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

Improve test logging #510

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
run: make setup
- uses: taiki-e/install-action@nextest
- name: run tests
run: make ef-tests
run: make tests
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["trunk.io", "streetsidesoftware.code-spell-checker"]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["delegatecall", "revm", "sload", "sstore"]
}
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ $(EF_TESTS_DIR):

# Ensures the commands for $(EF_TESTS_DIR) always run on `make setup`, regardless if the directory exists
.PHONY: $(EF_TESTS_DIR)
setup: $(EF_TESTS_DIR)
setup: $(EF_TESTS_DIR)

setup-kakarot: pull-kakarot
setup-kakarot: pull-kakarot
cd lib/kakarot && make setup && make build

pull-kakarot:
git submodule update --init --recursive

# Runs the Ethereum Foundation tests
ef-tests:
cargo nextest run -p ef-testing --features ef-tests
# Runs the repo tests
tests:
cargo nextest run --all-features

# Runs specific test
# Runs ef tests only
ef-test:
TARGET=$(target) cargo test -p ef-testing --features ef-tests -- --nocapture
cargo nextest run --package ef-testing --test tests --features ef-tests
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ instructions:

## Test execution

To run the whole test suite, execute `make ef-tests` To run a specific test or
list of tests, execute `make target=regular_expression ef-test` where
To run the whole test suite, execute `make ef-test` To run a specific test or
list of tests, execute `TARGET=regular_expression make ef-test` where
regular_expression allows you to filter on the specific tests you want to run.

## Acknowledgement
Expand Down
32 changes: 2 additions & 30 deletions crates/ef-testing/src/models/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ impl CaseResult {
}

/// Assert that all the given tests passed and print the results to stdout.
pub(crate) fn assert_tests_pass(suite_name: &str, path: &Path, results: &[CaseResult]) {
let (passed, failed, skipped) = categorize_results(results);

print_results(suite_name, path, &passed, &failed, &skipped);

pub(crate) fn assert_tests_pass(_suite_name: &str, _path: &Path, results: &[CaseResult]) {
let (_passed, failed, _skipped) = categorize_results(results);
assert!(failed.is_empty(), "Some tests failed (see above)");
}

Expand All @@ -55,28 +52,3 @@ pub(crate) fn categorize_results(

(passed, failed, skipped)
}

/// Display the given test results to stdout.
pub(crate) fn print_results(
suite_name: &str,
path: &Path,
passed: &[&CaseResult],
failed: &[&CaseResult],
skipped: &[&CaseResult],
) {
println!("\n Suite: {suite_name} (at {})", path.display());
println!(
"Ran {} tests ({} passed, {} failed, {} skipped) \n",
passed.len() + failed.len() + skipped.len(),
passed.len(),
failed.len(),
skipped.len()
);

for case in failed {
match &case.result {
Ok(_) => unreachable!(),
Err(err) => println!("[!] Case {} failed:\n{}", case.path.display(), err),
}
}
}
5 changes: 4 additions & 1 deletion crates/sequencer/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ where
<&mut S>::commit(&mut cached_state)?;
match execution_information.revert_error {
Some(err) => {
warn!("Transaction execution reverted: {:?}", err)
warn!(
"Transaction execution reverted: {}",
err.replace("\\n", "\n")
)
}
None => {
trace!("Transaction execution succeeded {execution_information:?}")
Expand Down
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ of an issue raised by an Integrator.
### Debugger

Pick an issue from the available `Integrator` issues. Verify that the test fails
(you can run a specific test by using `make target=your_test_name ef-test`). If
(you can run a specific test by using `TARGET=your_test_name make ef-test`). If
it does, you can start debugging it. The following documentation can be used:

- [Test fillers](https://github.com/ethereum/tests/tree/develop/src/GeneralStateTestsFiller):
Expand Down Expand Up @@ -103,7 +103,7 @@ Ethereum/test:
blockifier = { git = "https://github.com/jobez/blockifier.git", rev = "7f00407" }
```

- Run `make target=your_test_name ef-test`. You should see the executed opcodes
- Run `TARGET=your_test_name make ef-test`. You should see the executed opcodes
being printed out.

#### Reproducing in Python (to be updated once Python test flow is improved)
Expand Down
Loading