Skip to content

Commit 46b3886

Browse files
committed
add command_output to llvmfilecheck
1 parent a5f37b9 commit 46b3886

6 files changed

Lines changed: 18 additions & 25 deletions

File tree

src/tools/cargo

Submodule cargo updated 91 files

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ pub use wasmparser;
2626
pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
2727
pub use clang::{clang, Clang};
2828
pub use diff::{diff, Diff};
29-
pub use llvm::{llvm_profdata, llvm_readobj, llvm_filecheck, LlvmProfdata, LlvmReadobj, LlvmFilecheck};
29+
pub use llvm::{
30+
llvm_filecheck, llvm_profdata, llvm_readobj, LlvmFilecheck, LlvmProfdata, LlvmReadobj,
31+
};
3032
pub use run::{cmd, run, run_fail, run_with_args};
3133
pub use rustc::{aux_build, rustc, Rustc};
3234
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};

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

Lines changed: 7 additions & 19 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn run(name: &str) -> CompletedProcess {
5858

5959
/// Run a built binary with one or more argument(s) and make sure it succeeds.
6060
#[track_caller]
61-
pub fn run_with_args(name: &str, args: &[&str]) -> Output {
61+
pub fn run_with_args(name: &str, args: &[&str]) -> CompletedProcess {
6262
let caller_location = std::panic::Location::caller();
6363
let caller_line_number = caller_location.line();
6464

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

Lines changed: 5 additions & 2 deletions
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)

0 commit comments

Comments
 (0)