Skip to content

Commit 805acff

Browse files
committed
forward --quiet flag only if harness=true
1 parent e873e4e commit 805acff

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/bin/cargo/commands/test.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
144144
.map(|s| s.to_string()),
145145
);
146146

147-
if args.is_present("quiet") {
148-
test_args.push("-q".to_string())
149-
}
150-
151147
let err = ops::run_tests(&ws, &ops, &test_args)?;
152148
match err {
153149
None => Ok(()),

src/cargo/core/compiler/compilation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::path::PathBuf;
66
use semver::Version;
77

88
use super::BuildContext;
9-
use crate::core::{Edition, Package, PackageId, Target, TargetKind};
9+
use crate::core::{Edition, Package, PackageId, Target};
1010
use crate::util::{self, join_paths, process, CargoResult, CfgExpr, Config, ProcessBuilder};
1111

1212
pub struct Doctest {
@@ -22,7 +22,7 @@ pub struct Doctest {
2222
/// A structure returning the result of a compilation.
2323
pub struct Compilation<'cfg> {
2424
/// An array of all tests created during this compilation.
25-
pub tests: Vec<(Package, TargetKind, String, PathBuf)>,
25+
pub tests: Vec<(Package, Target, PathBuf)>,
2626

2727
/// An array of all binaries created.
2828
pub binaries: Vec<PathBuf>,

src/cargo/core/compiler/context/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
167167
if unit.mode == CompileMode::Test {
168168
self.compilation.tests.push((
169169
unit.pkg.clone(),
170-
unit.target.kind().clone(),
171-
unit.target.name().to_string(),
170+
unit.target.clone(),
172171
output.path.clone(),
173172
));
174173
} else if unit.target.is_bin() || unit.target.is_bin_example() {

src/cargo/ops/cargo_test.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::ffi::OsString;
22

33
use crate::core::compiler::{Compilation, Doctest};
44
use crate::core::Workspace;
5+
use crate::core::shell::Verbosity;
56
use crate::ops;
67
use crate::util::errors::CargoResult;
78
use crate::util::{CargoTestError, ProcessError, Test};
@@ -80,10 +81,15 @@ fn run_unit_tests(
8081

8182
let mut errors = Vec::new();
8283

83-
for &(ref pkg, ref kind, ref test, ref exe) in &compilation.tests {
84+
for &(ref pkg, ref target, ref exe) in &compilation.tests {
85+
let kind = target.kind();
86+
let test = target.name().to_string();
8487
let exe_display = exe.strip_prefix(cwd).unwrap_or(exe).display();
8588
let mut cmd = compilation.target_process(exe, pkg)?;
8689
cmd.args(test_args);
90+
if target.harness() && config.shell().verbosity() == Verbosity::Quiet {
91+
cmd.arg("--quiet");
92+
}
8793
config
8894
.shell()
8995
.concise(|shell| shell.status("Running", &exe_display))?;

0 commit comments

Comments
 (0)