reubeno / brush

bash/POSIX-compatible shell implemented in Rust
MIT License
26 stars 4 forks source link

test(parser): snapshot testing with `expect_test` #266

Open 39555 opened 2 weeks ago

39555 commented 2 weeks ago

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.

github-actions[bot] commented 2 weeks ago

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 commented 2 weeks ago

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