Skip to content

Commit

Permalink
Give the snapshot tests extra stack space to run
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybosamiya committed May 16, 2024
1 parent 986d59a commit 9c683e6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ tracing-subscriber = { version = "0.3.17" }
insta = { version = "1.30.0" }
similar = { version = "2.2.1" }
glob = "0.3.1"
stacker = "0.1.15"

# Spend more time on initial compilation in exchange for faster runs
[profile.dev.package.insta]
Expand Down
9 changes: 8 additions & 1 deletion tests/snapshot-examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
//! quick indicator for whether files in `../examples/` (such as `../examples/syntax.rs`) have been
//! modified by any change.

fn verusfmt_run_with_extra_stack(s: &str, opts: verusfmt::RunOptions) -> miette::Result<String> {
#[allow(non_upper_case_globals)]
const MiB: usize = 1024 * 1024;
const STACK_SIZE: usize = 8 * MiB;
stacker::grow(STACK_SIZE, || verusfmt::run(s, opts))
}

fn check_snapshot(original: &str) {
check_snapshot_with_config(original, Default::default())
}

fn check_snapshot_with_config(original: &str, config: verusfmt::RunOptions) {
let formatted = verusfmt::run(original, config).unwrap();
let formatted = verusfmt_run_with_extra_stack(original, config).unwrap();
if original != formatted {
let diff = similar::udiff::unified_diff(
similar::Algorithm::Patience,
Expand Down

0 comments on commit 9c683e6

Please sign in to comment.