Skip to content

Commit

Permalink
Show compiler error messages for unit tests that do not compile (Fuel…
Browse files Browse the repository at this point in the history
…Labs#4840)

Fixes FuelLabs#4839

## Description

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
anton-trunov authored Jul 20, 2023
1 parent 686f5e0 commit 55dd654
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions test/src/e2e_vm_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,34 +319,34 @@ impl TestContext {
harness::compile_and_run_unit_tests(&name, &context.run_config, true).await;
*output = out;

let tested_pkgs = result.expect("failed to compile and run unit tests");
let failed: Vec<String> = tested_pkgs
.into_iter()
.flat_map(|tested_pkg| {
tested_pkg
.tests
.into_iter()
.filter(|test| !test.passed())
.map(move |test| {
format!(
"{}: Test '{}' failed with state {:?}, expected: {:?}",
tested_pkg.built.descriptor.name,
test.name,
test.state,
test.condition,
)
})
})
.collect();

if !failed.is_empty() {
panic!(
"For {name}\n{} tests failed:\n{}",
failed.len(),
failed.into_iter().collect::<String>()
);
}
Ok(())
result.map(|tested_pkgs| {
let failed: Vec<String> = tested_pkgs
.into_iter()
.flat_map(|tested_pkg| {
tested_pkg
.tests
.into_iter()
.filter(|test| !test.passed())
.map(move |test| {
format!(
"{}: Test '{}' failed with state {:?}, expected: {:?}",
tested_pkg.built.descriptor.name,
test.name,
test.state,
test.condition,
)
})
})
.collect();

if !failed.is_empty() {
panic!(
"For {name}\n{} tests failed:\n{}",
failed.len(),
failed.into_iter().collect::<String>()
);
}
})
}

category => Err(anyhow::Error::msg(format!(
Expand Down

0 comments on commit 55dd654

Please sign in to comment.