Skip to content

Commit

Permalink
[rust][test] Search for {{{reset}}} or {{{reset:begin}}}
Browse files Browse the repository at this point in the history
This CL makes rust_runner_integration_test look for either {{{reset}}}
or {{{reset:begin}}} in logs. Before, it only looked for the former.
This is blocking the Rust toolchain roll, because after rolling the logs
contain the latter instead.

Here is what led to this:

* I0c4b787f79fe0d8f62370e302d232e77087e2de4 added support for backtrace
  prettifying, which uses {{{reset:begin}}} and {{{reset:end}}} instead
  of just {{{reset}}}.

* Idcb28b8c9a3269f0e1534b703d9231e8d452d801 made the Rust runner
  integration test look for {{{reset}}} in the output.

* rust-lang/backtrace-rs#559 made backtrace-rs
  start emitting {{{reset:begin}}} and {{{reset:end}}}.

* rust-lang/rust@249595b
  bumped rustc to use the new backtrace-rs.

Test: fx test rust_runner_integration_test
Bug: 132466, 59736
Change-Id: Ibec5d50b4c5d62f003178dc2b825ebde007a62a8
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/907287
Reviewed-by: Tyler Mandry <tmandry@google.com>
Reviewed-by: Ankur Mittal <anmittal@google.com>
Commit-Queue: Mitchell Kember <mkember@google.com>
  • Loading branch information
Mitchell Kember authored and Rebase bot committed Aug 25, 2023
1 parent dadbea7 commit db3e1b9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/sys/test_runners/rust/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,29 @@ async fn launch_and_run_sample_test_internal(parallel: u16) {

assert_eq!(expected_events, events_without_failing_test_logs);

let reset = "{{{reset}}}";
let (reset_index, _) = failing_test_logs
.iter()
.enumerate()
.find(|(_, event)| {
let RunEvent::CaseStderr { name: _, stderr_message: line } = event else {
return false;
};
line == reset
line == "{{{reset}}}" || line == "{{{reset:begin}}}"
})
.expect("should have reset log");
assert!(failing_test_logs.len() > reset_index, "{:?}", failing_test_logs);
let assert_contains = |msg| {
let contains = |msg| {
failing_test_logs[0..reset_index].iter().any(|event| {
let RunEvent::CaseStderr { name: _, stderr_message: line } = event else {
return false;
};
line.contains(msg)
})
};
assert_contains("thread 'main' panicked at");
assert_contains("I'm supposed to panic!()");
assert_contains("../../src/sys/test_runners/rust/test_data/sample-rust-tests/src/lib.rs:20:9");
assert_contains("stack backtrace:");
assert!(contains("I'm supposed to panic!()"));
assert!(contains(
"../../src/sys/test_runners/rust/test_data/sample-rust-tests/src/lib.rs:20:9"
));
assert_eq!(
failing_test_logs.last().unwrap(),
&RunEvent::case_stderr("my_tests::failing_test", "test failed.")
Expand Down

0 comments on commit db3e1b9

Please sign in to comment.