Rollup merge of #152509 - DanielEScherzer:test-references-tests, r=ehuss
tests/ui/test-attrs: add annotations for reference rules
This commit is contained in:
commit
9ac3dcd7c9
15 changed files with 38 additions and 30 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
//@ compile-flags: --test
|
//@ compile-flags: --test
|
||||||
|
//@ reference: attributes.testing.test.allowed-positions
|
||||||
|
|
||||||
fn align_offset_weird_strides() {
|
fn align_offset_weird_strides() {
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/issue-109816.rs:4:5
|
--> $DIR/issue-109816.rs:5:5
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
//@ compile-flags:--test
|
//@ compile-flags:--test
|
||||||
|
//@ reference: attributes.testing.test.allowed-positions
|
||||||
|
|
||||||
struct A {}
|
struct A {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-attr-non-associated-functions.rs:6:5
|
--> $DIR/test-attr-non-associated-functions.rs:7:5
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -11,7 +11,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-attr-non-associated-functions.rs:11:5
|
--> $DIR/test-attr-non-associated-functions.rs:12:5
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
//@ compile-flags: --test
|
//@ compile-flags: --test
|
||||||
|
//@ reference: attributes.testing.test.allowed-positions
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn foo() -> Result<(), ()> {
|
fn foo() -> Result<(), ()> {
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
error: functions used as tests can not have any arguments
|
error: functions used as tests can not have any arguments
|
||||||
--> $DIR/test-function-signature.rs:14:1
|
--> $DIR/test-function-signature.rs:15:1
|
||||||
|
|
|
|
||||||
LL | fn baz(val: i32) {}
|
LL | fn baz(val: i32) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: functions used as tests can not have any non-lifetime generic parameters
|
error: functions used as tests can not have any non-lifetime generic parameters
|
||||||
--> $DIR/test-function-signature.rs:22:1
|
--> $DIR/test-function-signature.rs:23:1
|
||||||
|
|
|
|
||||||
LL | fn type_generic<T>() {}
|
LL | fn type_generic<T>() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: functions used as tests can not have any non-lifetime generic parameters
|
error: functions used as tests can not have any non-lifetime generic parameters
|
||||||
--> $DIR/test-function-signature.rs:25:1
|
--> $DIR/test-function-signature.rs:26:1
|
||||||
|
|
|
|
||||||
LL | fn const_generic<const N: usize>() {}
|
LL | fn const_generic<const N: usize>() {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: functions used as tests can not have any arguments
|
error: functions used as tests can not have any arguments
|
||||||
--> $DIR/test-function-signature.rs:30:5
|
--> $DIR/test-function-signature.rs:31:5
|
||||||
|
|
|
|
||||||
LL | fn foo(arg: ()) {}
|
LL | fn foo(arg: ()) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0277]: the trait bound `i32: Termination` is not satisfied
|
error[E0277]: the trait bound `i32: Termination` is not satisfied
|
||||||
--> $DIR/test-function-signature.rs:9:13
|
--> $DIR/test-function-signature.rs:10:13
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ------- in this attribute macro expansion
|
| ------- in this attribute macro expansion
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
//@ compile-flags: --test
|
//@ compile-flags: --test
|
||||||
|
//@ reference: attributes.testing.test.allowed-positions
|
||||||
|
|
||||||
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
|
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
|
||||||
mod test {}
|
mod test {}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:3:1
|
--> $DIR/test-on-not-fn.rs:4:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -13,7 +13,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:6:1
|
--> $DIR/test-on-not-fn.rs:7:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -33,7 +33,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:20:1
|
--> $DIR/test-on-not-fn.rs:21:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -47,7 +47,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:23:1
|
--> $DIR/test-on-not-fn.rs:24:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -61,7 +61,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:26:1
|
--> $DIR/test-on-not-fn.rs:27:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -75,7 +75,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:29:1
|
--> $DIR/test-on-not-fn.rs:30:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -89,7 +89,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:32:1
|
--> $DIR/test-on-not-fn.rs:33:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -103,7 +103,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:35:1
|
--> $DIR/test-on-not-fn.rs:36:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -119,7 +119,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:40:1
|
--> $DIR/test-on-not-fn.rs:41:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -133,7 +133,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:43:1
|
--> $DIR/test-on-not-fn.rs:44:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -150,7 +150,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
error: the `#[test]` attribute may only be used on a free function
|
error: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:50:1
|
--> $DIR/test-on-not-fn.rs:51:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
@ -168,7 +168,7 @@ LL + #[cfg(test)]
|
||||||
|
|
|
|
||||||
|
|
||||||
warning: the `#[test]` attribute may only be used on a free function
|
warning: the `#[test]` attribute may only be used on a free function
|
||||||
--> $DIR/test-on-not-fn.rs:61:1
|
--> $DIR/test-on-not-fn.rs:62:1
|
||||||
|
|
|
|
||||||
LL | #[test]
|
LL | #[test]
|
||||||
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ check-run-results
|
//@ check-run-results
|
||||||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
||||||
|
//@ reference: attributes.testing.test.success
|
||||||
|
|
||||||
// Tests the output of the test harness with only passed tests.
|
// Tests the output of the test harness with only passed tests.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
//@ compile-flags: --test
|
//@ compile-flags: --test
|
||||||
|
//@ reference: attributes.testing.should_panic.syntax
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "foo"]
|
#[should_panic = "foo"]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0539]: malformed `should_panic` attribute input
|
error[E0539]: malformed `should_panic` attribute input
|
||||||
--> $DIR/test-should-panic-attr.rs:10:1
|
--> $DIR/test-should-panic-attr.rs:11:1
|
||||||
|
|
|
|
||||||
LL | #[should_panic(expected)]
|
LL | #[should_panic(expected)]
|
||||||
| ^^^^^^^^^^^^^^^--------^^
|
| ^^^^^^^^^^^^^^^--------^^
|
||||||
|
|
@ -19,7 +19,7 @@ LL + #[should_panic]
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0539]: malformed `should_panic` attribute input
|
error[E0539]: malformed `should_panic` attribute input
|
||||||
--> $DIR/test-should-panic-attr.rs:19:1
|
--> $DIR/test-should-panic-attr.rs:20:1
|
||||||
|
|
|
|
||||||
LL | #[should_panic(expect)]
|
LL | #[should_panic(expect)]
|
||||||
| ^^^^^^^^^^^^^^--------^
|
| ^^^^^^^^^^^^^^--------^
|
||||||
|
|
@ -39,7 +39,7 @@ LL + #[should_panic]
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0539]: malformed `should_panic` attribute input
|
error[E0539]: malformed `should_panic` attribute input
|
||||||
--> $DIR/test-should-panic-attr.rs:28:1
|
--> $DIR/test-should-panic-attr.rs:29:1
|
||||||
|
|
|
|
||||||
LL | #[should_panic(expected(foo, bar))]
|
LL | #[should_panic(expected(foo, bar))]
|
||||||
| ^^^^^^^^^^^^^^^------------------^^
|
| ^^^^^^^^^^^^^^^------------------^^
|
||||||
|
|
@ -60,7 +60,7 @@ LL + #[should_panic]
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0805]: malformed `should_panic` attribute input
|
error[E0805]: malformed `should_panic` attribute input
|
||||||
--> $DIR/test-should-panic-attr.rs:37:1
|
--> $DIR/test-should-panic-attr.rs:38:1
|
||||||
|
|
|
|
||||||
LL | #[should_panic(expected = "foo", bar)]
|
LL | #[should_panic(expected = "foo", bar)]
|
||||||
| ^^^^^^^^^^^^^^-----------------------^
|
| ^^^^^^^^^^^^^^-----------------------^
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
//@ normalize-stdout: "TypeId\(0x[0-9a-f]+\)" -> "TypeId($$HEX)"
|
//@ normalize-stdout: "TypeId\(0x[0-9a-f]+\)" -> "TypeId($$HEX)"
|
||||||
//@ needs-threads
|
//@ needs-threads
|
||||||
//@ needs-unwind (panic)
|
//@ needs-unwind (panic)
|
||||||
|
//@ reference: attributes.testing.should_panic.expected
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
|
|
||||||
thread 'should_panic_with_any_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:15:5:
|
thread 'should_panic_with_any_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:16:5:
|
||||||
Panic!
|
Panic!
|
||||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||||
|
|
||||||
thread 'should_panic_with_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:21:5:
|
thread 'should_panic_with_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:22:5:
|
||||||
message
|
message
|
||||||
|
|
||||||
thread 'should_panic_with_substring_panics_with_incorrect_string' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:39:5:
|
thread 'should_panic_with_substring_panics_with_incorrect_string' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:40:5:
|
||||||
ZOMGWTFBBQ
|
ZOMGWTFBBQ
|
||||||
|
|
||||||
thread 'should_panic_with_substring_panics_with_non_string_value' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:46:5:
|
thread 'should_panic_with_substring_panics_with_non_string_value' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:47:5:
|
||||||
Box<dyn Any>
|
Box<dyn Any>
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ test should_panic_with_substring_panics_with_non_string_value - should panic ...
|
||||||
failures:
|
failures:
|
||||||
|
|
||||||
---- should_panic_with_any_message_does_not_panic stdout ----
|
---- should_panic_with_any_message_does_not_panic stdout ----
|
||||||
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:26:4
|
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:27:4
|
||||||
---- should_panic_with_message_does_not_panic stdout ----
|
---- should_panic_with_message_does_not_panic stdout ----
|
||||||
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:32:4
|
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:33:4
|
||||||
---- should_panic_with_substring_panics_with_incorrect_string stdout ----
|
---- should_panic_with_substring_panics_with_incorrect_string stdout ----
|
||||||
note: panic did not contain expected string
|
note: panic did not contain expected string
|
||||||
panic message: "ZOMGWTFBBQ"
|
panic message: "ZOMGWTFBBQ"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ compile-flags: --cfg test
|
//@ compile-flags: --cfg test
|
||||||
|
//@ reference: cfg.test
|
||||||
|
|
||||||
// Make sure `--cfg test` does not inject test harness
|
// Make sure `--cfg test` does not inject test harness
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue