mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00

This change ensures cargo will output file paths in the expected format (C:\foo\... on Windows, /foo/... elsewhere). Previously it would output file:// URLs instead. To support this change, additional changes were made to the test suite string processing such that [ROOT] is now replaced with the appropriate file path root for the platform. The CWD template was also updated to use [CWD] like other replacement templates and to do the replacement on the expected value rather than the actual value to avoid replacing things we don't expect with CWD.
61 lines
1.5 KiB
Rust
61 lines
1.5 KiB
Rust
use support::{basic_bin_manifest, basic_manifest, project};
|
|
|
|
#[test]
|
|
fn build_lib_only() {
|
|
let p = project()
|
|
.file("src/main.rs", "fn main() {}")
|
|
.file("src/lib.rs", r#" "#)
|
|
.build();
|
|
|
|
p.cargo("build --lib -v")
|
|
.with_stderr(
|
|
"\
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
|
[RUNNING] `rustc --crate-name foo src/lib.rs --crate-type lib \
|
|
--emit=dep-info,link -C debuginfo=2 \
|
|
-C metadata=[..] \
|
|
--out-dir [..] \
|
|
-L dependency=[CWD]/target/debug/deps`
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
|
|
).run();
|
|
}
|
|
|
|
#[test]
|
|
fn build_with_no_lib() {
|
|
let p = project()
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
.file("src/main.rs", "fn main() {}")
|
|
.build();
|
|
|
|
p.cargo("build --lib")
|
|
.with_status(101)
|
|
.with_stderr("[ERROR] no library targets found in package `foo`")
|
|
.run();
|
|
}
|
|
|
|
#[test]
|
|
fn build_with_relative_cargo_home_path() {
|
|
let p = project()
|
|
.file(
|
|
"Cargo.toml",
|
|
r#"
|
|
[package]
|
|
|
|
name = "foo"
|
|
version = "0.0.1"
|
|
authors = ["wycats@example.com"]
|
|
|
|
[dependencies]
|
|
|
|
"test-dependency" = { path = "src/test_dependency" }
|
|
"#,
|
|
).file("src/main.rs", "fn main() {}")
|
|
.file("src/test_dependency/src/lib.rs", r#" "#)
|
|
.file(
|
|
"src/test_dependency/Cargo.toml",
|
|
&basic_manifest("test-dependency", "0.0.1"),
|
|
).build();
|
|
|
|
p.cargo("build").env("CARGO_HOME", "./cargo_home/").run();
|
|
}
|