Skip to content

Commit db472cc

Browse files
authored
Auto merge of #3253 - nipunn1313:exe, r=alexcrichton
Add an [EXE] hamcrest substitution for file extension This should make the testing a bit more precise as to whether we expect targets of the form foo.exe vs foo-abc123.exe. I was also considering adding a [/] substitution for the fwd slash vs backslash [..], but thought I would leave that to another PR if we thought that was a good idea.
2 parents 84a3e5c + dab3f5a commit db472cc

File tree

9 files changed

+115
-114
lines changed

9 files changed

+115
-114
lines changed

tests/bench.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn cargo_bench_simple() {
4343
execs().with_stderr(&format!("\
4444
[COMPILING] foo v0.5.0 ({})
4545
[FINISHED] release [optimized] target(s) in [..]
46-
[RUNNING] target[..]release[..]foo-[..]", p.url()))
46+
[RUNNING] target[..]release[..]foo-[..][EXE]", p.url()))
4747
.with_stdout("
4848
running 1 test
4949
test bench_hello ... bench: [..] 0 ns/iter (+/- 0)
@@ -78,7 +78,7 @@ fn bench_tarname() {
7878
.with_stderr(format!("\
7979
[COMPILING] foo v0.0.1 ({dir})
8080
[FINISHED] release [optimized] target(s) in [..]
81-
[RUNNING] target[..]release[..]bin2[..]
81+
[RUNNING] target[..]release[..]bin2-[..][EXE]
8282
", dir = prj.url()))
8383
.with_stdout("
8484
running 1 test
@@ -107,7 +107,7 @@ fn cargo_bench_verbose() {
107107
[COMPILING] foo v0.5.0 ({url})
108108
[RUNNING] `rustc src[..]foo.rs [..]`
109109
[FINISHED] release [optimized] target(s) in [..]
110-
[RUNNING] `[..]target[..]release[..]foo-[..] hello --bench`", url = p.url()))
110+
[RUNNING] `[..]target[..]release[..]foo-[..][EXE] hello --bench`", url = p.url()))
111111
.with_stdout("
112112
running 1 test
113113
test bench_hello ... bench: [..] 0 ns/iter (+/- 0)
@@ -190,7 +190,7 @@ test bench_hello ... ")
190190
.with_stderr_contains(format!("\
191191
[COMPILING] foo v0.5.0 ({})
192192
[FINISHED] release [optimized] target(s) in [..]
193-
[RUNNING] target[..]release[..]foo-[..]
193+
[RUNNING] target[..]release[..]foo-[..][EXE]
194194
thread '[..]' panicked at 'assertion failed: \
195195
`(left == right)` (left: \
196196
`\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:14
@@ -243,8 +243,8 @@ fn bench_with_lib_dep() {
243243
execs().with_stderr(&format!("\
244244
[COMPILING] foo v0.0.1 ({})
245245
[FINISHED] release [optimized] target(s) in [..]
246-
[RUNNING] target[..]release[..]baz-[..]
247-
[RUNNING] target[..]release[..]foo-[..]", p.url()))
246+
[RUNNING] target[..]release[..]baz-[..][EXE]
247+
[RUNNING] target[..]release[..]foo-[..][EXE]", p.url()))
248248
.with_stdout("
249249
running 1 test
250250
test bin_bench ... bench: [..] 0 ns/iter (+/- 0)
@@ -307,7 +307,7 @@ fn bench_with_deep_lib_dep() {
307307
[COMPILING] foo v0.0.1 ([..])
308308
[COMPILING] bar v0.0.1 ({dir})
309309
[FINISHED] release [optimized] target(s) in [..]
310-
[RUNNING] target[..]", dir = p.url()))
310+
[RUNNING] target[..]release[..]deps[..]bar-[..][EXE]", dir = p.url()))
311311
.with_stdout("
312312
running 1 test
313313
test bar_bench ... bench: [..] 0 ns/iter (+/- 0)
@@ -353,8 +353,8 @@ fn external_bench_explicit() {
353353
execs().with_stderr(&format!("\
354354
[COMPILING] foo v0.0.1 ({})
355355
[FINISHED] release [optimized] target(s) in [..]
356-
[RUNNING] target[..]release[..]bench-[..]
357-
[RUNNING] target[..]release[..]foo-[..]", p.url()))
356+
[RUNNING] target[..]release[..]bench-[..][EXE]
357+
[RUNNING] target[..]release[..]foo-[..][EXE]", p.url()))
358358
.with_stdout("
359359
running 1 test
360360
test external_bench ... bench: [..] 0 ns/iter (+/- 0)
@@ -403,8 +403,8 @@ fn external_bench_implicit() {
403403
execs().with_stderr(&format!("\
404404
[COMPILING] foo v0.0.1 ({})
405405
[FINISHED] release [optimized] target(s) in [..]
406-
[RUNNING] target[..]release[..]external-[..]
407-
[RUNNING] target[..]release[..]foo-[..]", p.url()))
406+
[RUNNING] target[..]release[..]external-[..][EXE]
407+
[RUNNING] target[..]release[..]foo-[..][EXE]", p.url()))
408408
.with_stdout("
409409
running 1 test
410410
test external_bench ... bench: [..] 0 ns/iter (+/- 0)
@@ -464,7 +464,7 @@ fn pass_through_command_line() {
464464
.with_stderr(&format!("\
465465
[COMPILING] foo v0.0.1 ({dir})
466466
[FINISHED] release [optimized] target(s) in [..]
467-
[RUNNING] target[..]release[..]foo-[..]", dir = p.url()))
467+
[RUNNING] target[..]release[..]foo-[..][EXE]", dir = p.url()))
468468
.with_stdout("
469469
running 1 test
470470
test bar ... bench: [..] 0 ns/iter (+/- 0)
@@ -476,7 +476,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
476476
assert_that(p.cargo("bench").arg("foo"),
477477
execs().with_status(0)
478478
.with_stderr("[FINISHED] release [optimized] target(s) in [..]
479-
[RUNNING] target[..]release[..]foo-[..]")
479+
[RUNNING] target[..]release[..]foo-[..][EXE]")
480480
.with_stdout("
481481
running 1 test
482482
test foo ... bench: [..] 0 ns/iter (+/- 0)
@@ -546,8 +546,8 @@ fn lib_bin_same_name() {
546546
execs().with_stderr(&format!("\
547547
[COMPILING] foo v0.0.1 ({})
548548
[FINISHED] release [optimized] target(s) in [..]
549-
[RUNNING] target[..]release[..]foo-[..]
550-
[RUNNING] target[..]release[..]foo-[..]", p.url()))
549+
[RUNNING] target[..]release[..]foo-[..][EXE]
550+
[RUNNING] target[..]release[..]foo-[..][EXE]", p.url()))
551551
.with_stdout("
552552
running 1 test
553553
test [..] ... bench: [..] 0 ns/iter (+/- 0)
@@ -600,8 +600,8 @@ fn lib_with_standard_name() {
600600
.with_stderr(&format!("\
601601
[COMPILING] syntax v0.0.1 ({dir})
602602
[FINISHED] release [optimized] target(s) in [..]
603-
[RUNNING] target[..]release[..]bench-[..]
604-
[RUNNING] target[..]release[..]syntax-[..]", dir = p.url()))
603+
[RUNNING] target[..]release[..]bench-[..][EXE]
604+
[RUNNING] target[..]release[..]syntax-[..][EXE]", dir = p.url()))
605605
.with_stdout("
606606
running 1 test
607607
test bench ... bench: [..] 0 ns/iter (+/- 0)
@@ -652,7 +652,7 @@ fn lib_with_standard_name2() {
652652
.with_stderr(&format!("\
653653
[COMPILING] syntax v0.0.1 ({dir})
654654
[FINISHED] release [optimized] target(s) in [..]
655-
[RUNNING] target[..]release[..]syntax-[..]", dir = p.url()))
655+
[RUNNING] target[..]release[..]syntax-[..][EXE]", dir = p.url()))
656656
.with_stdout("
657657
running 1 test
658658
test bench ... bench: [..] 0 ns/iter (+/- 0)
@@ -722,8 +722,8 @@ fn bench_dylib() {
722722
[RUNNING] [..] -C opt-level=3 [..]
723723
[RUNNING] [..] -C opt-level=3 [..]
724724
[FINISHED] release [optimized] target(s) in [..]
725-
[RUNNING] [..]target[..]release[..]bench-[..]
726-
[RUNNING] [..]target[..]release[..]foo-[..]", dir = p.url()))
725+
[RUNNING] `[..]target[..]release[..]bench-[..][EXE] --bench`
726+
[RUNNING] `[..]target[..]release[..]foo-[..][EXE] --bench`", dir = p.url()))
727727
.with_stdout("
728728
running 1 test
729729
test foo ... bench: [..] 0 ns/iter (+/- 0)
@@ -744,8 +744,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
744744
[FRESH] bar v0.0.1 ({dir}/bar)
745745
[FRESH] foo v0.0.1 ({dir})
746746
[FINISHED] release [optimized] target(s) in [..]
747-
[RUNNING] [..]target[..]release[..]bench-[..]
748-
[RUNNING] [..]target[..]release[..]foo-[..]", dir = p.url()))
747+
[RUNNING] `[..]target[..]release[..]bench-[..][EXE] --bench`
748+
[RUNNING] `[..]target[..]release[..]foo-[..][EXE] --bench`", dir = p.url()))
749749
.with_stdout("
750750
running 1 test
751751
test foo ... bench: [..] 0 ns/iter (+/- 0)
@@ -786,7 +786,7 @@ fn bench_twice_with_build_cmd() {
786786
.with_stderr(&format!("\
787787
[COMPILING] foo v0.0.1 ({dir})
788788
[FINISHED] release [optimized] target(s) in [..]
789-
[RUNNING] target[..]release[..]foo-[..]", dir = p.url()))
789+
[RUNNING] target[..]release[..]foo-[..][EXE]", dir = p.url()))
790790
.with_stdout("
791791
running 1 test
792792
test foo ... bench: [..] 0 ns/iter (+/- 0)
@@ -798,7 +798,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
798798
assert_that(p.cargo("bench"),
799799
execs().with_status(0)
800800
.with_stderr("[FINISHED] release [optimized] target(s) in [..]
801-
[RUNNING] target[..]release[..]foo-[..]")
801+
[RUNNING] target[..]release[..]foo-[..][EXE]")
802802
.with_stdout("
803803
running 1 test
804804
test foo ... bench: [..] 0 ns/iter (+/- 0)
@@ -871,8 +871,8 @@ fn bench_with_examples() {
871871
[RUNNING] `rustc [..]`
872872
[RUNNING] `rustc [..]`
873873
[FINISHED] release [optimized] target(s) in [..]
874-
[RUNNING] `{dir}[..]target[..]release[..]testb1-[..] --bench`
875-
[RUNNING] `{dir}[..]target[..]release[..]testbench-[..] --bench`",
874+
[RUNNING] `{dir}[..]target[..]release[..]testb1-[..][EXE] --bench`
875+
[RUNNING] `{dir}[..]target[..]release[..]testbench-[..][EXE] --bench`",
876876
dir = p.root().display(), url = p.url()))
877877
.with_stdout("
878878
running 1 test
@@ -920,7 +920,7 @@ fn test_a_bench() {
920920
.with_stderr("\
921921
[COMPILING] foo v0.1.0 ([..])
922922
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
923-
[RUNNING] target[..]debug[..]b-[..]")
923+
[RUNNING] target[..]debug[..]b-[..][EXE]")
924924
.with_stdout("
925925
running 1 test
926926
test foo ... ok
@@ -1030,15 +1030,15 @@ fn test_bench_multiple_packages() {
10301030
assert_that(p.cargo_process("bench").arg("-p").arg("bar").arg("-p").arg("baz"),
10311031
execs().with_status(0)
10321032
.with_stderr_contains("\
1033-
[RUNNING] target[..]release[..]bbaz-[..]")
1033+
[RUNNING] target[..]release[..]bbaz-[..][EXE]")
10341034
.with_stdout_contains("
10351035
running 1 test
10361036
test bench_baz ... bench: 0 ns/iter (+/- 0)
10371037
10381038
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
10391039
")
10401040
.with_stderr_contains("\
1041-
[RUNNING] target[..]release[..]bbar-[..]")
1041+
[RUNNING] target[..]release[..]bbar-[..][EXE]")
10421042
.with_stdout_contains("
10431043
running 1 test
10441044
test bench_bar ... bench: 0 ns/iter (+/- 0)

tests/build-script.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn custom_build_script_failed() {
3434
.with_stderr(&format!("\
3535
[COMPILING] foo v0.5.0 ({url})
3636
[RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin [..]`
37-
[RUNNING] `[..]build-script-build[..]`
37+
[RUNNING] `[..]build-script-build`
3838
[ERROR] failed to run custom build command for `foo v0.5.0 ({url})`
3939
process didn't exit successfully: `[..]build-script-build[..]` (exit code: 101)",
4040
url = p.url())));
@@ -407,7 +407,7 @@ fn only_rerun_build_script() {
407407
execs().with_status(0)
408408
.with_stderr("\
409409
[COMPILING] foo v0.5.0 (file://[..])
410-
[RUNNING] `[..]build-script-build[..]`
410+
[RUNNING] `[..]build-script-build`
411411
[RUNNING] `rustc [..] --crate-name foo [..]`
412412
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
413413
"));
@@ -495,11 +495,11 @@ fn testing_and_such() {
495495
execs().with_status(0)
496496
.with_stderr("\
497497
[COMPILING] foo v0.5.0 (file://[..])
498-
[RUNNING] `[..]build-script-build[..]`
498+
[RUNNING] `[..]build-script-build`
499499
[RUNNING] `rustc [..] --crate-name foo [..]`
500500
[RUNNING] `rustc [..] --crate-name foo [..]`
501501
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
502-
[RUNNING] `[..]foo-[..][..]`
502+
[RUNNING] `[..]foo-[..][EXE]`
503503
[DOCTEST] foo
504504
[RUNNING] `rustdoc --test [..]`")
505505
.with_stdout("
@@ -530,7 +530,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
530530
.with_stderr("\
531531
[COMPILING] foo v0.5.0 (file://[..])
532532
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
533-
[RUNNING] `target[..]foo[..]`
533+
[RUNNING] `target[..]foo[EXE]`
534534
"));
535535
}
536536

@@ -674,7 +674,7 @@ fn build_deps_simple() {
674674
[RUNNING] `rustc [..] --crate-name a [..]`
675675
[COMPILING] foo v0.5.0 (file://[..])
676676
[RUNNING] `rustc build.rs [..] --extern a=[..]`
677-
[RUNNING] `[..]foo-[..]build-script-build[..]`
677+
[RUNNING] `[..]foo-[..]build-script-build`
678678
[RUNNING] `rustc [..] --crate-name foo [..]`
679679
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
680680
"));
@@ -764,7 +764,7 @@ fn build_cmd_with_a_build_cmd() {
764764
[RUNNING] `rustc [..] --crate-name b [..]`
765765
[COMPILING] a v0.5.0 (file://[..])
766766
[RUNNING] `rustc a[..]build.rs [..] --extern b=[..]`
767-
[RUNNING] `[..]a-[..]build-script-build[..]`
767+
[RUNNING] `[..]a-[..]build-script-build`
768768
[RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \
769769
-C metadata=[..] \
770770
--out-dir [..]target[..]deps --emit=dep-info,link \
@@ -774,7 +774,7 @@ fn build_cmd_with_a_build_cmd() {
774774
-g -C metadata=[..] --out-dir [..] --emit=dep-info,link \
775775
-L [..]target[..]deps \
776776
--extern a=[..]liba[..].rlib`
777-
[RUNNING] `[..]foo-[..]build-script-build[..]`
777+
[RUNNING] `[..]foo-[..]build-script-build`
778778
[RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \
779779
-C metadata=[..] \
780780
--out-dir [..] --emit=dep-info,link \
@@ -854,7 +854,7 @@ fn output_separate_lines() {
854854
.with_stderr_contains("\
855855
[COMPILING] foo v0.5.0 (file://[..])
856856
[RUNNING] `rustc build.rs [..]`
857-
[RUNNING] `[..]foo-[..]build-script-build[..]`
857+
[RUNNING] `[..]foo-[..]build-script-build`
858858
[RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo`
859859
[ERROR] could not find native static library [..]
860860
"));
@@ -882,7 +882,7 @@ fn output_separate_lines_new() {
882882
.with_stderr_contains("\
883883
[COMPILING] foo v0.5.0 (file://[..])
884884
[RUNNING] `rustc build.rs [..]`
885-
[RUNNING] `[..]foo-[..]build-script-build[..]`
885+
[RUNNING] `[..]foo-[..]build-script-build`
886886
[RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo`
887887
[ERROR] could not find native static library [..]
888888
"));
@@ -1364,13 +1364,13 @@ fn cfg_test() {
13641364
execs().with_stderr(format!("\
13651365
[COMPILING] foo v0.0.1 ({dir})
13661366
[RUNNING] [..] build.rs [..]
1367-
[RUNNING] [..]build-script-build[..]
1367+
[RUNNING] `[..]build-script-build`
13681368
[RUNNING] [..] --cfg foo[..]
13691369
[RUNNING] [..] --cfg foo[..]
13701370
[RUNNING] [..] --cfg foo[..]
13711371
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
1372-
[RUNNING] [..]foo-[..]
1373-
[RUNNING] [..]test-[..]
1372+
[RUNNING] `[..]foo-[..][EXE]`
1373+
[RUNNING] `[..]test-[..][EXE]`
13741374
[DOCTEST] foo
13751375
[RUNNING] [..] --cfg foo[..]", dir = p.url()))
13761376
.with_stdout("
@@ -1486,8 +1486,8 @@ fn cfg_override_test() {
14861486
[RUNNING] `[..]`
14871487
[RUNNING] `[..]`
14881488
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
1489-
[RUNNING] [..]foo-[..]
1490-
[RUNNING] [..]test-[..]
1489+
[RUNNING] `[..]foo-[..][EXE]`
1490+
[RUNNING] `[..]test-[..][EXE]`
14911491
[DOCTEST] foo
14921492
[RUNNING] [..] --cfg foo[..]", dir = p.url()))
14931493
.with_stdout("
@@ -1598,15 +1598,15 @@ fn flags_go_into_tests() {
15981598
.with_stderr("\
15991599
[COMPILING] a v0.5.0 ([..]
16001600
[RUNNING] `rustc a[..]build.rs [..]`
1601-
[RUNNING] `[..]build-script-build[..]`
1601+
[RUNNING] `[..]build-script-build`
16021602
[RUNNING] `rustc a[..]src[..]lib.rs [..] -L test[..]`
16031603
[COMPILING] b v0.5.0 ([..]
16041604
[RUNNING] `rustc b[..]src[..]lib.rs [..] -L test[..]`
16051605
[COMPILING] foo v0.5.0 ([..]
16061606
[RUNNING] `rustc src[..]lib.rs [..] -L test[..]`
16071607
[RUNNING] `rustc tests[..]foo.rs [..] -L test[..]`
16081608
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
1609-
[RUNNING] `[..]foo-[..]`")
1609+
[RUNNING] `[..]foo-[..][EXE]`")
16101610
.with_stdout("
16111611
running 0 tests
16121612
@@ -1621,7 +1621,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
16211621
[COMPILING] b v0.5.0 ([..]
16221622
[RUNNING] `rustc b[..]src[..]lib.rs [..] -L test[..]`
16231623
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
1624-
[RUNNING] `[..]b-[..]`")
1624+
[RUNNING] `[..]b-[..][EXE]`")
16251625
.with_stdout("
16261626
running 0 tests
16271627
@@ -1802,7 +1802,7 @@ fn rebuild_only_on_explicit_paths() {
18021802
assert_that(p.cargo("build").arg("-v"),
18031803
execs().with_status(0).with_stderr("\
18041804
[COMPILING] a v0.5.0 ([..])
1805-
[RUNNING] `[..]build-script-build[..]`
1805+
[RUNNING] `[..]build-script-build`
18061806
[RUNNING] `rustc src[..]lib.rs [..]`
18071807
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
18081808
"));
@@ -1816,7 +1816,7 @@ fn rebuild_only_on_explicit_paths() {
18161816
assert_that(p.cargo("build").arg("-v"),
18171817
execs().with_status(0).with_stderr("\
18181818
[COMPILING] a v0.5.0 ([..])
1819-
[RUNNING] `[..]build-script-build[..]`
1819+
[RUNNING] `[..]build-script-build`
18201820
[RUNNING] `rustc src[..]lib.rs [..]`
18211821
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
18221822
"));
@@ -1845,7 +1845,7 @@ fn rebuild_only_on_explicit_paths() {
18451845
assert_that(p.cargo("build").arg("-v"),
18461846
execs().with_status(0).with_stderr("\
18471847
[COMPILING] a v0.5.0 ([..])
1848-
[RUNNING] `[..]build-script-build[..]`
1848+
[RUNNING] `[..]build-script-build`
18491849
[RUNNING] `rustc src[..]lib.rs [..]`
18501850
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
18511851
"));
@@ -1856,7 +1856,7 @@ fn rebuild_only_on_explicit_paths() {
18561856
assert_that(p.cargo("build").arg("-v"),
18571857
execs().with_status(0).with_stderr("\
18581858
[COMPILING] a v0.5.0 ([..])
1859-
[RUNNING] `[..]build-script-build[..]`
1859+
[RUNNING] `[..]build-script-build`
18601860
[RUNNING] `rustc src[..]lib.rs [..]`
18611861
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
18621862
"));

tests/cargotest/support/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ fn substitute_macros(input: &str) -> String {
672672
("[INSTALLING]", " Installing"),
673673
("[REPLACING]", " Replacing"),
674674
("[UNPACKING]", " Unpacking"),
675+
("[EXE]", if cfg!(windows) {".exe"} else {""}),
675676
];
676677
let mut result = input.to_owned();
677678
for &(pat, subst) in macros.iter() {

tests/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn build_script() {
172172
execs().with_status(0).with_stderr("\
173173
[COMPILING] foo v0.0.1 ([..])
174174
[RUNNING] `rustc build.rs [..]`
175-
[RUNNING] `[..]build-script-build[..]`
175+
[RUNNING] `[..]build-script-build`
176176
[RUNNING] `rustc src[..]main.rs [..]`
177177
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
178178
"));

0 commit comments

Comments
 (0)