From d8cd6f060bfaa12fa3ecddf391ac3c2b966e188a Mon Sep 17 00:00:00 2001 From: Sondre Lefsaker Date: Sat, 2 May 2015 18:18:05 +0200 Subject: [PATCH] Modify test to build `main` like before, but `lib` also gets built as a dependency. - The test verifies that the trailing arguments only gets passed to the binary being built --- tests/test_cargo_rustc.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/test_cargo_rustc.rs b/tests/test_cargo_rustc.rs index f370986a6..1ead1a31d 100644 --- a/tests/test_cargo_rustc.rs +++ b/tests/test_cargo_rustc.rs @@ -82,14 +82,31 @@ test!(build_main_and_allow_unstable_options { "#) .file("src/main.rs", r#" fn main() {} - "#); + "#) + .file("src/lib.rs", r#" "#); - assert_that(p.cargo_process("rustc").arg("-v") + assert_that(p.cargo_process("rustc").arg("-v").arg("--bin").arg("foo") .arg("--").arg("-Z").arg("unstable-options"), execs() .with_status(0) - .with_stdout(verbose_output_for_target_with_args(false, &p, - "-Z unstable-options"))); + .with_stdout(&format!("\ +{compiling} {name} v{version} ({url}) +{running} `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \ + --out-dir {dir}{sep}target{sep}debug \ + --emit=dep-info,link \ + -L dependency={dir}{sep}target{sep}debug \ + -L dependency={dir}{sep}target{sep}debug{sep}deps` +{running} `rustc src{sep}main.rs --crate-name {name} --crate-type bin -g \ + -Z unstable-options \ + --out-dir {dir}{sep}target{sep}debug \ + --emit=dep-info,link \ + -L dependency={dir}{sep}target{sep}debug \ + -L dependency={dir}{sep}target{sep}debug{sep}deps \ + --extern {name}={dir}{sep}target{sep}debug{sep}lib{name}.rlib` +", + running = RUNNING, compiling = COMPILING, sep = SEP, + dir = p.root().display(), url = p.url(), + name = "foo", version = "0.0.1"))); }); test!(fails_when_trying_to_build_main_and_lib_with_args { @@ -106,7 +123,6 @@ test!(fails_when_trying_to_build_main_and_lib_with_args { "#) .file("src/lib.rs", r#" "#); - assert_that(p.cargo_process("rustc").arg("-v") .arg("--").arg("-Z").arg("unstable-options"), execs()