//! `wai conform` run against implementations of each kind, through both adapters, and its //! records checked by `wai verify`: //! //! - the reference verifiers of the claim, JWP and key-discovery corpora (`wai_*_vectors //! verdicts`, whole-corpus runs) conform, and so does the key-discovery reference behind //! an HTTP adapter; one that changes one verdict does not, at that case alone; //! - the score reference renderer (`wai score render`) conforms, and one that changes one //! byte of its output fails every case; //! - the reference origin (`wai http origin`) serving the HTTP corpus's objects conforms, //! and one serving an object with one byte changed fails that object; //! - a record changed after signing, in a case's outcome or in its summary, is refused by //! `wai verify`; a dry run writes nothing; a record is not replaced without `--yes`; //! each failure to run has its exit status; //! - `--format junit` and `--format html` are the records' report: a test case a case, a failure //! exactly where a case failed, the independent verifier's record told apart from the //! implementation's; `--format json` is the envelope `--json` prints; //! - `--independent` beside an implementation runs the corpus's independent verifier on the same //! cases, its own signed record beside the implementation's: the run passes when both conform //! and agree, and a case the two disagree on fails it and is named, two passing answers that //! differ on a case the corpus states in part among them; with the real Python verifier too; //! beside the origin, the HTTP corpus's verifier over the whole corpus, which failing fails it; //! - `--independent` alone runs the independent verifiers `--suite` names (each with its own //! command line, in `wai/`), a record a corpus in `--out
] --json`, the record to `out`.
fn floor_run(dir: &Path, suite: &str, imp: &str, presents: Option<&str>, out: &Path, more: &[&str]) -> (i32, Value, String) {
let root = wai_dir();
let mut args = vec!["conform", "decoder", "--suite", suite, "--impl", imp, "--root", root.to_str().unwrap(), "--out", out.to_str().unwrap(), "--yes"];
if let Some(p) = presents {
args.extend(["--presents", p]);
}
args.extend(more);
let o = wai(dir, &[args.as_slice(), &["--json"]].concat());
let v: Value = serde_json::from_slice(&o.stdout).unwrap_or_else(|_| panic!("JSON: {}", text(&o)));
let t = wai(dir, &args);
(o.status.code().unwrap_or(-1), v, text(&t))
}
/// `wai conform decoder --suite video-floor --impl 'wai-av1 {in} {out}' --presents video`: the
/// video floor run against this repository's own AV1 decoder (`../wai-av1`, its `wai-av1`
/// command, built here), which passes it, its record admitted by `wai verify --conformant`.
#[cfg(unix)]
#[test]
fn the_video_floor_passes_with_this_repositorys_own_av1_decoder() {
let d = tmp("floor-wai-av1");
let target = Path::new(env!("CARGO_TARGET_TMPDIR")).join("wai-av1");
let manifest = wai_dir().join("wai-av1/Cargo.toml");
let b = Command::new(env!("CARGO")).args(["build", "--release", "--locked", "--bin", "wai-av1", "--manifest-path", manifest.to_str().unwrap(), "--target-dir", target.to_str().unwrap()]).output().unwrap();
assert!(b.status.success(), "{}", String::from_utf8_lossy(&b.stderr));
let bin = target.join("release").join(if cfg!(windows) { "wai-av1.exe" } else { "wai-av1" });
let imp = format!("{} {{in}} {{out}}", q(bin.to_str().unwrap()));
let out = d.join("wai-av1.wai-conform.json");
let (code, v, t) = floor_run(&d, "video-floor", &imp, Some("video"), &out, &[]);
assert_eq!(code, 0, "{v:#}\n{t}");
assert_eq!((v["data"]["cases"].as_u64(), v["data"]["not_run"].as_u64(), v["data"]["conformant"].as_bool()), (Some(1), Some(0), Some(true)), "{v:#}");
assert!(t.contains("the video floor (decoder video-floor): 1 of 1 cases passed: conformant"), "{t}");
let o = wai(&d, &["verify", "--conformant", "--root", wai_dir().to_str().unwrap(), out.to_str().unwrap()]);
assert!(o.status.success(), "{}", text(&o));
let _ = std::fs::remove_dir_all(&d);
}
#[cfg(unix)]
#[test]
fn the_floor_suites_hold_a_sink_to_the_class_rule() {
let d = tmp("floor");
let r = wai_dir();
let outs = floor_outputs(&d);
// A sink's decoder, given the envelope ($1) and where its output goes ($2): the case's output,
// by the envelope's name.
let copy = format!("cp {}/\"$(basename \"$1\" .wai)\".out \"$2\"", q(outs.to_str().unwrap()));
let script = |name: &str, body: &str| format!("{} {{in}} {{out}}", q(fake_python(&d, name, body).to_str().unwrap()));
let decodes = script("decodes", ©);
// One with no AV1 decoder, which says so.
let no_av1 = script("no-av1", &format!("case \"$(basename \"$1\")\" in av1-*) echo unsupported wai.video.av1; exit 3;; esac; {copy}"));
// (1) It presents video and decodes every case: both floors pass, a record each, both admitted.
let out = d.join("sink.wai-conform.json");
let (code, v, t) = floor_run(&d, "floor", &decodes, Some("audio,video"), &out, &[]);
assert_eq!(code, 0, "{v:#}\n{t}");
let data = &v["data"];
assert_eq!((data["conformant"].as_bool(), data["cases"].as_u64(), data["not_run"].as_u64()), (Some(true), Some(4), Some(0)), "{data:#}");
let runs = data["runs"].as_array().unwrap();
assert_eq!(runs.iter().map(|r| r["suite"].as_str().unwrap()).collect::