1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#![allow(missing_docs)]
// Unix-only: this test shells out to the system `diff` command which is not
// standard on Windows. The corpus is platform-invariant (regenerated vectors
// are byte-identical regardless of OS), so Unix CI coverage is sufficient.
#[cfg(unix)]
use assert_cmd::Command;
#[cfg(unix)]
use std::process::Command as StdCommand;
#[cfg(unix)]
use tempfile::tempdir;
#[cfg(all(unix, feature = "json"))]
#[test]
fn vectors_output_matches_committed_corpus() {
let tmp = tempdir().unwrap();
Command::cargo_bin("md")
.unwrap()
.args(["vectors", "--out", tmp.path().to_str().unwrap()])
.assert()
.success();
let committed = format!("{}/../md-codec/tests/vectors", env!("CARGO_MANIFEST_DIR"));
// Compare every committed corpus file against the freshly-generated tmp tree.
// Use --exclude to skip the manifest (source-of-truth, not a generated artifact)
// and the .gitkeep marker.
let status = StdCommand::new("diff")
.args([
"-r",
"--exclude=manifest.rs",
"--exclude=.gitkeep",
// The BIP-341 upstream wallet-test-vectors.json fixture lives
// alongside the md-codec corpus as the host for
// `bip341_wallet_vectors.rs`, but isn't generated by `md vectors`.
// Exclude from the corpus-drift diff. Cycle: v0.8.0 Phase 1.
"--exclude=bip341-wallet-test-vectors.json",
tmp.path().to_str().unwrap(),
&committed,
])
.status()
.unwrap();
assert!(status.success(), "vectors corpus drift detected");
}