Add exact saved-project comparison for native Arrange checks
This commit is contained in:
@@ -208,10 +208,27 @@ fn source_bytes(p: &Project) -> Vec<u8> {
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut args = std::env::args_os().skip(1);
|
||||
let output = PathBuf::from(
|
||||
args.next()
|
||||
.ok_or("Usage: arrange_reset_native_probe NEW_DIRECTORY")?,
|
||||
);
|
||||
let first = args.next().ok_or(
|
||||
"Usage: arrange_reset_native_probe NEW_DIRECTORY | --compare ACTUAL EXPECTED",
|
||||
)?;
|
||||
if first == "--compare" {
|
||||
let actual_path = args.next().ok_or("Missing ACTUAL path")?;
|
||||
let expected_path = args.next().ok_or("Missing EXPECTED path")?;
|
||||
if args.next().is_some() {
|
||||
return Err("Unexpected comparison argument".into());
|
||||
}
|
||||
let actual = persistence::decode(&fs::read(actual_path)?)?;
|
||||
let expected = persistence::decode(&fs::read(expected_path)?)?;
|
||||
let equal = actual == expected;
|
||||
println!("{}", json!({"complete_project_equal": equal,
|
||||
"actual_diagrams": actual.diagrams.len(),
|
||||
"expected_diagrams": expected.diagrams.len()}));
|
||||
if !equal {
|
||||
return Err("Complete typed Projects differ".into());
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
let output = PathBuf::from(first);
|
||||
if args.next().is_some() || output.exists() {
|
||||
return Err("Require exactly one output directory that does not already exist".into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user