mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
move config tests from build.rs to bad_config.rs
This commit is contained in:
parent
87a24aa734
commit
e2987afda7
@ -3,7 +3,7 @@
|
||||
use crate::prelude::*;
|
||||
use cargo_test_support::git::cargo_uses_gitoxide;
|
||||
use cargo_test_support::registry::{self, Package};
|
||||
use cargo_test_support::{basic_manifest, project, rustc_host, str, Project};
|
||||
use cargo_test_support::{basic_bin_manifest, basic_manifest, project, rustc_host, str, Project};
|
||||
|
||||
#[cargo_test]
|
||||
fn bad1() {
|
||||
@ -3130,3 +3130,421 @@ Caused by:
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_test() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[test]]
|
||||
name = "hello"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --tests -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `hello` test at `tests/hello.rs` or `tests/hello/main.rs`. Please specify test.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_example() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[example]]
|
||||
name = "hello"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --examples -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `hello` example at `examples/hello.rs` or `examples/hello/main.rs`. Please specify example.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_benchmark() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "hello"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --benches -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `hello` bench at `benches/hello.rs` or `benches/hello/main.rs`. Please specify bench.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_binary() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/ehlo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. Please specify bin.path if you want to use a non-default path.
|
||||
|
||||
[HELP] a bin with a similar name exists: `ehlo`
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_of_test() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[test]]
|
||||
name = "foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("test/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --tests -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` test at default paths, but found a file at `test/foo.rs`.
|
||||
Perhaps rename the file to `tests/foo.rs` for target auto-discovery, or specify test.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_of_example() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[example]]
|
||||
name = "foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("example/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --examples -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` example at default paths, but found a file at `example/foo.rs`.
|
||||
Perhaps rename the file to `examples/foo.rs` for target auto-discovery, or specify example.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_of_benchmark() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("bench/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --benches -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bench at default paths, but found a file at `bench/foo.rs`.
|
||||
Perhaps rename the file to `benches/foo.rs` for target auto-discovery, or specify bench.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_binary() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bins/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bin at default paths, but found a file at `src/bins/foo.rs`.
|
||||
Perhaps rename the file to `src/bin/foo.rs` for target auto-discovery, or specify bin.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_subdir_binary() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bins/foo/main.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bin at default paths, but found a file at `src/bins/foo/main.rs`.
|
||||
Perhaps rename the file to `src/bin/foo/main.rs` for target auto-discovery, or specify bin.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn found_multiple_target_files() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/foo.rs", "")
|
||||
.file("src/bin/foo/main.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
// Don't assert the inferred paths since the order is non-deterministic.
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
cannot infer path for `foo` bin
|
||||
Cargo doesn't know which to use because multiple target files found at `src/bin/foo[..]rs` and `src/bin/foo[..].rs`.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn legacy_binary_paths_warnings() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[[bin]]
|
||||
name = "bar"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently
|
||||
disables Cargo from automatically inferring other binary targets.
|
||||
This inference behavior will change in the Rust 2018 edition and the following
|
||||
files will be included as a binary target:
|
||||
|
||||
* src/main.rs
|
||||
|
||||
This is likely to break cargo build or cargo test as these files may not be
|
||||
ready to be compiled as a binary target today. You can future-proof yourself
|
||||
and disable this warning by adding `autobins = false` to your [package]
|
||||
section. You may also move the files to a location where Cargo would not
|
||||
automatically infer them to be a target, such as in subfolders.
|
||||
|
||||
For more information on this warning you can consult
|
||||
https://github.com/rust-lang/cargo/issues/5330
|
||||
[WARNING] path `src/main.rs` was erroneously implicitly accepted for binary `bar`,
|
||||
please set bin.path in Cargo.toml
|
||||
[COMPILING] foo v1.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[[bin]]
|
||||
name = "bar"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently
|
||||
disables Cargo from automatically inferring other binary targets.
|
||||
This inference behavior will change in the Rust 2018 edition and the following
|
||||
files will be included as a binary target:
|
||||
|
||||
* src/bin/main.rs
|
||||
|
||||
This is likely to break cargo build or cargo test as these files may not be
|
||||
ready to be compiled as a binary target today. You can future-proof yourself
|
||||
and disable this warning by adding `autobins = false` to your [package]
|
||||
section. You may also move the files to a location where Cargo would not
|
||||
automatically infer them to be a target, such as in subfolders.
|
||||
|
||||
For more information on this warning you can consult
|
||||
https://github.com/rust-lang/cargo/issues/5330
|
||||
[WARNING] path `src/bin/main.rs` was erroneously implicitly accepted for binary `bar`,
|
||||
please set bin.path in Cargo.toml
|
||||
[COMPILING] foo v1.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[[bin]]
|
||||
name = "bar"
|
||||
"#,
|
||||
)
|
||||
.file("src/bar.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] path `src/bar.rs` was erroneously implicitly accepted for binary `bar`,
|
||||
please set bin.path in Cargo.toml
|
||||
[COMPILING] foo v1.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
@ -2251,424 +2251,6 @@ Goodbye, World!
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_test() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[test]]
|
||||
name = "hello"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --tests -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `hello` test at `tests/hello.rs` or `tests/hello/main.rs`. Please specify test.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_example() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[example]]
|
||||
name = "hello"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --examples -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `hello` example at `examples/hello.rs` or `examples/hello/main.rs`. Please specify example.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_benchmark() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "hello"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --benches -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `hello` bench at `benches/hello.rs` or `benches/hello/main.rs`. Please specify bench.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn non_existing_binary() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/ehlo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. Please specify bin.path if you want to use a non-default path.
|
||||
|
||||
[HELP] a bin with a similar name exists: `ehlo`
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_of_test() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[test]]
|
||||
name = "foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("test/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --tests -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` test at default paths, but found a file at `test/foo.rs`.
|
||||
Perhaps rename the file to `tests/foo.rs` for target auto-discovery, or specify test.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_of_example() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[example]]
|
||||
name = "foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("example/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --examples -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` example at default paths, but found a file at `example/foo.rs`.
|
||||
Perhaps rename the file to `examples/foo.rs` for target auto-discovery, or specify example.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_of_benchmark() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("bench/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build --benches -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bench at default paths, but found a file at `bench/foo.rs`.
|
||||
Perhaps rename the file to `benches/foo.rs` for target auto-discovery, or specify bench.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_binary() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bins/foo.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bin at default paths, but found a file at `src/bins/foo.rs`.
|
||||
Perhaps rename the file to `src/bin/foo.rs` for target auto-discovery, or specify bin.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn commonly_wrong_path_subdir_binary() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bins/foo/main.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `foo` bin at default paths, but found a file at `src/bins/foo/main.rs`.
|
||||
Perhaps rename the file to `src/bin/foo/main.rs` for target auto-discovery, or specify bin.path if you want to use a non-default path.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn found_multiple_target_files() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/foo.rs", "")
|
||||
.file("src/bin/foo/main.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
// Don't assert the inferred paths since the order is non-deterministic.
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
cannot infer path for `foo` bin
|
||||
Cargo doesn't know which to use because multiple target files found at `src/bin/foo[..]rs` and `src/bin/foo[..].rs`.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn legacy_binary_paths_warnings() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[[bin]]
|
||||
name = "bar"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently
|
||||
disables Cargo from automatically inferring other binary targets.
|
||||
This inference behavior will change in the Rust 2018 edition and the following
|
||||
files will be included as a binary target:
|
||||
|
||||
* src/main.rs
|
||||
|
||||
This is likely to break cargo build or cargo test as these files may not be
|
||||
ready to be compiled as a binary target today. You can future-proof yourself
|
||||
and disable this warning by adding `autobins = false` to your [package]
|
||||
section. You may also move the files to a location where Cargo would not
|
||||
automatically infer them to be a target, such as in subfolders.
|
||||
|
||||
For more information on this warning you can consult
|
||||
https://github.com/rust-lang/cargo/issues/5330
|
||||
[WARNING] path `src/main.rs` was erroneously implicitly accepted for binary `bar`,
|
||||
please set bin.path in Cargo.toml
|
||||
[COMPILING] foo v1.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[[bin]]
|
||||
name = "bar"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently
|
||||
disables Cargo from automatically inferring other binary targets.
|
||||
This inference behavior will change in the Rust 2018 edition and the following
|
||||
files will be included as a binary target:
|
||||
|
||||
* src/bin/main.rs
|
||||
|
||||
This is likely to break cargo build or cargo test as these files may not be
|
||||
ready to be compiled as a binary target today. You can future-proof yourself
|
||||
and disable this warning by adding `autobins = false` to your [package]
|
||||
section. You may also move the files to a location where Cargo would not
|
||||
automatically infer them to be a target, such as in subfolders.
|
||||
|
||||
For more information on this warning you can consult
|
||||
https://github.com/rust-lang/cargo/issues/5330
|
||||
[WARNING] path `src/bin/main.rs` was erroneously implicitly accepted for binary `bar`,
|
||||
please set bin.path in Cargo.toml
|
||||
[COMPILING] foo v1.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "1.0.0"
|
||||
edition = "2015"
|
||||
authors = []
|
||||
|
||||
[[bin]]
|
||||
name = "bar"
|
||||
"#,
|
||||
)
|
||||
.file("src/bar.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] path `src/bar.rs` was erroneously implicitly accepted for binary `bar`,
|
||||
please set bin.path in Cargo.toml
|
||||
[COMPILING] foo v1.0.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn implicit_examples() {
|
||||
let p = project()
|
||||
|
Loading…
x
Reference in New Issue
Block a user