Skip to content

Commit

Permalink
Catch compiler panics in e2e tests (FuelLabs#4776)
Browse files Browse the repository at this point in the history
close FuelLabs#4384

## 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 7, 2023
1 parent 3b66f8e commit 8491be8
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/src/e2e_vm_tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,16 @@ pub(crate) async fn compile_to_bytes(file_name: &str, run_config: &RunConfig) ->
},
..Default::default()
};
let result = forc_pkg::build_with_options(build_opts);

// Print the result of the compilation (i.e., any errors Forc produces).
if let Err(ref e) = result {
println!("\n{e}");
match std::panic::catch_unwind(|| forc_pkg::build_with_options(build_opts)) {
Ok(result) => {
// Print the result of the compilation (i.e., any errors Forc produces).
if let Err(ref e) = result {
println!("\n{e}");
}
result
}
Err(_) => Err(anyhow!("Compiler panic")),
}

result
}

/// Compiles the project's unit tests, then runs all unit tests.
Expand Down

0 comments on commit 8491be8

Please sign in to comment.