]> git.proxmox.com Git - cargo.git/commitdiff
forward --quiet flag only if harness=true
authorCollins Abitekaniza <abtcolns@gmail.com>
Thu, 21 Feb 2019 13:41:05 +0000 (16:41 +0300)
committerCollins Abitekaniza <abtcolns@gmail.com>
Mon, 11 Mar 2019 00:01:56 +0000 (03:01 +0300)
src/bin/cargo/commands/test.rs
src/cargo/core/compiler/compilation.rs
src/cargo/core/compiler/context/mod.rs
src/cargo/ops/cargo_test.rs

index b2cff39b048765232e5760afa9ba36e045a9e242..852ddc65b835580854766db25e6a51f07e729726 100644 (file)
@@ -144,10 +144,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
             .map(|s| s.to_string()),
     );
 
-    if args.is_present("quiet") {
-        test_args.push("-q".to_string())
-    }
-
     let err = ops::run_tests(&ws, &ops, &test_args)?;
     match err {
         None => Ok(()),
index 863affc7cfe0446856c383d9f128b43a57abf5fe..afe2c9e4859b33bc31722c9e639fbc9172c3e9b8 100644 (file)
@@ -6,7 +6,7 @@ use std::path::PathBuf;
 use semver::Version;
 
 use super::BuildContext;
-use crate::core::{Edition, Package, PackageId, Target, TargetKind};
+use crate::core::{Edition, Package, PackageId, Target};
 use crate::util::{self, join_paths, process, CargoResult, CfgExpr, Config, ProcessBuilder};
 
 pub struct Doctest {
@@ -22,7 +22,7 @@ pub struct Doctest {
 /// A structure returning the result of a compilation.
 pub struct Compilation<'cfg> {
     /// An array of all tests created during this compilation.
-    pub tests: Vec<(Package, TargetKind, String, PathBuf)>,
+    pub tests: Vec<(Package, Target, PathBuf)>,
 
     /// An array of all binaries created.
     pub binaries: Vec<PathBuf>,
index 27f8adb2068b41c3bec677117000de2cb661efa1..650e7d2f552a57a57800d64612ead81a05348915 100644 (file)
@@ -167,8 +167,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
                 if unit.mode == CompileMode::Test {
                     self.compilation.tests.push((
                         unit.pkg.clone(),
-                        unit.target.kind().clone(),
-                        unit.target.name().to_string(),
+                        unit.target.clone(),
                         output.path.clone(),
                     ));
                 } else if unit.target.is_bin() || unit.target.is_bin_example() {
index d335a80a80035270091565b905e52717cf57be23..210da9879e4d9ec536c2efab525f75641d5e8179 100644 (file)
@@ -2,6 +2,7 @@ use std::ffi::OsString;
 
 use crate::core::compiler::{Compilation, Doctest};
 use crate::core::Workspace;
+use crate::core::shell::Verbosity;
 use crate::ops;
 use crate::util::errors::CargoResult;
 use crate::util::{CargoTestError, ProcessError, Test};
@@ -80,10 +81,15 @@ fn run_unit_tests(
 
     let mut errors = Vec::new();
 
-    for &(ref pkg, ref kind, ref test, ref exe) in &compilation.tests {
+    for &(ref pkg, ref target, ref exe) in &compilation.tests {
+        let kind = target.kind();
+        let test = target.name().to_string();
         let exe_display = exe.strip_prefix(cwd).unwrap_or(exe).display();
         let mut cmd = compilation.target_process(exe, pkg)?;
         cmd.args(test_args);
+        if target.harness() && config.shell().verbosity() == Verbosity::Quiet {
+            cmd.arg("--quiet");
+        }
         config
             .shell()
             .concise(|shell| shell.status("Running", &exe_display))?;