Skip to content

Commit

Permalink
Auto merge of #5950 - dwijnand:cwd, r=alexcrichton
Browse files Browse the repository at this point in the history
Introduce the CWD macro in test output asserting

Avoids dealing with things like CWD changing.

Mentioned in #5742
  • Loading branch information
bors committed Aug 30, 2018
2 parents 1f49100 + d5fc8dc commit 9ab347d
Show file tree
Hide file tree
Showing 35 changed files with 583 additions and 862 deletions.
30 changes: 12 additions & 18 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ fn depend_on_alt_registry() {
[UPDATING] registry `{reg}`
[DOWNLOADING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
dir = p.url(),
reg = registry::alt_registry()
)).run();

Expand All @@ -71,14 +70,13 @@ fn depend_on_alt_registry() {
// Don't download a second time
p.cargo("build")
.masquerade_as_nightly_cargo()
.with_stderr(&format!(
.with_stderr(
"\
[COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
dir = p.url()
)).run();
).run();
}

#[test]
Expand Down Expand Up @@ -116,10 +114,9 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() {
[DOWNLOADING] [..] v0.0.1 (registry `file://[..]`)
[COMPILING] baz v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
dir = p.url(),
reg = registry::alt_registry()
)).run();
}
Expand Down Expand Up @@ -159,10 +156,9 @@ fn depend_on_alt_registry_depends_on_same_registry() {
[DOWNLOADING] [..] v0.0.1 (registry `file://[..]`)
[COMPILING] baz v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
dir = p.url(),
reg = registry::alt_registry()
)).run();
}
Expand Down Expand Up @@ -203,10 +199,9 @@ fn depend_on_alt_registry_depends_on_crates_io() {
[DOWNLOADING] [..] v0.0.1 (registry `file://[..]`)
[COMPILING] baz v0.0.1 (registry `file://[..]`)
[COMPILING] bar v0.0.1 (registry `file://[..]`)
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
dir = p.url(),
alt_reg = registry::alt_registry(),
reg = registry::registry()
)).run();
Expand Down Expand Up @@ -238,14 +233,13 @@ fn registry_and_path_dep_works() {

p.cargo("build")
.masquerade_as_nightly_cargo()
.with_stderr(&format!(
.with_stderr(
"\
[COMPILING] bar v0.0.1 ({dir}/bar)
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] bar v0.0.1 (CWD/bar)
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
dir = p.url()
)).run();
).run();
}

#[test]
Expand Down Expand Up @@ -371,7 +365,7 @@ fn alt_registry_and_crates_io_deps() {
.with_stderr_contains("[DOWNLOADING] alt_reg_dep v0.1.0 (registry `file://[..]`)")
.with_stderr_contains("[COMPILING] alt_reg_dep v0.1.0 (registry `file://[..]`)")
.with_stderr_contains("[COMPILING] crates_io_dep v0.0.1")
.with_stderr_contains(&format!("[COMPILING] foo v0.0.1 ({})", p.url()))
.with_stderr_contains("[COMPILING] foo v0.0.1 (CWD)")
.with_stderr_contains("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s")
.run();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ fn unused_keys() {
.with_stderr(
"\
warning: unused manifest key: target.foo.bar
[COMPILING] foo v0.1.0 (file:///[..])
[COMPILING] foo v0.1.0 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
).run();
Expand Down
66 changes: 23 additions & 43 deletions tests/testsuite/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ fn cargo_bench_simple() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] foo v0.5.0 ({})
[COMPILING] foo v0.5.0 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]",
p.url()
)).with_stdout_contains("test bench_hello ... bench: [..]")
.run();
}
Expand Down Expand Up @@ -79,12 +78,11 @@ fn bench_bench_implicit() {
p.cargo("bench --benches")
.with_stderr(format!(
"\
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]
[RUNNING] target/release/deps/mybench-[..][EXE]
",
dir = p.url()
)).with_stdout_contains("test run2 ... bench: [..]")
.run();
}
Expand Down Expand Up @@ -121,11 +119,10 @@ fn bench_bin_implicit() {
p.cargo("bench --bins")
.with_stderr(format!(
"\
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]
",
dir = p.url()
)).with_stdout_contains("test run1 ... bench: [..]")
.run();
}
Expand Down Expand Up @@ -154,11 +151,10 @@ fn bench_tarname() {
p.cargo("bench --bench bin2")
.with_stderr(format!(
"\
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/bin2-[..][EXE]
",
dir = p.url()
)).with_stdout_contains("test run2 ... bench: [..]")
.run();
}
Expand Down Expand Up @@ -219,11 +215,10 @@ fn cargo_bench_verbose() {
p.cargo("bench -v hello")
.with_stderr(&format!(
"\
[COMPILING] foo v0.5.0 ({url})
[COMPILING] foo v0.5.0 (CWD)
[RUNNING] `rustc [..] src/main.rs [..]`
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `[..]target/release/deps/foo-[..][EXE] hello --bench`",
url = p.url()
)).with_stdout_contains("test bench_hello ... bench: [..]")
.run();
}
Expand Down Expand Up @@ -310,10 +305,9 @@ fn cargo_bench_failing_test() {
.with_stdout_contains("test bench_hello ...[..]")
.with_stderr_contains(format!(
"\
[COMPILING] foo v0.5.0 ({})[..]
[COMPILING] foo v0.5.0 (CWD)[..]
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]",
p.url()
)).with_either_contains(
"[..]thread '[..]' panicked at 'assertion failed: `(left == right)`[..]",
).with_either_contains("[..]left: `\"hello\"`[..]")
Expand Down Expand Up @@ -378,11 +372,10 @@ fn bench_with_lib_dep() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ({})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]
[RUNNING] target/release/deps/baz-[..][EXE]",
p.url()
)).with_stdout_contains("test lib_bench ... bench: [..]")
.with_stdout_contains("test bin_bench ... bench: [..]")
.run();
Expand Down Expand Up @@ -440,10 +433,9 @@ fn bench_with_deep_lib_dep() {
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ([..])
[COMPILING] bar v0.0.1 ({dir})
[COMPILING] bar v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/bar-[..][EXE]",
dir = p.url()
)).with_stdout_contains("test bar_bench ... bench: [..]")
.run();
}
Expand Down Expand Up @@ -494,11 +486,10 @@ fn external_bench_explicit() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ({})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]
[RUNNING] target/release/deps/bench-[..][EXE]",
p.url()
)).with_stdout_contains("test internal_bench ... bench: [..]")
.with_stdout_contains("test external_bench ... bench: [..]")
.run();
Expand Down Expand Up @@ -539,11 +530,10 @@ fn external_bench_implicit() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ({})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]
[RUNNING] target/release/deps/external-[..][EXE]",
p.url()
)).with_stdout_contains("test internal_bench ... bench: [..]")
.with_stdout_contains("test external_bench ... bench: [..]")
.run();
Expand Down Expand Up @@ -615,11 +605,10 @@ automatically infer them to be a target, such as in subfolders.
For more information on this warning you can consult
https://github.com/rust-lang/cargo/issues/5330
[COMPILING] foo v0.0.1 ({})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]
",
p.url()
)).run();
}

