-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Selectively replace instances of error-pattern
with check-run-results
#143537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
211c933
to
5abe0ed
Compare
This comment has been minimized.
This comment has been minimized.
5abe0ed
to
168f65c
Compare
This comment has been minimized.
This comment has been minimized.
168f65c
to
4b544a1
Compare
This comment has been minimized.
This comment has been minimized.
4b544a1
to
ca0bf4b
Compare
error-pattern
with //~? ERROR in tests/ui
error-pattern
with check-run-results
The job Click to see the possible cause of the failure (guessed by this bot)
|
I'll still need to look at this, but you might find my comment in the other PR useful for context |
Hm yeah, looking at this, I believe my comment on the other PR still holds:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this experiment!
I think it is a non-goal to remove //@ error-pattern
, but rather the original issue #134889 was proposing to double-check if //@ check-run-results
should be added, and even if so, there probably are core strings that should be checked by //@ error-pattern
.
check-run-results
will snapshot and compare the exact stderr. However, the exact stderr is easy to accidentally bless away.error-pattern
orregex-error-pattern
is there to additionally ensure the key things we're looking for are still there, i.e. harder to accidentally bless away. This can be useful if you consider that (1) the exact stderr should be snapshotted and (2) there are specific key bits that you want to ensure its presence.If anything, usually only having
check-run-results
can be suspicious.
I left a few initial remarks, I'll look at this more closely tmrw to see how we can pivot this into making it more clear what the use case of these two directives are.
//@ run-fail | ||
//@ error-pattern:index out of bounds | ||
//@ check-run-results | ||
//@ needs-subprocess | ||
|
||
use std::mem::size_of; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: More concretely, I think we cannot attempt to capture run-time panic output, because the backtrace mechanism, std line numbers of underlying panic impls / macros, etc. can change between targets and is prone to breaking.
// Verify that the expected source code is shown. | ||
//@ error-pattern: pub struct SomeStruct {} // This line should be show |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: for tests like this, I believe it's intentional that we do not snapshot exact run output, because the exact paths themselves are not important but rather it's
The actual error is irrelevant. The important part it that is should show a snippet of the dependency's source.
//@ error-pattern: r#T: 'static | ||
//@ error-pattern: r#K: 'static | ||
//@ error-pattern: T: 'static= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: for this test though, I do wonder why this is error-pattern
//@ error-pattern:assertion `left matches right` failed: 1 + 1 definitely should be 3 | ||
//@ error-pattern: left: 2 | ||
//@ error-pattern: right: 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: for example, I believe this intentionally does not try to capture full run output, because the exact panic does not matter, and only the core substrings do matter.
//@ error-pattern: a call in this macro requires a mutable binding due to mutable borrow of `d` | ||
//@ check-run-results | ||
//FIXME: remove error-pattern (see #141896) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: I want to say this can be
//~? a call in this macro requires a mutable binding due to mutable borrow of `d`
but I think //~?
had limitations in that it only matched on rustc check/build output?
@@ -1,7 +1,7 @@ | |||
//@ run-fail | |||
//@ ignore-i686-pc-windows-msvc: #112480 | |||
//@ compile-flags: -C debug-assertions | |||
//@ error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: same here, the exact assertion shape or content is not as important as having a core substring
@@ -1,5 +1,5 @@ | |||
//@ run-fail | |||
//@ error-pattern:location-mod-assign-by-zero.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: I believe these intentionally want to check for the file name in panic messages, but only to a file granularity (cf. #114814)
//@ error-pattern: overflow | ||
//@ check-run-results | ||
//@ compile-flags: -C overflow-checks=yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: for example, only "overflow" within panic message matters and less about the exact panic message
//@ error-pattern: panic in a function that cannot unwind | ||
//@ error-pattern: Noisy Drop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: this is an example where //@ check-run-results
is not a replacement of //@ error-pattern
but rather complementary, because //@ error-pattern
makes sure you can't accidentally bless away the run snapshots.
@@ -1,6 +1,6 @@ | |||
//@ run-fail | |||
//@ compile-flags: -Copt-level=3 -Cdebug-assertions=no -Zub-checks=yes | |||
//@ error-pattern: unsafe precondition(s) violated: ptr::copy requires |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: for example, here this message is critical for test intention yet not the exact panic message
Some changes occurred in tests/ui/sanitizer cc @rcvalle |
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
I combed through the stderr of every
error-pattern
test, looking for patterns that would be troublesome in acheck-run-results
context.The following should keep
error-pattern
:hashmap-capacity-overflow.rs
overflowing-neg-nonzero.rs
overflowing-pow-signed.rs
overflowing-pow-unsigned.rs
copy-nonoverlapping.rs
copy.rs
str-get_unchecked.rs
test-tasks-invalid-value.rs
The reason these are problematic is because they contain line numbers in their
stderr
which refers to parts of the Rust compiler. For example,copy-nonoverlapping.rs
's error message starts withthread 'main' panicked at /rustc/FAKE_PREFIX/library/core/src/ptr/mod.rs:522:5:
. That means that changing this unrelated file at any point in the future would result in this test failing.After this, there are hundreds of tests which contain lines such as
thread 'main' panicked at /checkout/tests/ui/precondition-checks/slice-from-raw-parts-mut.rs:13:30:
These would start failing if the test was ever modified to have additional lines. However, this vulnerability is contained to the test itself, and in almost all cases, the line number is actually important for the test's purpose. Therefore, I think this would be unwise to normalize away these numbers.
If we aim to remove
error-pattern
completely, a possible approach would be to normalize the stderr of these flaky tests to remove the paths leading to the Rust compiler files.If you would like to review my methodology, here is the log I used to review the test stderrs: https://triage.rust-lang.org/gha-logs/rust-lang/rust/45509161982
Closes #134889