aconfig: improve code diffs in tests
Implement a helper function to make it easier for unit tests to diff
(and find the first difference) generated code and expected code.
Bug: 283910447
Test: atest aconfig.test
Change-Id: I460e8fbf05e8f33e8a62ecef67b2d9d77051e876
diff --git a/tools/aconfig/src/codegen_java.rs b/tools/aconfig/src/codegen_java.rs
index 1c1cf77..dfd6766 100644
--- a/tools/aconfig/src/codegen_java.rs
+++ b/tools/aconfig/src/codegen_java.rs
@@ -135,8 +135,11 @@
let file = generate_java_code(&cache).unwrap();
assert_eq!("com/example/Flags.java", file.path.to_str().unwrap());
assert_eq!(
- expect_content.replace(' ', ""),
- String::from_utf8(file.contents).unwrap().replace(' ', "")
+ None,
+ crate::test::first_significant_code_diff(
+ expect_content,
+ &String::from_utf8(file.contents).unwrap()
+ )
);
}
}