mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 14:06:29 +03:00
test: Notifiy more prominently & in more tests about false positives when running cargo test (#6308)
This PR: - Moves the note about the false positive to the end of the test output, where it is more likely to be noticed - Also notes in test_modify_chat_disordered() and test_setup_contact_*(), in addition to the existing note in test_was_seen_recently()
This commit is contained in:
@@ -1351,6 +1351,24 @@ async fn write_msg(context: &Context, prefix: &str, msg: &Message, buf: &mut Str
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// When dropped after a test failure,
|
||||
/// prints a note about a possible false-possible caused by SystemTime::shift().
|
||||
pub(crate) struct TimeShiftFalsePositiveNote;
|
||||
impl Drop for TimeShiftFalsePositiveNote {
|
||||
fn drop(&mut self) {
|
||||
if std::thread::panicking() {
|
||||
let green = nu_ansi_term::Color::Green.normal();
|
||||
println!("{}", green.paint(
|
||||
"\nNOTE: This test failure may be a false-positive, caused by tests running in parallel.
|
||||
The issue is that `SystemTime::shift()` (a utility function for tests) changes the time for all threads doing tests, and not only for the running test.
|
||||
Until the false-positive is fixed:
|
||||
- Use `cargo test -- --test-threads 1` instead of `cargo test`
|
||||
- Or use `cargo nextest run` (install with `cargo install cargo-nextest --locked`)\n")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user