Skip to content

Commit a896101

Browse files
committed
Add test for ensuring determinism of static-api
1 parent 4e28840 commit a896101

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ atty.workspace = true
2929
difference.workspace = true
3030
duct.workspace = true
3131
walkdir.workspace = true
32+
dir-diff = "0.3"
3233

3334
[workspace]
3435
members = [

tests/snapshot.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ fn static_api() -> Result<(), Error> {
7777
Ok(())
7878
}
7979

80+
#[test]
81+
fn static_api_determinism() -> Result<(), Error> {
82+
// Ensure that the output of `static-api` is deterministic
83+
let dir = tempfile::TempDir::new()?;
84+
let reference_dir = dir.path().join("reference");
85+
cmd!(bin(), "static-api", &reference_dir).assert_success()?;
86+
87+
for i in 0..10 {
88+
let out = dir.path().join(format!("output-{i}"));
89+
cmd!(bin(), "static-api", &out).assert_success()?;
90+
assert!(
91+
!dir_diff::is_different(&reference_dir, &out)?,
92+
"static-api produced non-deterministic output"
93+
);
94+
}
95+
Ok(())
96+
}
97+
8098
fn bin() -> &'static str {
8199
env!("CARGO_BIN_EXE_rust-team")
82100
}

0 commit comments

Comments
 (0)