Skip to content

Commit

Permalink
test: use canonical bin path to surpress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Jun 14, 2024
1 parent adf40d0 commit c636276
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ fn cargo_fail_with_no_stderr() {
fn cargo_compile_incremental() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.file("src/main.rs", &main_file(r#""i am foo""#, &[]))
.build();

p.cargo("build -v")
.env("CARGO_INCREMENTAL", "1")
.with_stderr_data(str![[r#"
[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`,
please set bin.path in Cargo.toml
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[RUNNING] `rustc [..] -C incremental=[ROOT]/foo/target/debug/incremental[..]`
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
Expand All @@ -121,8 +119,6 @@ please set bin.path in Cargo.toml
p.cargo("test -v")
.env("CARGO_INCREMENTAL", "1")
.with_stderr_data(str![[r#"
[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`,
please set bin.path in Cargo.toml
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[RUNNING] `rustc [..] -C incremental=[ROOT]/foo/target/debug/incremental[..]`
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
Expand Down Expand Up @@ -819,14 +815,12 @@ fn cargo_compile_with_lowercase_cargo_toml() {
fn cargo_compile_with_invalid_code() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", "invalid rust code!")
.file("src/main.rs", "invalid rust code!")
.build();

p.cargo("build")
.with_status(101)
.with_stderr_data(str![[r#"
[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`,
please set bin.path in Cargo.toml
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[ERROR] [..]
...
Expand Down Expand Up @@ -879,13 +873,11 @@ fn cargo_compile_with_invalid_code_in_deps() {
fn cargo_compile_with_warnings_in_the_root_package() {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", "fn main() {} fn dead() {}")
.file("src/main.rs", "fn main() {} fn dead() {}")
.build();

p.cargo("build")
.with_stderr_data(str![[r#"
[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`,
please set bin.path in Cargo.toml
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[WARNING] [..]dead[..]
...
Expand Down Expand Up @@ -917,7 +909,7 @@ fn cargo_compile_with_warnings_in_a_dep_package() {
name = "foo"
"#,
)
.file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"]))
.file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"]))
.file("bar/Cargo.toml", &basic_lib_manifest("bar"))
.file(
"bar/src/bar.rs",
Expand All @@ -933,8 +925,6 @@ fn cargo_compile_with_warnings_in_a_dep_package() {

p.cargo("build")
.with_stderr_data(str![[r#"
[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`,
please set bin.path in Cargo.toml
[LOCKING] 2 packages to latest compatible versions
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
[WARNING] [..]dead[..]
Expand Down Expand Up @@ -2330,7 +2320,7 @@ fn ignore_broken_symlinks() {

let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.file("src/main.rs", &main_file(r#""i am foo""#, &[]))
.symlink("Notafile", "bar")
// To hit the symlink directory, we need a build script
// to trigger a full scan of package files.
Expand All @@ -2340,8 +2330,6 @@ fn ignore_broken_symlinks() {

p.cargo("build")
.with_stderr_data(str![[r#"
[WARNING] path `src/foo.rs` was erroneously implicitly accepted for binary `foo`,
please set bin.path in Cargo.toml
[WARNING] File system loop found: [ROOT]/foo/a/b/c/d/foo points to an ancestor [ROOT]/foo/a/b
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
Expand Down

0 comments on commit c636276

Please sign in to comment.