2016-05-26 00:06:25 +00:00
|
|
|
use cargotest::rustc_host;
|
|
|
|
use cargotest::support::{path2url, project, execs};
|
2015-07-24 06:35:53 +00:00
|
|
|
use hamcrest::assert_that;
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn pathless_tools() {
|
2016-05-26 00:06:25 +00:00
|
|
|
let target = rustc_host();
|
2015-07-24 06:35:53 +00:00
|
|
|
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
name = "foo"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", &format!(r#"
|
|
|
|
[target.{}]
|
|
|
|
ar = "nonexistent-ar"
|
|
|
|
linker = "nonexistent-linker"
|
2017-07-22 03:12:21 +00:00
|
|
|
"#, target))
|
|
|
|
.build();
|
2015-07-24 06:35:53 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
assert_that(foo.cargo("build").arg("--verbose"),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_stderr(&format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
|
|
|
[RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
", url = foo.url())))
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-07-24 06:35:53 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn absolute_tools() {
|
2016-05-26 00:06:25 +00:00
|
|
|
let target = rustc_host();
|
2015-07-24 06:35:53 +00:00
|
|
|
|
|
|
|
// Escaped as they appear within a TOML config file
|
|
|
|
let config = if cfg!(windows) {
|
|
|
|
(r#"C:\\bogus\\nonexistent-ar"#, r#"C:\\bogus\\nonexistent-linker"#)
|
|
|
|
} else {
|
|
|
|
(r#"/bogus/nonexistent-ar"#, r#"/bogus/nonexistent-linker"#)
|
|
|
|
};
|
|
|
|
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
name = "foo"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file(".cargo/config", &format!(r#"
|
|
|
|
[target.{target}]
|
|
|
|
ar = "{ar}"
|
|
|
|
linker = "{linker}"
|
2017-07-22 03:12:21 +00:00
|
|
|
"#, target = target, ar = config.0, linker = config.1))
|
|
|
|
.build();
|
2015-07-24 06:35:53 +00:00
|
|
|
|
|
|
|
let output = if cfg!(windows) {
|
|
|
|
(r#"C:\bogus\nonexistent-ar"#, r#"C:\bogus\nonexistent-linker"#)
|
|
|
|
} else {
|
|
|
|
(r#"/bogus/nonexistent-ar"#, r#"/bogus/nonexistent-linker"#)
|
|
|
|
};
|
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
assert_that(foo.cargo("build").arg("--verbose"),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_stderr(&format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
|
|
|
[RUNNING] `rustc [..] -C ar={ar} -C linker={linker} [..]`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
", url = foo.url(), ar = output.0, linker = output.1)))
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-07-24 06:35:53 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn relative_tools() {
|
2016-05-26 00:06:25 +00:00
|
|
|
let target = rustc_host();
|
2015-07-24 06:35:53 +00:00
|
|
|
|
|
|
|
// Escaped as they appear within a TOML config file
|
|
|
|
let config = if cfg!(windows) {
|
|
|
|
(r#".\\nonexistent-ar"#, r#".\\tools\\nonexistent-linker"#)
|
|
|
|
} else {
|
|
|
|
(r#"./nonexistent-ar"#, r#"./tools/nonexistent-linker"#)
|
|
|
|
};
|
|
|
|
|
|
|
|
// Funky directory structure to test that relative tool paths are made absolute
|
|
|
|
// by reference to the `.cargo/..` directory and not to (for example) the CWD.
|
|
|
|
let origin = project("origin")
|
|
|
|
.file("foo/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
name = "foo"
|
|
|
|
"#)
|
|
|
|
.file("foo/src/lib.rs", "")
|
|
|
|
.file(".cargo/config", &format!(r#"
|
|
|
|
[target.{target}]
|
|
|
|
ar = "{ar}"
|
|
|
|
linker = "{linker}"
|
2017-07-22 03:12:21 +00:00
|
|
|
"#, target = target, ar = config.0, linker = config.1))
|
|
|
|
.build();
|
2015-07-24 06:35:53 +00:00
|
|
|
|
|
|
|
let foo_path = origin.root().join("foo");
|
|
|
|
let foo_url = path2url(foo_path.clone());
|
|
|
|
let prefix = origin.root().into_os_string().into_string().unwrap();
|
|
|
|
let output = if cfg!(windows) {
|
|
|
|
(format!(r#"{}\.\nonexistent-ar"#, prefix),
|
|
|
|
format!(r#"{}\.\tools\nonexistent-linker"#, prefix))
|
|
|
|
} else {
|
|
|
|
(format!(r#"{}/./nonexistent-ar"#, prefix),
|
|
|
|
format!(r#"{}/./tools/nonexistent-linker"#, prefix))
|
|
|
|
};
|
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
assert_that(origin.cargo("build").cwd(foo_path).arg("--verbose"),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_stderr(&format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
|
|
|
[RUNNING] `rustc [..] -C ar={ar} -C linker={linker} [..]`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
", url = foo_url, ar = output.0, linker = output.1)))
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2017-04-26 00:16:17 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn custom_runner() {
|
|
|
|
let target = rustc_host();
|
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
let p = project("foo")
|
2017-04-26 00:16:17 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("tests/test.rs", "")
|
|
|
|
.file("benches/bench.rs", "")
|
|
|
|
.file(".cargo/config", &format!(r#"
|
|
|
|
[target.{}]
|
2017-05-12 22:07:42 +00:00
|
|
|
runner = "nonexistent-runner -r"
|
2017-07-22 03:12:21 +00:00
|
|
|
"#, target))
|
|
|
|
.build();
|
2017-04-26 00:16:17 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
assert_that(p.cargo("run").args(&["--", "--param"]),
|
2017-04-26 00:16:17 +00:00
|
|
|
execs().with_stderr_contains(&format!("\
|
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2017-05-12 22:07:42 +00:00
|
|
|
[RUNNING] `nonexistent-runner -r target[/]debug[/]foo[EXE] --param`
|
2017-07-22 03:12:21 +00:00
|
|
|
", url = p.url())));
|
2017-04-26 00:16:17 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
assert_that(p.cargo("test").args(&["--test", "test", "--verbose", "--", "--param"]),
|
2017-04-26 00:16:17 +00:00
|
|
|
execs().with_stderr_contains(&format!("\
|
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
|
|
|
[RUNNING] `rustc [..]`
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2017-05-12 22:07:42 +00:00
|
|
|
[RUNNING] `nonexistent-runner -r [..][/]target[/]debug[/]deps[/]test-[..][EXE] --param`
|
2017-07-22 03:12:21 +00:00
|
|
|
", url = p.url())));
|
2017-04-26 00:16:17 +00:00
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
assert_that(p.cargo("bench").args(&["--bench", "bench", "--verbose", "--", "--param"]),
|
2017-04-26 00:16:17 +00:00
|
|
|
execs().with_stderr_contains(&format!("\
|
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
|
|
|
[RUNNING] `rustc [..]`
|
|
|
|
[RUNNING] `rustc [..]`
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2017-05-12 22:07:42 +00:00
|
|
|
[RUNNING] `nonexistent-runner -r [..][/]target[/]release[/]deps[/]bench-[..][EXE] --param --bench`
|
2017-07-22 03:12:21 +00:00
|
|
|
", url = p.url())));
|
2017-04-26 00:16:17 +00:00
|
|
|
}
|