Expand Down Expand Up @@ -660,10 +649,9 @@ fn pass_through_command_line() {
p.cargo("bench bar")
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]",
dir = p.url()
)).with_stdout_contains("test bar ... bench: [..]")
.run();

Expand Down Expand Up @@ -748,11 +736,10 @@ fn lib_bin_same_name() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ({})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]
[RUNNING] target/release/deps/foo-[..][EXE]",
p.url()
)).with_stdout_contains_n("test [..] ... bench: [..]", 2)
.run();
}
Expand Down Expand Up @@ -795,11 +782,10 @@ fn lib_with_standard_name() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] syntax v0.0.1 ({dir})
[COMPILING] syntax v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/syntax-[..][EXE]
[RUNNING] target/release/deps/bench-[..][EXE]",
dir = p.url()
)).with_stdout_contains("test foo_bench ... bench: [..]")
.with_stdout_contains("test bench ... bench: [..]")
.run();
Expand Down Expand Up @@ -845,10 +831,9 @@ fn lib_with_standard_name2() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] syntax v0.0.1 ({dir})
[COMPILING] syntax v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/syntax-[..][EXE]",
dir = p.url()
)).with_stdout_contains("test bench ... bench: [..]")
.run();
}
Expand Down Expand Up @@ -916,29 +901,27 @@ fn bench_dylib() {
p.cargo("bench -v")
.with_stderr(&format!(
"\
[COMPILING] bar v0.0.1 ({dir}/bar)
[COMPILING] bar v0.0.1 (CWD/bar)
[RUNNING] [..] -C opt-level=3 [..]
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[RUNNING] [..] -C opt-level=3 [..]
[RUNNING] [..] -C opt-level=3 [..]
[RUNNING] [..] -C opt-level=3 [..]
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench`
[RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`",
dir = p.url()
)).with_stdout_contains_n("test foo ... bench: [..]", 2)
.run();

p.root().move_into_the_past();
p.cargo("bench -v")
.with_stderr(&format!(
"\
[FRESH] bar v0.0.1 ({dir}/bar)
[FRESH] foo v0.0.1 ({dir})
[FRESH] bar v0.0.1 (CWD/bar)
[FRESH] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench`
[RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`",
dir = p.url()
)).with_stdout_contains_n("test foo ... bench: [..]", 2)
.run();
}
Expand Down Expand Up @@ -974,10 +957,9 @@ fn bench_twice_with_build_cmd() {
p.cargo("bench")
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ({dir})
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target/release/deps/foo-[..][EXE]",
dir = p.url()
)).with_stdout_contains("test foo ... bench: [..]")
.run();

Expand Down Expand Up @@ -1059,15 +1041,13 @@ fn bench_with_examples() {
p.cargo("bench -v")
.with_stderr(&format!(
"\
[COMPILING] foo v6.6.6 ({url})
[COMPILING] foo v6.6.6 (CWD)
[RUNNING] `rustc [..]`
[RUNNING] `rustc [..]`
[RUNNING] `rustc [..]`
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `{dir}/target/release/deps/foo-[..][EXE] --bench`
[RUNNING] `{dir}/target/release/deps/testb1-[..][EXE] --bench`",
dir = p.root().display(),
url = p.url()
[RUNNING] `CWD/target/release/deps/foo-[..][EXE] --bench`
[RUNNING] `CWD/target/release/deps/testb1-[..][EXE] --bench`",
)).with_stdout_contains("test bench_bench1 ... bench: [..]")
.with_stdout_contains("test bench_bench2 ... bench: [..]")
.run();
Expand Down
Loading

0 comments on commit 9ab347d

Please sign in to comment.