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

test runner #807

Merged
merged 3 commits into from
Mar 10, 2023
Merged

test runner #807

merged 3 commits into from
Mar 10, 2023

Conversation

g-r-a-n-t
Copy link
Member

@g-r-a-n-t g-r-a-n-t commented Nov 10, 2022

This PR contains the following:

  • test attribute for functions and appropriate checks
  • test function compilation
  • test-runner crate with revm backend
  • tests crate which uses the test runner (renamed old tests crate to tests-legacy)
  • CLI test subcommand

Example CLI usage:

Screenshot from 2023-02-28 16-14-28

To-Do

  • OPTIONAL: Update Spec if applicable
  • Add entry to the release notes (may forgo for trivial changes)
  • Clean up commit history

crates/tests/src/ingots.rs Outdated Show resolved Hide resolved
crates/codegen/src/yul/isel/function.rs Outdated Show resolved Hide resolved
crates/driver/Cargo.toml Outdated Show resolved Hide resolved
crates/driver/src/lib.rs Outdated Show resolved Hide resolved
crates/driver/src/lib.rs Outdated Show resolved Hide resolved
crates/test-files/fixtures/ingots/basic_ingot/src/bing.fe Outdated Show resolved Hide resolved
crates/test-files/fixtures/internal/const_local.fe Outdated Show resolved Hide resolved
crates/test-files/fixtures/internal/revert.fe Outdated Show resolved Hide resolved
crates/test-files/fixtures/internal/while_loop.fe Outdated Show resolved Hide resolved
crates/tests/src/internal.rs Outdated Show resolved Hide resolved
todo Outdated Show resolved Hide resolved
@g-r-a-n-t g-r-a-n-t force-pushed the test-runner branch 6 times, most recently from 55df6d3 to 7e3d540 Compare February 28, 2023 23:20
crates/analyzer/tests/analysis.rs Outdated Show resolved Hide resolved
crates/parser/src/grammar/module.rs Show resolved Hide resolved
@g-r-a-n-t g-r-a-n-t force-pushed the test-runner branch 2 times, most recently from 6881993 to 8f37628 Compare February 28, 2023 23:39
@g-r-a-n-t g-r-a-n-t marked this pull request as ready for review February 28, 2023 23:53
@g-r-a-n-t g-r-a-n-t force-pushed the test-runner branch 2 times, most recently from 6bc5914 to 3da04d7 Compare March 5, 2023 19:32
crates/driver/Cargo.toml Outdated Show resolved Hide resolved
crates/fe/Cargo.toml Show resolved Hide resolved
crates/tests-legacy/Cargo.toml Show resolved Hide resolved
crates/driver/src/lib.rs Outdated Show resolved Hide resolved
@g-r-a-n-t g-r-a-n-t force-pushed the test-runner branch 3 times, most recently from 21bf81f to c4e9579 Compare March 6, 2023 03:46
@g-r-a-n-t
Copy link
Member Author

I'm using revm now @sbillig. There's a nested dependency on getrand that fails to build for wasm. I'm not sure how to easily fix this, so I'm just disabling revm for wasm. let me know if you have any ideas

Comment on lines 358 to 359
// test_file! { test_call }
// test_file! { test_params }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g-r-a-n-t These tests aren't producing snapshots, which breaks the test on wasm. I assume there's no error output? (The test_file macro should probably assert that there's error output)

Copy link
Member Author

@g-r-a-n-t g-r-a-n-t Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason test_ is being removed from the snapshot name when using insta

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, looks like insta just does this

#[test]
fn test_my_thing() {
    assert_snapshot!("test123")
}
Snapshot file: crates/analyzer/tests/snapshots/errors__my_thing.snap
Snapshot: my_thing
Source: crates/analyzer/tests/errors.rs:101

@sbillig sbillig force-pushed the test-runner branch 2 times, most recently from 2b33047 to 46e22a1 Compare March 6, 2023 05:38
- name: Run WASM tests
# wasm-pack needs a Cargo.toml with a 'package' field.
# (see https://github.com/rustwasm/wasm-pack/issues/642)
# This will still run all tests in the workspace.
run: wasm-pack test --node crates/fe -- --workspace
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this used to run the tests, but now doesn't, so we haven't actually been running wasm tests for a while (and they've been broken). I guess it was a wasm-pack change? 🤷

@sbillig
Copy link
Collaborator

sbillig commented Mar 6, 2023

@g-r-a-n-t I pushed a commit to let the test-runner crate build on wasm, but of course we can't run any of the tests because we can't build the solc backend on wasm 🤦. Anyway, I still think this was a worthwhile exercise.

@g-r-a-n-t g-r-a-n-t requested a review from sbillig March 7, 2023 16:50
Copy link
Collaborator

@sbillig sbillig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@sbillig sbillig merged commit 65ffd4a into ethereum:master Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants