diff --git a/Cargo.toml b/Cargo.toml index d339aa8..99e3770 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ zerocopy = "0.8.13" zstd = "0.13.2" [dev-dependencies] +similar-asserts = "1.6.0" [profile.dev.package.sha2] # this is *really* slow otherwise diff --git a/src/bin/composefs-pivot-sysroot.rs b/src/bin/composefs-pivot-sysroot.rs index 3814e9d..473de69 100644 --- a/src/bin/composefs-pivot-sysroot.rs +++ b/src/bin/composefs-pivot-sysroot.rs @@ -33,7 +33,7 @@ fn test_parse() { } let digest = "8b7df143d91c716ecfa5fc1730022f6b421b05cedee8fd52b1fc65a96030ad52"; let digest_bytes = hex::decode(digest).unwrap(); - assert_eq!( + similar_asserts::assert_eq!( parse_composefs_cmdline(format!("composefs={digest}").as_bytes()) .unwrap() .as_slice(), diff --git a/src/dumpfile_parse.rs b/src/dumpfile_parse.rs index d367560..ea5e18d 100644 --- a/src/dumpfile_parse.rs +++ b/src/dumpfile_parse.rs @@ -784,15 +784,15 @@ mod tests { #[test] fn test_xattr() { let v = Xattr::parse("foo=bar").unwrap(); - assert_eq!(v.key.as_bytes(), b"foo"); - assert_eq!(&*v.value, b"bar"); + similar_asserts::assert_eq!(v.key.as_bytes(), b"foo"); + similar_asserts::assert_eq!(&*v.value, b"bar"); // Invalid embedded NUL in keys assert!(Xattr::parse("foo\0bar=baz").is_err()); assert!(Xattr::parse("foo\x00bar=baz").is_err()); // But embedded NUL in values is OK let v = Xattr::parse("security.selinux=bar\x00").unwrap(); - assert_eq!(v.key.as_bytes(), b"security.selinux"); - assert_eq!(&*v.value, b"bar\0"); + similar_asserts::assert_eq!(v.key.as_bytes(), b"security.selinux"); + similar_asserts::assert_eq!(&*v.value, b"bar\0"); } #[test] @@ -829,9 +829,9 @@ mod tests { if line != serialized { dbg!(&line, &e, &serialized); } - assert_eq!(line, serialized); + similar_asserts::assert_eq!(line, serialized); let e2 = Entry::parse(&serialized).unwrap(); - assert_eq!(e, e2); + similar_asserts::assert_eq!(e, e2); } } @@ -875,7 +875,7 @@ mod tests { Ok(()) }) .unwrap(); - assert_eq!(SPECIAL_DUMP, &entries); + similar_asserts::assert_eq!(SPECIAL_DUMP, &entries); Ok(()) } diff --git a/src/fsverity/digest.rs b/src/fsverity/digest.rs index c12531d..241dd92 100644 --- a/src/fsverity/digest.rs +++ b/src/fsverity/digest.rs @@ -157,7 +157,7 @@ mod tests { #[test] fn test_digest() -> Result<()> { let digest = FsVerityHasher::hash(b"hello world"); - assert_eq!( + similar_asserts::assert_eq!( digest, [ 30, 46, 170, 66, 2, 215, 80, 164, 17, 116, 238, 69, 73, 112, 185, 44, 27, 194, 249, diff --git a/src/oci/image.rs b/src/oci/image.rs index ffec4e9..0358f6f 100644 --- a/src/oci/image.rs +++ b/src/oci/image.rs @@ -149,7 +149,7 @@ fn assert_files(fs: &FileSystem, expected: &[&str]) -> Result<()> { .map(|line| line.unwrap().split_once(' ').unwrap().0.into()) .collect(); - assert_eq!(actual, expected); + similar_asserts::assert_eq!(actual, expected); Ok(()) } diff --git a/tests/repo.rs b/tests/repo.rs index f5c2881..c4e0d3b 100644 --- a/tests/repo.rs +++ b/tests/repo.rs @@ -53,7 +53,7 @@ fn test_layer() -> Result<()> { while let Some(entry) = oci::tar::get_entry(&mut split_stream)? { writeln!(dump, "{}", entry)?; } - assert_eq!(dump, "\ + similar_asserts::assert_eq!(dump, "\ /file0 0 100700 1 0 0 0 0.0 - - - /file4095 4095 100700 1 0 0 0 0.0 53/72beb83c78537c8970c8361e3254119fafdf1763854ecd57d3f0fe2da7c719 - 5372beb83c78537c8970c8361e3254119fafdf1763854ecd57d3f0fe2da7c719 /file4096 4096 100700 1 0 0 0 0.0 ba/bc284ee4ffe7f449377fbf6692715b43aec7bc39c094a95878904d34bac97e - babc284ee4ffe7f449377fbf6692715b43aec7bc39c094a95878904d34bac97e