Skip to content

Commit 47b6f9c

Browse files
committed
Reuse the command output helper
makes the output consistent and simplifies the code
1 parent 57ef8f5 commit 47b6f9c

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

src/aux_builds.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use crate::{
55
build_manager::{Build, BuildManager},
6+
core::run_command,
67
custom_flags::Flag,
78
default_per_file_config, display,
89
per_test_config::{Comments, TestConfig},
@@ -122,7 +123,7 @@ impl Build for AuxBuilder {
122123

123124
aux_cmd.arg("--emit=link");
124125
let filename = self.aux_file.file_stem().unwrap().to_str().unwrap();
125-
let output = aux_cmd.output().unwrap();
126+
let output = run_command(&mut aux_cmd)?;
126127
if !output.status.success() {
127128
let error = Error::Command {
128129
kind: "compilation of aux build failed".to_string(),
@@ -138,7 +139,7 @@ impl Build for AuxBuilder {
138139

139140
// Now run the command again to fetch the output filenames
140141
aux_cmd.arg("--print").arg("file-names");
141-
let output = aux_cmd.output().unwrap();
142+
let output = run_command(&mut aux_cmd)?;
142143

143144
if build_manager.aborted() {
144145
return Err(Errored::aborted());

src/dependencies.rs

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::{
44
build_manager::{Build, BuildManager},
5+
core::run_command,
56
custom_flags::Flag,
67
per_test_config::TestConfig,
78
test_result::Errored,
@@ -37,17 +38,7 @@ fn cfgs(config: &Config) -> Result<Vec<Cfg>, Errored> {
3738
let mut cmd = config.program.build(&config.out_dir);
3839
cmd.arg(cfg);
3940
cmd.arg("--target").arg(config.target.as_ref().unwrap());
40-
let output = match cmd.output() {
41-
Ok(o) => o,
42-
Err(e) => {
43-
return Err(Errored {
44-
command: format!("{cmd:?}"),
45-
stderr: e.to_string().into_bytes(),
46-
stdout: vec![],
47-
errors: vec![],
48-
})
49-
}
50-
};
41+
let output = run_command(&mut cmd)?;
5142

5243
if !output.status.success() {
5344
return Err(Errored {
@@ -106,17 +97,7 @@ fn build_dependencies_inner(
10697

10798
build.arg("--message-format=json");
10899

109-
let output = match build.output() {
110-
Err(e) => {
111-
return Err(Errored {
112-
command: format!("{build:?}"),
113-
stderr: e.to_string().into_bytes(),
114-
stdout: vec![],
115-
errors: vec![],
116-
})
117-
}
118-
Ok(o) => o,
119-
};
100+
let output = run_command(&mut build)?;
120101

121102
if !output.status.success() {
122103
let stdout = output
@@ -212,17 +193,7 @@ fn build_dependencies_inner(
212193
.arg(&info.crate_manifest_path);
213194
info.program.apply_env(&mut metadata);
214195
set_locking(&mut metadata);
215-
let output = match metadata.output() {
216-
Err(e) => {
217-
return Err(Errored {
218-
command: format!("{metadata:?}"),
219-
errors: vec![],
220-
stderr: e.to_string().into_bytes(),
221-
stdout: vec![],
222-
})
223-
}
224-
Ok(output) => output,
225-
};
196+
let output = run_command(&mut metadata)?;
226197

227198
if !output.status.success() {
228199
return Err(Errored {

0 commit comments

Comments
 (0)