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(parser): snapshot testing with expect_test #266

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

39555
Copy link
Contributor

@39555 39555 commented Nov 8, 2024

expect_test is minimalistic library from the rust-analyzer project that does not require a lot of learning. It can update both inline snapshots and snapshots from files by running UPDATE_EXPECT=1 cargo test. TTo achieve comparable functionality to insta I've added serde_yaml for serialization although I don't particularly like using serde here because it doesn't include type names. A similar limitation to insta is that the snapshot file doesn’t include the input.

Copy link

github-actions bot commented Nov 8, 2024

Performance Benchmark Report

Benchmark name Baseline (μs) Test/PR (μs) Delta (μs) Delta %
expand_one_string 3.46 μs 3.46 μs -0.00 μs ⚪ Unchanged
instantiate_shell 60.11 μs 60.35 μs 0.24 μs ⚪ Unchanged
instantiate_shell_with_init_scripts 33695.05 μs 34763.93 μs 1068.88 μs 🟠 +3.17%
parse_bash_completion 2973.75 μs 2864.48 μs -109.27 μs ⚪ Unchanged
parse_sample_script 4.30 μs 4.25 μs -0.06 μs 🟢 -1.37%
run_echo_builtin_command 91.72 μs 92.83 μs 1.11 μs ⚪ Unchanged
run_one_builtin_command 109.12 μs 111.63 μs 2.51 μs ⚪ Unchanged
run_one_external_command 2105.38 μs 2032.12 μs -73.26 μs 🟢 -3.48%
run_one_external_command_directly 1035.12 μs 1030.67 μs -4.45 μs ⚪ Unchanged

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
brush-core/src/shell.rs 🟢 77.45% 🟢 78.01% 🟢 0.56%
brush-parser/src/parser.rs 🟢 99.14% 🟢 99.21% 🟢 0.07%
brush-shell/src/main.rs 🟢 90.26% 🟢 90.91% 🟢 0.65%
Overall Coverage 🟢 74.34% 🟢 74.54% 🟢 0.2%

Minimum allowed coverage is 70%, this run produced 74.54%

@39555
Copy link
Contributor Author

39555 commented Nov 8, 2024

The second commit contains snapshots in ron format. It looks better with the struct names

@39555 39555 force-pushed the test-with-expect-test branch from 0ff9cce to 6ff7d7a Compare November 8, 2024 21:31
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.

1 participant