Skip to content

Commit

Permalink
dev: improve failing tests logging (#544)
Browse files Browse the repository at this point in the history
* improve failing tests logging

* Add log4rs

* trunk fmt
  • Loading branch information
khaeljy authored Oct 17, 2023
1 parent bf1c850 commit 2467e04
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ broadcast

# Ignore compiled Kakarot contracts
lib/kakarot

# Ignore failing tests log
failing_tests.log
132 changes: 131 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9.25"

# Log
log = "0.4.20"
log4rs = "1.2.0"

[patch."https://github.com/ethereum/c-kzg-4844"]
c-kzg = { git = "https://github.com/rjected/c-kzg-4844", branch = "dan/add-serde-feature" }

Expand Down
4 changes: 4 additions & 0 deletions crates/ef-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ cairo-vm = { workspace = true }
starknet_api = { workspace = true }
starknet = { workspace = true }

# Log
log = { workspace = true }
log4rs = { workspace = true }

# Other
async-trait = { workspace = true }
ctor = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/ef-testing/src/models/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub(crate) fn print_results(failed: &[&CaseResult]) {
for case in failed {
match &case.result {
Ok(_) => unreachable!(),
Err(err) => println!("[!] Case {} failed:\n{}", case.path.display(), err,),
Err(err) => log::error!("[!] Case {} failed:\n{}", case.path.display(), err,),
}
}
}
3 changes: 3 additions & 0 deletions crates/ef-testing/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ fn setup() {
let subscriber = FmtSubscriber::builder().with_env_filter(filter).finish();
tracing::subscriber::set_global_default(subscriber)
.expect("setting tracing default failed");

// Set-up log4rs
log4rs::init_file("../../log4rs.yml", Default::default()).unwrap();
})
}

Expand Down
30 changes: 30 additions & 0 deletions log4rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
refresh_rate: 30 seconds

appenders:
stdout:
kind: console

failing_tests:
kind: rolling_file
path: ../../failing_tests.log
append: true
encoder:
pattern: "{m}{n}"
policy:
kind: compound
trigger:
kind: size
limit: 10 mb
roller:
kind: delete

root:
level: info
appenders:
- stdout

loggers:
ef_testing::models::result:
level: error
appenders:
- failing_tests

0 comments on commit 2467e04

Please sign in to comment.