Skip to content

Commit 1239325

Browse files
committed
add command_output to llvmfilecheck
1 parent ab3b00d commit 1239325

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

src/tools/run-make-support/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ pub use wasmparser;
2929
pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
3030
pub use clang::{clang, Clang};
3131
pub use diff::{diff, Diff};
32-
pub use llvm::{llvm_profdata, llvm_readobj, llvm_filecheck, LlvmProfdata, LlvmReadobj, LlvmFilecheck};
32+
pub use llvm::{
33+
llvm_filecheck, llvm_profdata, llvm_readobj, LlvmFilecheck, LlvmProfdata, LlvmReadobj,
34+
};
3335
pub use run::{cmd, run, run_fail, run_with_args};
3436
pub use rustc::{aux_build, rustc, Rustc};
3537
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};

src/tools/run-make-support/src/llvm.rs

+7-19
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use std::path::{Path, PathBuf};
2-
use std::process::{Command, Output};
3-
use std::io::{BufReader, Read, Write};
41
use std::fs::File;
2+
use std::io::{BufReader, Read, Write};
3+
use std::path::{Path, PathBuf};
54

6-
use crate::{env_var, handle_failed_output};
5+
use crate::{env_var, Command};
76

87
/// Construct a new `llvm-readobj` invocation. This assumes that `llvm-readobj` is available
98
/// at `$LLVM_BIN_DIR/llvm-readobj`.
@@ -42,11 +41,12 @@ pub struct LlvmFilecheck {
4241
}
4342

4443
crate::impl_common_helpers!(LlvmReadobj);
44+
crate::impl_common_helpers!(LlvmProfdata);
45+
crate::impl_common_helpers!(LlvmFilecheck);
4546

4647
/// Generate the path to the bin directory of LLVM.
4748
pub fn llvm_bin_dir() -> PathBuf {
48-
let llvm_bin_dir = env_var("LLVM_BIN_DIR")
49-
.expect("`LLVM_BIN_DIR` not specified, but this is required to find `llvm-readobj`");
49+
let llvm_bin_dir = env_var("LLVM_BIN_DIR");
5050
PathBuf::from(llvm_bin_dir)
5151
}
5252

@@ -70,12 +70,6 @@ impl LlvmReadobj {
7070
self.cmd.arg("--file-header");
7171
self
7272
}
73-
74-
/// Get the [`Output`][::std::process::Output] of the finished process.
75-
#[track_caller]
76-
pub fn command_output(&mut self) -> Output {
77-
self.cmd.output().expect("failed to get output of finished process")
78-
}
7973
}
8074

8175
impl LlvmProfdata {
@@ -89,13 +83,13 @@ impl LlvmProfdata {
8983

9084
/// Provide an input file.
9185
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
92-
self.cmd.arg("-o");
9386
self.cmd.arg(path.as_ref());
9487
self
9588
}
9689

9790
/// Specify the output file path.
9891
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
92+
self.cmd.arg("-o");
9993
self.cmd.arg(path.as_ref());
10094
self
10195
}
@@ -106,12 +100,6 @@ impl LlvmProfdata {
106100
self.cmd.arg("merge");
107101
self
108102
}
109-
110-
/// Get the [`Output`][::std::process::Output] of the finished process.
111-
#[track_caller]
112-
pub fn command_output(&mut self) -> Output {
113-
self.cmd.output().expect("failed to get output of finished process")
114-
}
115103
}
116104

117105
impl LlvmFilecheck {

src/tools/run-make-support/src/run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn run(name: &str) -> CompletedProcess {
5959
/// Run a built binary with one or more argument(s) and make sure it succeeds.
6060
#[track_caller]
6161
pub fn run_with_args(name: &str, args: &[&str]) -> CompletedProcess {
62-
let caller = std::panic::Location::caller();
62+
let caller = panic::Location::caller();
6363
let mut cmd = run_common(name, Some(args));
6464
let output = cmd.run();
6565
if !output.status().success() {

tests/run-make/pgo-branch-weights/rmake.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
// (This test has problems generating profdata on mingw. This could use further investigation.)
1414
//@ ignore-windows-gnu
1515

16-
use run_make_support::{llvm_filecheck, llvm_profdata, run_with_args, rustc, rustdoc, target};
16+
use run_make_support::{llvm_filecheck, llvm_profdata, run_with_args, rustc};
1717
use std::fs;
18+
use std::path::Path;
19+
20+
//FIXME(Oneirical): Edit this test to use fs_wrapper and rmake_out_path.
1821

1922
fn main() {
2023
let path_prof_data_dir = Path::new("prof_data_dir");
2124
let path_merged_profdata = path_prof_data_dir.join("merged.profdata");
2225
rustc().input("opaque.rs").run();
23-
fs::create_dir_all(&path_prof_data_dir);
26+
fs::create_dir_all(&path_prof_data_dir).unwrap();
2427
rustc()
2528
.input("interesting.rs")
2629
.profile_generate(&path_prof_data_dir)
@@ -37,5 +40,5 @@ fn main() {
3740
.codegen_units(1)
3841
.emit("llvm-ir")
3942
.run();
40-
llvm_filecheck().patterns("filecheck-patterns.txt").stdin("interesting_ll").run();
43+
llvm_filecheck().patterns("filecheck-patterns.txt").stdin("interesting.ll").run();
4144
}

0 commit comments

Comments
 (0)