Skip to content

Commit 0bf8e54

Browse files
committed
Add tests for --all-targets
1 parent 89d5161 commit 0bf8e54

File tree

3 files changed

+110
-1
lines changed

3 files changed

+110
-1
lines changed

tests/testsuite/build.rs

+49
Original file line numberDiff line numberDiff line change
@@ -5336,6 +5336,55 @@ fn build_filter_infer_profile() {
53365336
);
53375337
}
53385338

5339+
#[test]
5340+
fn all_targets_with_and_without() {
5341+
let p = project("foo")
5342+
.file(
5343+
"Cargo.toml",
5344+
r#"
5345+
[package]
5346+
name = "foo"
5347+
version = "0.1.0"
5348+
authors = []
5349+
"#,
5350+
)
5351+
.file("src/main.rs", "fn main() {}")
5352+
.build();
5353+
assert_that(
5354+
p.cargo("build").arg("-v").arg("--all-targets"),
5355+
execs().with_status(0)
5356+
// bin
5357+
.with_stderr_contains("\
5358+
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
5359+
--emit=dep-info,link[..]")
5360+
// bench
5361+
.with_stderr_contains("\
5362+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
5363+
-C opt-level=3 --test [..]")
5364+
// unit test
5365+
.with_stderr_contains("\
5366+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
5367+
-C debuginfo=2 --test [..]"),
5368+
);
5369+
assert_that(p.cargo("clean"), execs().with_status(0));
5370+
assert_that(
5371+
p.cargo("build").arg("-v"),
5372+
execs().with_status(0)
5373+
// bin
5374+
.with_stderr_contains("\
5375+
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
5376+
--emit=dep-info,link[..]")
5377+
// bench
5378+
.with_stderr_does_not_contain("\
5379+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
5380+
-C opt-level=3 --test [..]")
5381+
// unit test
5382+
.with_stderr_does_not_contain("\
5383+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
5384+
-C debuginfo=2 --test [..]"),
5385+
);
5386+
}
5387+
53395388
#[test]
53405389
fn all_targets_no_lib() {
53415390
let p = project("foo")

tests/testsuite/check.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ fn check_virtual_all_implied() {
606606
}
607607

608608
#[test]
609-
fn check_all_targets() {
609+
fn all_targets_with_and_without() {
610610
let foo = project("foo")
611611
.file("Cargo.toml", SIMPLE_MANIFEST)
612612
.file("src/main.rs", "fn main() {}")
@@ -626,6 +626,17 @@ fn check_all_targets() {
626626
.with_stderr_contains("[..] --crate-name test2 tests[/]test2.rs [..]")
627627
.with_stderr_contains("[..] --crate-name bench3 benches[/]bench3.rs [..]"),
628628
);
629+
assert_that(foo.cargo("clean"), execs().with_status(0));
630+
assert_that(
631+
foo.cargo("check").arg("-v"),
632+
execs()
633+
.with_status(0)
634+
.with_stderr_contains("[..] --crate-name foo src[/]lib.rs [..]")
635+
.with_stderr_contains("[..] --crate-name foo src[/]main.rs [..]")
636+
.with_stderr_does_not_contain("[..] --crate-name example1 examples[/]example1.rs [..]")
637+
.with_stderr_does_not_contain("[..] --crate-name test2 tests[/]test2.rs [..]")
638+
.with_stderr_does_not_contain("[..] --crate-name bench3 benches[/]bench3.rs [..]"),
639+
);
629640
}
630641

631642
#[test]

tests/testsuite/rustc.rs

+49
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,55 @@ fn build_only_bar_dependency() {
437437
);
438438
}
439439

440+
#[test]
441+
fn all_targets_with_and_without() {
442+
let p = project("foo")
443+
.file(
444+
"Cargo.toml",
445+
r#"
446+
[package]
447+
name = "foo"
448+
version = "0.1.0"
449+
authors = []
450+
"#,
451+
)
452+
.file("src/main.rs", "fn main() {}")
453+
.build();
454+
assert_that(
455+
p.cargo("rustc").arg("-v").arg("--all-targets"),
456+
execs().with_status(0)
457+
// bin
458+
.with_stderr_contains("\
459+
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
460+
--emit=dep-info,link[..]")
461+
// bench
462+
.with_stderr_contains("\
463+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
464+
-C opt-level=3 --test [..]")
465+
// unit test
466+
.with_stderr_contains("\
467+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
468+
-C debuginfo=2 --test [..]"),
469+
);
470+
assert_that(p.cargo("clean"), execs().with_status(0));
471+
assert_that(
472+
p.cargo("rustc").arg("-v"),
473+
execs().with_status(0)
474+
// bin
475+
.with_stderr_contains("\
476+
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
477+
--emit=dep-info,link[..]")
478+
// bench
479+
.with_stderr_does_not_contain("\
480+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
481+
-C opt-level=3 --test [..]")
482+
// unit test
483+
.with_stderr_does_not_contain("\
484+
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
485+
-C debuginfo=2 --test [..]"),
486+
);
487+
}
488+
440489
#[test]
441490
fn fail_with_multiple_packages() {
442491
let foo = project("foo")

0 commit comments

Comments
 (0)