From f04e09522fa78926d2cb118f388c8f4f4dd5d7fa Mon Sep 17 00:00:00 2001 From: Xavier Denis Date: Tue, 28 May 2024 15:19:00 +0200 Subject: [PATCH] Add tests --- tests/integrations/basic-fail/Cargo.stderr | 11 +- tests/integrations/basic-fail/Cargo.stdout | 352 ++++++++++++++++++ tests/integrations/basic-fail/Cargo.toml | 4 + .../basic-fail/tests/ui_tests_diff_only.rs | 18 + 4 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 tests/integrations/basic-fail/tests/ui_tests_diff_only.rs diff --git a/tests/integrations/basic-fail/Cargo.stderr b/tests/integrations/basic-fail/Cargo.stderr index 08aeb63f..f6d500c5 100644 --- a/tests/integrations/basic-fail/Cargo.stderr +++ b/tests/integrations/basic-fail/Cargo.stderr @@ -13,6 +13,14 @@ Location: $DIR/src/lib.rs:LL:CC) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace error: test failed, to rerun pass `--test ui_tests_bless` +Error: tests failed + +Location: + $DIR/src/lib.rs:LL:CC +error: test failed, to rerun pass `--test ui_tests_diff_only` + +Caused by: + process didn't exit successfully: `$DIR/target/ui/tests/integrations/basic-fail/debug/deps/ui_tests_diff_only-HASH` (exit status: 1) Error: failed to parse rustc version info: invalid_foobarlaksdfalsdfj Caused by: @@ -31,8 +39,9 @@ error: test failed, to rerun pass `--test ui_tests_invalid_program2` Caused by: process didn't exit successfully: `$DIR/target/ui/tests/integrations/basic-fail/debug/deps/ui_tests_invalid_program2-HASH` (exit status: 1) -error: 4 targets failed: +error: 5 targets failed: `--test ui_tests` `--test ui_tests_bless` + `--test ui_tests_diff_only` `--test ui_tests_invalid_program` `--test ui_tests_invalid_program2` diff --git a/tests/integrations/basic-fail/Cargo.stdout b/tests/integrations/basic-fail/Cargo.stdout index 7ece0769..5818b33a 100644 --- a/tests/integrations/basic-fail/Cargo.stdout +++ b/tests/integrations/basic-fail/Cargo.stdout @@ -1098,6 +1098,358 @@ tests/actual_tests/rustc_ice.rs ... FAILED tests/actual_tests/touching_above_below.rs ... FAILED tests/actual_tests/touching_above_below_chain.rs ... FAILED +FAILED TEST: tests/actual_tests/bad_pattern.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/bad_pattern.rs" "--edition" "2021" + +error: actual output differed from expected +Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/bad_pattern.stderr` to the actual output +--- tests/actual_tests/bad_pattern.stderr ++++ +-error[E0308]: mismatched types ++error[E0432]: unresolved import `basic_fail` +- --> tests/actual_tests/bad_pattern.rs:4:9 ++ --> tests/actual_tests/bad_pattern.rs:1:5 + | +-4 | add("42", 3); ++1 | use basic_fail::add; +- | --- ^^^^ expected `usize`, found `&str` ++ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail` + +-error: aborting due to previous error ++error: aborting due to 1 previous error + +-For more information about this error, try `rustc --explain E0308`. ++For more information about this error, try `rustc --explain E0432`. + + +error: `miesmätsched types` not found in diagnostics on line 4 + --> tests/actual_tests/bad_pattern.rs:5:17 + | +5 | //~^ ERROR: miesmätsched types + | ^^^^^^^^^^^^^^^^^^ expected because of this pattern + | + +error: there were 1 unmatched diagnostics + --> tests/actual_tests/bad_pattern.rs:1:5 + | +1 | use basic_fail::add; + | ^^^^^^^^^^ Error[E0432]: unresolved import `basic_fail` + | + + +FAILED TEST: tests/actual_tests/executable.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/executable.rs" "--edition" "2021" + +error: pass test got exit status: 1, but expected 0 + = note: compilation failed, but was expected to succeed + +error: actual output differed from expected +Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/executable.stderr` to the actual output +--- tests/actual_tests/executable.stderr ++++ ++error[E0432]: unresolved import `basic_fail` ++ --> tests/actual_tests/executable.rs:1:5 ++ | ++1 | use basic_fail::add; ++ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail` ++ ++error: aborting due to 1 previous error ++ ++For more information about this error, try `rustc --explain E0432`. + + +error: there were 1 unmatched diagnostics + --> tests/actual_tests/executable.rs:1:5 + | +1 | use basic_fail::add; + | ^^^^^^^^^^ Error[E0432]: unresolved import `basic_fail` + | + + +FAILED TEST: tests/actual_tests/executable_compile_err.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/executable_compile_err.rs" "--edition" "2021" + +error: pass test got exit status: 1, but expected 0 + = note: compilation failed, but was expected to succeed + +error: actual output differed from expected +Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/executable_compile_err.stderr` to the actual output +--- tests/actual_tests/executable_compile_err.stderr ++++ ++error: this file contains an unclosed delimiter ++ --> tests/actual_tests/executable_compile_err.rs:4:2 ++ | ++3 | fn main() { ++ | - unclosed delimiter ++4 | ++ | ^ ++ ++error: aborting due to 1 previous error ++ + + +error: there were 1 unmatched diagnostics + --> tests/actual_tests/executable_compile_err.rs:4:1 + | +4 | ... + | ^ Error: this file contains an unclosed delimiter + | + + +FAILED TEST: tests/actual_tests/exit_code_fail.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/exit_code_fail.rs" "--edition" "2021" + +error: fail test got exit status: 0, but expected 1 + = note: compilation succeeded, but was expected to fail + +error: no error patterns found in fail test + + +FAILED TEST: tests/actual_tests/filters.rs +command: "parse comments" + +error: `x86_64` is not a valid condition, expected `on-host`, /[0-9]+bit/, /host-.*/, or /target-.*/ + --> tests/actual_tests/filters.rs:1:9 + | +1 | //@only-x86_64 + | ^^^^^^ + | + + +FAILED TEST: tests/actual_tests/foomp.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/foomp.rs" "--edition" "2021" + +error: actual output differed from expected +Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/foomp.stderr` to the actual output +--- tests/actual_tests/foomp.stderr ++++ +-error[E0308]: mismatched types ++error[E0432]: unresolved import `basic_fail` +- --> tests/actual_tests/foomp.rs:4:9 ++ --> tests/actual_tests/foomp.rs:1:5 + | +-4 | add("42", 3); ++1 | use basic_fail::add; +- | --- ^^^^ expected `usize`, found `&str` ++ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail` + +-error: aborting doo to previous error ++error: aborting due to 1 previous error + +-For more information about this error, try `rustc --explain E0308`. ++For more information about this error, try `rustc --explain E0432`. + + +error: `mismatched types` not found in diagnostics on line 4 + --> tests/actual_tests/foomp.rs:5:17 + | +5 | //~^ ERROR: mismatched types + | ^^^^^^^^^^^^^^^^ expected because of this pattern + | + +error: there were 1 unmatched diagnostics + --> tests/actual_tests/foomp.rs:1:5 + | +1 | use basic_fail::add; + | ^^^^^^^^^^ Error[E0432]: unresolved import `basic_fail` + | + + +FAILED TEST: tests/actual_tests/foomp2.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/foomp2.rs" "--edition" "2021" + +error: actual output differed from expected +Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/foomp2.stderr` to the actual output +--- tests/actual_tests/foomp2.stderr ++++ +-error[E0308]: mismatched types ++error[E0432]: unresolved import `basic_fail` +- --> tests/actual_tests/foomp2.rs:4:9 ++ --> tests/actual_tests/foomp2.rs:1:5 + | +-4 | add("42", 3); ++1 | use basic_fail::add; +- | --- ^^^^ expected `usize`, found `&str` ++ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail` + +-error: aborting due to previous error ++error: aborting due to 1 previous error + +-For more information about this error, try `rustc --explain E0308`. ++For more information about this error, try `rustc --explain E0432`. + + +error: `mismatched types` not found in diagnostics on line 4 + --> tests/actual_tests/foomp2.rs:5:17 + | +5 | //~^ ERROR: mismatched types + | ^^^^^^^^^^^^^^^^ expected because of this pattern + | + +error: there were 1 unmatched diagnostics + --> tests/actual_tests/foomp2.rs:1:5 + | +1 | use basic_fail::add; + | ^^^^^^^^^^ Error[E0432]: unresolved import `basic_fail` + | + + +FAILED TEST: tests/actual_tests/inline_chain.rs +command: "parse comments" + +error: `//~|` comment not attached to anchoring matcher + --> tests/actual_tests/inline_chain.rs:5:26 + | +5 | //~| unused_variables + | ^ + | + + +FAILED TEST: tests/actual_tests/joined_wrong_order.rs +command: "parse comments" + +error: `//~|` comment not attached to anchoring matcher + --> tests/actual_tests/joined_wrong_order.rs:5:8 + | +5 | //~| unused_mut + | ^ + | + + +FAILED TEST: tests/actual_tests/lone_joined_pattern.rs +command: "parse comments" + +error: `//~|` comment not attached to anchoring matcher + --> tests/actual_tests/lone_joined_pattern.rs:2:8 + | +2 | //~| ERROR: mismatched types + | ^ + | + +error: `//~|` comment not attached to anchoring matcher + --> tests/actual_tests/lone_joined_pattern.rs:4:8 + | +4 | //~| ERROR: mismatched types + | ^ + | + + +FAILED TEST: tests/actual_tests/pattern_too_many_arrow.rs +command: "parse comments" + +error: //~^ pattern is trying to refer to 7 lines above, but there are only 2 lines above + --> tests/actual_tests/pattern_too_many_arrow.rs:3:8 + | +3 | //~^^^^^^^ ERROR: mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + + +FAILED TEST: tests/actual_tests/pattern_too_many_arrow_above.rs +command: "parse comments" + +error: //~v pattern is trying to refer to line 8, but the file only has 6 lines + --> tests/actual_tests/pattern_too_many_arrow_above.rs:2:22 + | +2 | //~vvvvvv ERROR: mismatched types + | ^^^^^^^^^^^^^^^^ + | + + +FAILED TEST: tests/actual_tests/rustc_ice.rs +command: "rustc" "--error-format=json" "--out-dir" "$TMP "tests/actual_tests/rustc_ice.rs" "-Ztreat-err-as-bug" "--edition" "2021" + +error: fail test got exit status: 101, but expected 1 + = note: the compiler panicked + +error: actual output differed from expected +Execute `DO NOT BLESS. These are meant to fail` to update `tests/actual_tests/rustc_ice.stderr` to the actual output +--- tests/actual_tests/rustc_ice.stderr ++++ +-error: internal compiler error[E0308]: mismatched types ++error: internal compiler error[E0432]: unresolved import `basic_fail` +- --> tests/actual_tests/rustc_ice.rs:8:9 ++ --> tests/actual_tests/rustc_ice.rs:5:5 + | +-8 | add("42", 3); ++5 | use basic_fail::add; +- | --- ^^^^ expected `usize`, found `&str` ++ | ^^^^^^^^^^ use of undeclared crate or module `basic_fail` + + thread 'rustc' panicked + + +error: `mismatched types` not found in diagnostics on line 8 + --> tests/actual_tests/rustc_ice.rs:9:17 + | +9 | //~^ ERROR: mismatched types + | ^^^^^^^^^^^^^^^^ expected because of this pattern + | + +error: there were 1 unmatched diagnostics + --> tests/actual_tests/rustc_ice.rs:5:5 + | +5 | use basic_fail::add; + | ^^^^^^^^^^ Ice: unresolved import `basic_fail` + | + + +FAILED TEST: tests/actual_tests/touching_above_below.rs +command: "parse comments" + +error: `//~v` comment immediately following a `//~^` comment chain + --> tests/actual_tests/touching_above_below.rs:4:8 + | +4 | //~v ERROR: mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + + +FAILED TEST: tests/actual_tests/touching_above_below_chain.rs +command: "parse comments" + +error: `//~v` comment immediately following a `//~^` comment chain + --> tests/actual_tests/touching_above_below_chain.rs:5:8 + | +5 | //~v ERROR: unused variable + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + +FAILURES: + tests/actual_tests/bad_pattern.rs + tests/actual_tests/executable.rs + tests/actual_tests/executable_compile_err.rs + tests/actual_tests/exit_code_fail.rs + tests/actual_tests/filters.rs + tests/actual_tests/foomp.rs + tests/actual_tests/foomp2.rs + tests/actual_tests/inline_chain.rs + tests/actual_tests/joined_wrong_order.rs + tests/actual_tests/lone_joined_pattern.rs + tests/actual_tests/pattern_too_many_arrow.rs + tests/actual_tests/pattern_too_many_arrow_above.rs + tests/actual_tests/rustc_ice.rs + tests/actual_tests/touching_above_below.rs + tests/actual_tests/touching_above_below_chain.rs + +test result: FAIL. 15 failed; + +tests/actual_tests/bad_pattern.rs ... FAILED +tests/actual_tests/executable.rs ... FAILED +tests/actual_tests/executable_compile_err.rs ... FAILED +tests/actual_tests/exit_code_fail.rs ... FAILED +tests/actual_tests/filters.rs ... FAILED +tests/actual_tests/foomp.rs ... FAILED +tests/actual_tests/foomp2.rs ... FAILED +tests/actual_tests/inline_chain.rs ... FAILED +tests/actual_tests/joined_wrong_order.rs ... FAILED +tests/actual_tests/lone_joined_pattern.rs ... FAILED +tests/actual_tests/pattern_too_many_arrow.rs ... FAILED +tests/actual_tests/pattern_too_many_arrow_above.rs ... FAILED +tests/actual_tests/rustc_ice.rs ... FAILED +tests/actual_tests/touching_above_below.rs ... FAILED +tests/actual_tests/touching_above_below_chain.rs ... FAILED + FAILED TEST: tests/actual_tests/bad_pattern.rs command: "$CMD" "tests/actual_tests/bad_pattern.rs" "--edition" "2021" diff --git a/tests/integrations/basic-fail/Cargo.toml b/tests/integrations/basic-fail/Cargo.toml index fe56b07b..b9ca9521 100644 --- a/tests/integrations/basic-fail/Cargo.toml +++ b/tests/integrations/basic-fail/Cargo.toml @@ -21,6 +21,10 @@ harness = false name = "ui_tests_invalid_program2" harness = false +[[test]] +name = "ui_tests_diff_only" +harness = false + [[test]] name = "ui_tests_bless" harness = false diff --git a/tests/integrations/basic-fail/tests/ui_tests_diff_only.rs b/tests/integrations/basic-fail/tests/ui_tests_diff_only.rs new file mode 100644 index 00000000..041cbfb7 --- /dev/null +++ b/tests/integrations/basic-fail/tests/ui_tests_diff_only.rs @@ -0,0 +1,18 @@ +use ui_test::*; + +fn main() -> ui_test::color_eyre::Result<()> { + let config = Config { + // Never bless integrations-fail tests, we want to see stderr mismatches + output_conflict_handling: OutputConflictHandling::Error, + bless_command: Some("DO NOT BLESS. These are meant to fail".to_string()), + ..Config::rustc("tests/actual_tests") + }; + + run_tests_generic( + vec![config], + default_file_filter, + default_per_file_config, + // Avoid github actions, as these would end up showing up in `Cargo.stderr` + status_emitter::Text::diff(), + ) +}