Add ruleset packs, linter, fixtures, and JSON schema
This commit is contained in:
76
vid-repair-core/tests/fixtures.rs
Normal file
76
vid-repair-core/tests/fixtures.rs
Normal file
@@ -0,0 +1,76 @@
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
use tempfile::tempdir;
|
||||
|
||||
use vid_repair_core::config::Config;
|
||||
use vid_repair_core::rules::RuleSet;
|
||||
use vid_repair_core::scan::scan_file;
|
||||
|
||||
fn command_available(cmd: &str) -> bool {
|
||||
Command::new(cmd)
|
||||
.arg("-version")
|
||||
.output()
|
||||
.map(|out| out.status.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn ruleset_dir() -> PathBuf {
|
||||
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
manifest_dir
|
||||
.parent()
|
||||
.expect("workspace root")
|
||||
.join("rulesets")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scan_clean_fixture_has_no_issues() {
|
||||
if !command_available("ffmpeg") || !command_available("ffprobe") {
|
||||
eprintln!("ffmpeg/ffprobe not available; skipping fixture test");
|
||||
return;
|
||||
}
|
||||
|
||||
let dir = tempdir().expect("tempdir");
|
||||
let output = dir.path().join("clean.mp4");
|
||||
|
||||
let status = Command::new("ffmpeg")
|
||||
.args([
|
||||
"-y",
|
||||
"-hide_banner",
|
||||
"-loglevel",
|
||||
"error",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"testsrc=size=128x72:rate=30",
|
||||
"-f",
|
||||
"lavfi",
|
||||
"-i",
|
||||
"sine=frequency=1000:sample_rate=44100",
|
||||
"-t",
|
||||
"1",
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-pix_fmt",
|
||||
"yuv420p",
|
||||
"-c:a",
|
||||
"aac",
|
||||
"-movflags",
|
||||
"+faststart",
|
||||
output.to_str().unwrap(),
|
||||
])
|
||||
.status()
|
||||
.expect("ffmpeg run");
|
||||
|
||||
if !status.success() {
|
||||
eprintln!("ffmpeg failed to create fixture");
|
||||
return;
|
||||
}
|
||||
|
||||
let config = Config::default();
|
||||
let ruleset = RuleSet::load_from_dir(&ruleset_dir()).expect("ruleset load");
|
||||
|
||||
let scan = scan_file(&output, &config, &ruleset).expect("scan file");
|
||||
|
||||
assert!(scan.issues.is_empty(), "Expected no issues, got {}", scan.issues.len());
|
||||
}
|
||||
Reference in New Issue
Block a user