Update dbg macro test to use check-run-results
flag for run-pass test
Updates the dbg-macro-expected behavior test to remove the workaround and use the `check-run-result` flag/feature in compiletest. This serves to test the feature on a real use-case (as mentioned in #63751)
This commit is contained in:
parent
0e3bc62f39
commit
12e0420268
@ -1,7 +1,5 @@
|
||||
// run-pass
|
||||
// ignore-cloudabi no processes
|
||||
// ignore-emscripten no processes
|
||||
// ignore-sgx no processes
|
||||
// check-run-results
|
||||
|
||||
// Tests ensuring that `dbg!(expr)` has the expected run-time behavior.
|
||||
// as well as some compile time properties we expect.
|
||||
@ -18,7 +16,7 @@ struct Point<T> {
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct NoCopy(usize);
|
||||
|
||||
fn test() {
|
||||
fn main() {
|
||||
let a: Unit = dbg!(Unit);
|
||||
let _: Unit = dbg!(a);
|
||||
// We can move `a` because it's Copy.
|
||||
@ -67,81 +65,3 @@ fn f<'a>(x: &'a u8) -> &'a u8 { x }
|
||||
assert_eq!((1u8, 2u32, "Yeah"), dbg!(1u8, 2u32,
|
||||
"Yeah",));
|
||||
}
|
||||
|
||||
fn validate_stderr(stderr: Vec<String>) {
|
||||
assert_eq!(stderr, &[
|
||||
":22] Unit = Unit",
|
||||
|
||||
":23] a = Unit",
|
||||
|
||||
":29] Point{x: 42, y: 24,} = Point {",
|
||||
" x: 42,",
|
||||
" y: 24,",
|
||||
"}",
|
||||
|
||||
":30] b = Point {",
|
||||
" x: 42,",
|
||||
" y: 24,",
|
||||
"}",
|
||||
|
||||
":38]",
|
||||
|
||||
":42] &a = NoCopy(",
|
||||
" 1337,",
|
||||
")",
|
||||
|
||||
":42] dbg!(& a) = NoCopy(",
|
||||
" 1337,",
|
||||
")",
|
||||
":47] f(&42) = 42",
|
||||
|
||||
"before",
|
||||
":52] { foo += 1; eprintln!(\"before\"); 7331 } = 7331",
|
||||
|
||||
":60] (\"Yeah\",) = (",
|
||||
" \"Yeah\",",
|
||||
")",
|
||||
|
||||
":63] 1 = 1",
|
||||
":63] 2 = 2",
|
||||
|
||||
":67] 1u8 = 1",
|
||||
":67] 2u32 = 2",
|
||||
":67] \"Yeah\" = \"Yeah\"",
|
||||
]);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// The following is a hack to deal with compiletest's inability
|
||||
// to check the output (to stdout) of run-pass tests.
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
|
||||
let mut args = env::args();
|
||||
let prog = args.next().unwrap();
|
||||
let child = args.next();
|
||||
if let Some("child") = child.as_ref().map(|s| &**s) {
|
||||
// Only run the test if we've been spawned as 'child'
|
||||
test()
|
||||
} else {
|
||||
// This essentially spawns as 'child' to run the tests
|
||||
// and then it collects output of stderr and checks the output
|
||||
// against what we expect.
|
||||
let out = Command::new(&prog).arg("child").output().unwrap();
|
||||
assert!(out.status.success());
|
||||
assert!(out.stdout.is_empty());
|
||||
|
||||
let stderr = String::from_utf8(out.stderr).unwrap();
|
||||
let stderr = stderr.lines().map(|mut s| {
|
||||
if s.starts_with("[") {
|
||||
// Strip `[` and file path:
|
||||
s = s.trim_start_matches("[");
|
||||
assert!(s.starts_with(file!()));
|
||||
s = s.trim_start_matches(file!());
|
||||
}
|
||||
s.to_owned()
|
||||
}).collect();
|
||||
|
||||
validate_stderr(stderr);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
[$DIR/dbg-macro-expected-behavior.rs:20] Unit = Unit
|
||||
[$DIR/dbg-macro-expected-behavior.rs:21] a = Unit
|
||||
[$DIR/dbg-macro-expected-behavior.rs:27] Point{x: 42, y: 24,} = Point {
|
||||
x: 42,
|
||||
y: 24,
|
||||
}
|
||||
[$DIR/dbg-macro-expected-behavior.rs:28] b = Point {
|
||||
x: 42,
|
||||
y: 24,
|
||||
}
|
||||
[$DIR/dbg-macro-expected-behavior.rs:36]
|
||||
[$DIR/dbg-macro-expected-behavior.rs:40] &a = NoCopy(
|
||||
1337,
|
||||
)
|
||||
[$DIR/dbg-macro-expected-behavior.rs:40] dbg!(& a) = NoCopy(
|
||||
1337,
|
||||
)
|
||||
[$DIR/dbg-macro-expected-behavior.rs:45] f(&42) = 42
|
||||
before
|
||||
[$DIR/dbg-macro-expected-behavior.rs:50] { foo += 1; eprintln!("before"); 7331 } = 7331
|
||||
[$DIR/dbg-macro-expected-behavior.rs:58] ("Yeah",) = (
|
||||
"Yeah",
|
||||
)
|
||||
[$DIR/dbg-macro-expected-behavior.rs:61] 1 = 1
|
||||
[$DIR/dbg-macro-expected-behavior.rs:61] 2 = 2
|
||||
[$DIR/dbg-macro-expected-behavior.rs:65] 1u8 = 1
|
||||
[$DIR/dbg-macro-expected-behavior.rs:65] 2u32 = 2
|
||||
[$DIR/dbg-macro-expected-behavior.rs:65] "Yeah" = "Yeah"
|
Loading…
Reference in New Issue
Block a user