Skip to content

Commit d0342d3

Browse files
authored
test: relax bad_crate_type to only match error message prefix (#14990)
### What does this PR try to resolve? This PR relaxes the `bad_crate_type` test to have it only match the prefix of the unknown crate type error message emitted by rustc. This is so that the cargo test isn't sensitive to (future) suggestions for known crate types that rustc may emit to help the user. ### How should we test and review this PR? This test should already be run as part of cargo CI. (This is definitely run as part of rust-lang/rust CI, lol.) ### Additional information rust-lang/rust side PR that's trying to add a suffix to the bad crate type error message to list all valid `--crate-type` values: rust-lang/rust#134720. Without relaxing this test, the rust-lang/rust side PR [fails with](rust-lang/rust#134720 (comment)): <details> <summary>rust-lang/rust CI fail message</summary> (Ignore the missing colon after `unknown crate type`) ``` ---- bad_config::bad_crate_type stdout ---- running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/cargo build -v` thread 'bad_config::bad_crate_type' panicked at src/tools/cargo/tests/testsuite/bad_config.rs:434:10: ---- expected: tests/testsuite/bad_config.rs:424:27 ++++ actual: stderr 1 1 | [ERROR] failed to run `rustc` to learn about crate-type bad_type information 2 2 | 3 3 | Caused by: 4 4 | process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --crate-type bad_type` ([EXIT_STATUS]: 1) 5 5 | --- stderr 6 - [ERROR] unknown crate type: `bad_type` Error: 6 + [ERROR] unknown crate type `bad_type`, expected one of: `bin`, `cdylib`, `dylib`, `lib`, `proc-macro`, `rlib` 7 7 | ``` </details> Discussed at https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/Reblessing.20a.20cargo.20test.
2 parents 0276088 + 17aaafd commit d0342d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/testsuite/bad_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ fn bad_crate_type() {
427427
Caused by:
428428
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --crate-type bad_type` ([EXIT_STATUS]: 1)
429429
--- stderr
430-
[ERROR] unknown crate type: `bad_type`
430+
[ERROR] unknown crate type: `bad_type`[..]
431431
432432
433433
"#]])

0 commit comments

Comments
 (0)