about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com>2024-07-15 11:59:06 +0000
committer许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com>2024-07-17 12:48:22 +0000
commit88fd1df017d7652ffd82ad11cb9f63d8a660f95f (patch)
treed6f66408b9ed661c0d4cafd1415fb025cc81ae02 /src
parent56cbfa8749d18fedc0133b2f501b8d5678e89ce9 (diff)
downloadrust-88fd1df017d7652ffd82ad11cb9f63d8a660f95f.tar.gz
rust-88fd1df017d7652ffd82ad11cb9f63d8a660f95f.zip
run_make_support: move `assert_recursive_eq` into `assertion_helpers`
Diffstat (limited to 'src')
-rw-r--r--src/tools/run-make-support/src/assertion_helpers.rs28
-rw-r--r--src/tools/run-make-support/src/lib.rs27
2 files changed, 28 insertions, 27 deletions
diff --git a/src/tools/run-make-support/src/assertion_helpers.rs b/src/tools/run-make-support/src/assertion_helpers.rs
index 96f6296b304..3fdcc94a034 100644
--- a/src/tools/run-make-support/src/assertion_helpers.rs
+++ b/src/tools/run-make-support/src/assertion_helpers.rs
@@ -1,8 +1,9 @@
 //! Collection of assertions and assertion-related helpers.
 
-use std::path::{Path, PathBuf};
 use std::panic;
+use std::path::{Path, PathBuf};
 
+use crate::fs_helpers;
 use crate::fs_wrapper;
 use crate::path_helpers::cwd;
 
@@ -140,3 +141,28 @@ pub fn assert_not_contains<H: AsRef<str>, N: AsRef<str>>(haystack: H, needle: N)
         panic!("needle was unexpectedly found in haystack");
     }
 }
+
+/// Assert that all files in `dir1` exist and have the same content in `dir2`
+pub fn assert_recursive_eq(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) {
+    let dir2 = dir2.as_ref();
+    fs_helpers::read_dir(dir1, |entry_path| {
+        let entry_name = entry_path.file_name().unwrap();
+        if entry_path.is_dir() {
+            assert_recursive_eq(&entry_path, &dir2.join(entry_name));
+        } else {
+            let path2 = dir2.join(entry_name);
+            let file1 = fs_wrapper::read(&entry_path);
+            let file2 = fs_wrapper::read(&path2);
+
+            // We don't use `assert_eq!` because they are `Vec<u8>`, so not great for display.
+            // Why not using String? Because there might be minified files or even potentially
+            // binary ones, so that would display useless output.
+            assert!(
+                file1 == file2,
+                "`{}` and `{}` have different content",
+                entry_path.display(),
+                path2.display(),
+            );
+        }
+    });
+}
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index 1a2a648c47a..658b6cc3559 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -78,7 +78,7 @@ pub use fs_helpers::{copy_dir_all, create_symlink, read_dir};
 pub use scoped_run::{run_in_tmpdir, test_while_readonly};
 
 pub use assertion_helpers::{
-    assert_contains, assert_equals, assert_not_contains,
+    assert_contains, assert_equals, assert_not_contains, assert_recursive_eq,
     count_regex_matches_in_files_with_extension, filename_not_in_denylist, has_extension,
     has_prefix, has_suffix, invalid_utf8_contains, invalid_utf8_not_contains, not_contains,
     shallow_find_files,
@@ -136,28 +136,3 @@ pub fn set_host_rpath(cmd: &mut Command) {
         std::env::join_paths(paths.iter()).unwrap()
     });
 }
-
-/// Assert that all files in `dir1` exist and have the same content in `dir2`
-pub fn assert_recursive_eq(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) {
-    let dir2 = dir2.as_ref();
-    read_dir(dir1, |entry_path| {
-        let entry_name = entry_path.file_name().unwrap();
-        if entry_path.is_dir() {
-            assert_recursive_eq(&entry_path, &dir2.join(entry_name));
-        } else {
-            let path2 = dir2.join(entry_name);
-            let file1 = fs_wrapper::read(&entry_path);
-            let file2 = fs_wrapper::read(&path2);
-
-            // We don't use `assert_eq!` because they are `Vec<u8>`, so not great for display.
-            // Why not using String? Because there might be minified files or even potentially
-            // binary ones, so that would display useless output.
-            assert!(
-                file1 == file2,
-                "`{}` and `{}` have different content",
-                entry_path.display(),
-                path2.display(),
-            );
-        }
-    });
-}