Skip to content

Commit ef4cdcf

Browse files
committed
add traces to test fails
1 parent a497506 commit ef4cdcf

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

crates/forge/tests/it/config.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ use foundry_evm::{
1313
decode::decode_console_logs, inspectors::CheatsConfig, revm::primitives::SpecId,
1414
};
1515
use foundry_test_utils::Filter;
16-
use std::{
17-
collections::BTreeMap,
18-
path::{Path, PathBuf},
19-
};
16+
use itertools::Itertools;
17+
use std::{collections::BTreeMap, path::Path};
2018

2119
/// How to execute a a test run
2220
pub struct TestConfig {
@@ -82,11 +80,12 @@ impl TestConfig {
8280
let outcome = if self.should_fail { "fail" } else { "pass" };
8381

8482
eyre::bail!(
85-
"Test {} did not {} as expected.\nReason: {:?}\nLogs:\n{}",
83+
"Test {} did not {} as expected.\nReason: {:?}\nLogs:\n{}\n\nTraces:\n{}",
8684
test_name,
8785
outcome,
8886
result.reason,
89-
logs.join("\n")
87+
logs.join("\n"),
88+
result.traces.iter().map(|(_, a)| a).format("\n"),
9089
)
9190
}
9291
}
@@ -136,14 +135,14 @@ pub(crate) fn init_tracing() {
136135
.try_init();
137136
}
138137

139-
pub fn manifest_root() -> PathBuf {
138+
pub fn manifest_root() -> &'static Path {
140139
let mut root = Path::new(env!("CARGO_MANIFEST_DIR"));
141140
// need to check here where we're executing the test from, if in `forge` we need to also allow
142141
// `testdata`
143142
if root.ends_with("forge") {
144143
root = root.parent().unwrap();
145144
}
146-
root.to_path_buf()
145+
root
147146
}
148147

149148
/// Builds a base runner
@@ -161,7 +160,7 @@ pub async fn runner() -> MultiContractRunner {
161160
/// Builds a non-tracing runner
162161
pub async fn runner_with_config(mut config: Config) -> MultiContractRunner {
163162
config.rpc_endpoints = rpc_endpoints();
164-
config.allow_paths.push(manifest_root());
163+
config.allow_paths.push(manifest_root().to_path_buf());
165164

166165
let root = &PROJECT.paths.root;
167166
let opts = &*EVM_OPTS;

crates/forge/tests/it/test_helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub static EVM_OPTS: Lazy<EvmOpts> = Lazy::new(|| EvmOpts {
7272
sender: Config::DEFAULT_SENDER,
7373
initial_balance: U256::MAX,
7474
ffi: true,
75+
verbosity: 3,
7576
..Default::default()
7677
});
7778

testdata/foundry.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[profile.default]
2-
solc = "0.8.19"
2+
solc = "0.8.18"
33
block_base_fee_per_gas = 0
44
block_coinbase = "0x0000000000000000000000000000000000000000"
55
block_difficulty = 0
@@ -36,10 +36,10 @@ remappings = ["ds-test/=lib/ds-test/src/"]
3636
sender = "0x00a329c0648769a73afac7f9381e08fb43dbea72"
3737
sizes = false
3838
sparse_mode = false
39-
src = "src"
40-
test = "test"
39+
src = "./"
40+
test = "./"
4141
tx_origin = "0x00a329c0648769a73afac7f9381e08fb43dbea72"
42-
verbosity = 0
42+
verbosity = 3
4343
via_ir = false
4444
fs_permissions = [{ access = "read-write", path = "./" }]
4545

0 commit comments

Comments
 (0)