Skip to content

Commit

Permalink
more contexts for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sveitser committed Mar 10, 2025
1 parent 74cd285 commit 6dcf7a0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ jobs:
version: [02,99]
include:
- version: 02
test-name: test_native_demo
test-name: test_native_demo_basic

- version: 99
test-name: test_native_demo_upgrade
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test-all:
cargo nextest run --locked --release --workspace --verbose --profile all

test-integration:
INTEGRATION_TEST_SEQUENCER_VERSION=2 cargo nextest run -p tests --nocapture --profile integration test_native_demo
INTEGRATION_TEST_SEQUENCER_VERSION=2 cargo nextest run -p tests --nocapture --profile integration test_native_demo_basic

test-integration-mp:
INTEGRATION_TEST_SEQUENCER_VERSION=99 cargo nextest run -p tests --nocapture --profile integration test_native_demo_upgrade
Expand Down
27 changes: 19 additions & 8 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
time::Duration,
};

use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use client::SequencerClient;
use espresso_types::{FeeAmount, FeeVersion, MarketplaceVersion};
use ethers::prelude::*;
Expand Down Expand Up @@ -330,12 +330,23 @@ impl NativeDemo {
});

println!("Writing native demo logs to file: {}", log_path);
let outputs = File::create(log_path)?;
let errors = outputs.try_clone()?;
cmd.stdout(outputs) // Redirect stdout to log file
.stderr(errors); // Redirect stderr to log file
Ok(Self {
_child: cmd.spawn()?,
})
let outputs = File::create(log_path).context("unable to create log file")?;
let errors = outputs
.try_clone()
.context("unable to clone log file handle")?;
cmd.stdout(outputs).stderr(errors);

let mut child = cmd.spawn()?;

// Wait for three seconds and check if process has already exited so we don't waste time
// waiting for results later.
std::thread::sleep(Duration::from_secs(3));
if let Some(exit_code) = child.try_wait()? {
return Err(anyhow!("process-compose exited early with: {}", exit_code));
}

println!("process-compose started ...");

Ok(Self { _child: child })
}
}
2 changes: 1 addition & 1 deletion tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub async fn assert_native_demo_works() -> Result<()> {
}

#[tokio::test(flavor = "multi_thread")]
async fn test_native_demo() -> Result<()> {
async fn test_native_demo_basic() -> Result<()> {
let _child = NativeDemo::run(None);
assert_native_demo_works().await
}

0 comments on commit 6dcf7a0

Please sign in to comment.