81 lines
2.3 KiB
Rust
81 lines
2.3 KiB
Rust
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
use tempfile::tempdir;
|
|
|
|
use vid_repair_core::config::Config;
|
|
use vid_repair_core::fix::{FixAction, FixKind, FixPlan};
|
|
use vid_repair_core::rules::RuleSet;
|
|
use vid_repair_core::scan::scan_file;
|
|
use vid_repair_core::{fix, ConfigOverrides};
|
|
|
|
fn command_available(cmd: &str) -> bool {
|
|
Command::new(cmd)
|
|
.arg("-version")
|
|
.output()
|
|
.map(|out| out.status.success())
|
|
.unwrap_or(false)
|
|
}
|
|
|
|
fn fixture_dir() -> PathBuf {
|
|
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
manifest_dir
|
|
.parent()
|
|
.expect("workspace root")
|
|
.join("tests")
|
|
.join("fixtures")
|
|
.join("generated")
|
|
}
|
|
|
|
#[test]
|
|
fn remux_fix_succeeds_on_clean_fixture() {
|
|
if !command_available("ffmpeg") || !command_available("ffprobe") {
|
|
eprintln!("ffmpeg/ffprobe not available; skipping fix test");
|
|
return;
|
|
}
|
|
|
|
let fixture = fixture_dir().join("clean.mp4");
|
|
if !fixture.exists() {
|
|
eprintln!("fixture not found: {}; skipping", fixture.display());
|
|
return;
|
|
}
|
|
|
|
let temp = tempdir().expect("tempdir");
|
|
|
|
let mut config = Config::default();
|
|
let mut overrides = ConfigOverrides::default();
|
|
overrides.output_dir = Some(temp.path().to_string_lossy().to_string());
|
|
config.apply_overrides(&overrides);
|
|
|
|
let ruleset_dir = fixture_dir()
|
|
.parent()
|
|
.unwrap()
|
|
.parent()
|
|
.unwrap()
|
|
.parent()
|
|
.unwrap()
|
|
.join("rulesets");
|
|
let ruleset = RuleSet::load_from_dir(&ruleset_dir).expect("ruleset load");
|
|
|
|
let plan = FixPlan {
|
|
policy: config.repair.policy,
|
|
recommended: Some(FixKind::Remux),
|
|
actions: vec![FixAction {
|
|
kind: FixKind::Remux,
|
|
command: Vec::new(),
|
|
destructive: true,
|
|
}],
|
|
blocked_reason: None,
|
|
};
|
|
|
|
let outcome = fix::executor::apply_fix(&fixture, &plan, &config, &ruleset)
|
|
.expect("apply fix");
|
|
|
|
assert!(outcome.success, "Expected remux to succeed");
|
|
let output_path = outcome.output_path.expect("output path");
|
|
|
|
let scan = scan_file(PathBuf::from(output_path).as_path(), &config, &ruleset)
|
|
.expect("scan output");
|
|
assert!(scan.issues.is_empty(), "Output should be clean");
|
|
}
|