about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/run-make-support/src/lib.rs1
-rw-r--r--tests/run-make/pgo-gen/rmake.rs12
-rw-r--r--tests/run-make/pgo-use/rmake.rs27
3 files changed, 21 insertions, 19 deletions
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index 6c1bcc6d7cd..af5ae6a8e60 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -272,6 +272,7 @@ pub fn shallow_find_files<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
     for entry in fs_wrapper::read_dir(path) {
         let entry = entry.expect("failed to read directory entry.");
         let path = entry.path();
+
         if path.is_file() && closure(&path) {
             matching_files.push(path);
         }
diff --git a/tests/run-make/pgo-gen/rmake.rs b/tests/run-make/pgo-gen/rmake.rs
index d35b2930264..ad2f6388e8f 100644
--- a/tests/run-make/pgo-gen/rmake.rs
+++ b/tests/run-make/pgo-gen/rmake.rs
@@ -6,13 +6,13 @@
 //@ needs-profiler-support
 //@ ignore-cross-compile
 
-use run_make_support::{cwd, find_files_by_prefix_and_extension, run, rustc};
+use run_make_support::{cwd, has_extension, has_prefix, run, rustc, shallow_find_files};
 
 fn main() {
-    rustc().arg("-g").profile_generate(cwd()).run();
+    rustc().arg("-g").profile_generate(cwd()).input("test.rs").run();
     run("test");
-    assert!(
-        find_files_by_prefix_and_extension(cwd(), "default", "profraw").len() > 0,
-        "no .profraw file generated"
-    );
+    let profraw_files = shallow_find_files(cwd(), |path| {
+        has_prefix(path, "default") && has_extension(path, "profraw")
+    });
+    assert!(!profraw_files.is_empty(), "no .profraw file generated");
 }
diff --git a/tests/run-make/pgo-use/rmake.rs b/tests/run-make/pgo-use/rmake.rs
index 04777821b51..0f76aff80d0 100644
--- a/tests/run-make/pgo-use/rmake.rs
+++ b/tests/run-make/pgo-use/rmake.rs
@@ -9,8 +9,8 @@
 //@ ignore-cross-compile
 
 use run_make_support::{
-    cwd, find_files_by_prefix_and_extension, fs_wrapper, llvm_filecheck, llvm_profdata,
-    run_with_args, rustc,
+    cwd, fs_wrapper, has_extension, has_prefix, llvm_filecheck, llvm_profdata, run_with_args,
+    rustc, shallow_find_files,
 };
 
 fn main() {
@@ -28,11 +28,11 @@ fn main() {
     // Run it in order to generate some profiling data
     run_with_args("main", &["some-argument"]);
     // Postprocess the profiling data so it can be used by the compiler
-    llvm_profdata()
-        .merge()
-        .output("merged.profdata")
-        .input(find_files_by_prefix_and_extension(cwd(), "default", "profraw").get(0).unwrap())
-        .run();
+    let profraw_files = shallow_find_files(cwd(), |path| {
+        has_prefix(path, "default") && has_extension(path, "profraw")
+    });
+    let profraw_file = profraw_files.get(0).unwrap();
+    llvm_profdata().merge().output("merged.profdata").input(profraw_file).run();
     // Compile the test program again, making use of the profiling data
     rustc()
         .opt_level("2")
@@ -42,13 +42,14 @@ fn main() {
         .emit("llvm-ir")
         .input("main.rs")
         .run();
-    // Check that the generate IR contains some things that we expect
-    //
-    // We feed the file into LLVM FileCheck tool *in reverse* so that we see the
+    // Check that the generate IR contains some things that we expect.
+    // We feed the file into LLVM FileCheck tool *with its lines reversed* so that we see the
     // line with the function name before the line with the function attributes.
     // FileCheck only supports checking that something matches on the next line,
     // but not if something matches on the previous line.
-    let mut bytes = fs_wrapper::read("interesting.ll");
-    bytes.reverse();
-    llvm_filecheck().patterns("filecheck-patterns.txt").stdin(bytes).run();
+    let ir = fs_wrapper::read_to_string("main.ll");
+    let lines: Vec<_> = ir.lines().rev().collect();
+    let mut reversed_ir = lines.join("\n");
+    reversed_ir.push('\n');
+    llvm_filecheck().patterns("filecheck-patterns.txt").stdin(reversed_ir.as_bytes()).run();
 }