Skip to content
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

E2E Dump logs and cleanup on assert failures #1252

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions bin/citrea/tests/bitcoin_e2e/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,27 @@ impl<T: TestCase> TestCaseRunner<T> {
///
/// This sets up the framework, executes the test, and ensures cleanup is performed even if a panic occurs.
pub async fn run(mut self) -> Result<()> {
let mut framework = None;
let result = panic::AssertUnwindSafe(async {
let mut framework = TestFramework::new(Self::generate_test_config()?).await?;
let test_result = self.run_test_case(&mut framework).await;

if test_result.is_err() {
if let Err(e) = framework.dump_log() {
eprintln!("Error dumping log: {}", e);
}
}

framework.stop().await?;

test_result
framework = Some(TestFramework::new(Self::generate_test_config()?).await?);
let f = framework.as_mut().unwrap();
self.run_test_case(f).await
})
.catch_unwind()
.await;

let f = framework
.as_mut()
.expect("Framework not correctly initialized");

if result.is_err() {
if let Err(e) = f.dump_log() {
eprintln!("Error dumping log: {}", e);
}
}

f.stop().await?;

// Additional test cleanup
self.0.cleanup().await?;

Expand Down
Loading