Manishearth / compiletest-rs

An extraction of the compiletest utility from the Rust compiler
Apache License 2.0
218 stars 59 forks source link

cd test-project && cargo +nightly hack test --feature-powerset fails with duplicate rlibs #274

Closed tamird closed 1 year ago

tamird commented 1 year ago

Running the tests twice (with different features) results in pollution:

/src/compiletest-rs/test-project$ find target/ -name 'libtestp*.rlib' -type f | xargs ls -lah
-rw-rw-r-- 1 tamird tamird 3.3K Jun  2 12:02 target/debug/deps/libtestp-4450211ae8c20f2d.rlib
-rw-rw-r-- 1 tamird tamird 3.3K Jun  2 12:13 target/debug/deps/libtestp-c6f9abab7ee2589d.rlib

which leads to failure:

running 5 tests
test [run-pass] run-pass/with-own-crate.rs ... FAILED
test [run-pass] run-pass/associated-types-binding-in-where-clause.rs ... ok
test [run-pass] run-pass/issue-10025.rs ... ok
test [run-pass] run-pass/while-with-break.rs ... ok
test [run-pass] run-pass/vec-slice-drop.rs ... ok

failures:

failures:
    [run-pass] run-pass/with-own-crate.rs

test result: FAILED. 4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s

test compile_test ... FAILED

failures:

---- compile_test stdout ----

error: compilation failed!
status: exit status: 1
command: "rustc" "tests/run-pass/with-own-crate.rs" "-L" "/tmp/compiletestLDU13B" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletestLDU13B/with-own-crate.stage-id" "-L" "/home/tamird/src/compiletest-rs/test-project/target/debug/deps" "-L" "/home/tamird/src/compiletest-rs/test-project/target/debug" "-L" "/home/tamird/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/tamird/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib" "-L" "/tmp/compiletestLDU13B/with-own-crate.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
{"message":"multiple candidates for `rlib` dependency `testp` found","code":{"code":"E0464","explanation":"The compiler found multiple library files with the requested crate name.\n\n```compile_fail\n// aux-build:crateresolve-1.rs\n// aux-build:crateresolve-2.rs\n// aux-build:crateresolve-3.rs\n\nextern crate crateresolve;\n//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found\n\nfn main() {}\n```\n\nThis error can occur in several different cases -- for example, when using\n`extern crate` or passing `--extern` options without crate paths. It can also be\ncaused by caching issues with the build directory, in which case `cargo clean`\nmay help.\n\nIn the above example, there are three different library files, all of which\ndefine the same crate name. Without providing a full path, there is no way for\nthe compiler to know which crate it should use.\n"},"level":"error","spans":[{"file_name":"tests/run-pass/with-own-crate.rs","byte_start":0,"byte_end":19,"line_start":1,"line_end":1,"column_start":1,"column_end":20,"is_primary":true,"text":[{"text":"extern crate testp;","highlight_start":1,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"candidate #1: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-4450211ae8c20f2d.rlib","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"candidate #2: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-c6f9abab7ee2589d.rlib","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0464]: multiple candidates for `rlib` dependency `testp` found\n --> tests/run-pass/with-own-crate.rs:1:1\n  |\n1 | extern crate testp;\n  | ^^^^^^^^^^^^^^^^^^^\n  |\n  = note: candidate #1: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-4450211ae8c20f2d.rlib\n  = note: candidate #2: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-c6f9abab7ee2589d.rlib\n\n"}
{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
{"message":"For more information about this error, try `rustc --explain E0464`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0464`.\n"}

------------------------------------------

thread 'compile_test' panicked at 'Some tests failed', /home/tamird/src/compiletest-rs/src/lib.rs:113:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    compile_test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.18s

Prettified JSON:

{
  "message": "multiple candidates for `rlib` dependency `testp` found",
  "code": {
    "code": "E0464",
    "explanation": "The compiler found multiple library files with the requested crate name.\n\n```compile_fail\n// aux-build:crateresolve-1.rs\n// aux-build:crateresolve-2.rs\n// aux-build:crateresolve-3.rs\n\nextern crate crateresolve;\n//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found\n\nfn main() {}\n```\n\nThis error can occur in several different cases -- for example, when using\n`extern crate` or passing `--extern` options without crate paths. It can also be\ncaused by caching issues with the build directory, in which case `cargo clean`\nmay help.\n\nIn the above example, there are three different library files, all of which\ndefine the same crate name. Without providing a full path, there is no way for\nthe compiler to know which crate it should use.\n"
  },
  "level": "error",
  "spans": [
    {
      "file_name": "tests/run-pass/with-own-crate.rs",
      "byte_start": 0,
      "byte_end": 19,
      "line_start": 1,
      "line_end": 1,
      "column_start": 1,
      "column_end": 20,
      "is_primary": true,
      "text": [
        {
          "text": "extern crate testp;",
          "highlight_start": 1,
          "highlight_end": 20
        }
      ],
      "label": null,
      "suggested_replacement": null,
      "suggestion_applicability": null,
      "expansion": null
    }
  ],
  "children": [
    {
      "message": "candidate #1: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-4450211ae8c20f2d.rlib",
      "code": null,
      "level": "note",
      "spans": [],
      "children": [],
      "rendered": null
    },
    {
      "message": "candidate #2: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-c6f9abab7ee2589d.rlib",
      "code": null,
      "level": "note",
      "spans": [],
      "children": [],
      "rendered": null
    }
  ],
  "rendered": "error[E0464]: multiple candidates for `rlib` dependency `testp` found\n --> tests/run-pass/with-own-crate.rs:1:1\n  |\n1 | extern crate testp;\n  | ^^^^^^^^^^^^^^^^^^^\n  |\n  = note: candidate #1: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-4450211ae8c20f2d.rlib\n  = note: candidate #2: /home/tamird/src/compiletest-rs/test-project/target/debug/deps/libtestp-c6f9abab7ee2589d.rlib\n\n"
}
{
  "message": "aborting due to previous error",
  "code": null,
  "level": "error",
  "spans": [],
  "children": [],
  "rendered": "error: aborting due to previous error\n\n"
}
{
  "message": "For more information about this error, try `rustc --explain E0464`.",
  "code": null,
  "level": "failure-note",
  "spans": [],
  "children": [],
  "rendered": "For more information about this error, try `rustc --explain E0464`.\n"
}

Perhaps we should have a Config::clean_rlib(), akin to Config::clean_rmeta() for dealing with this problem?