]> git.lizzy.rs Git - rust.git/blobdiff - src/libtest/formatters/terse.rs
Rollup merge of #67531 - RalfJung:tame-promotion, r=nikomatsakis
[rust.git] / src / libtest / formatters / terse.rs
index 96203d5ea42794766ae35d80617f974e2fcf4345..5a264d2005744cb54faeef7c8fcbb8a8ebb34b9c 100644 (file)
@@ -1,5 +1,17 @@
-use super::*;
-use super::console::{ConsoleTestState, OutputLocation};
+use std::{io, io::prelude::Write};
+
+use super::OutputFormatter;
+use crate::{
+    bench::fmt_bench_samples,
+    console::{ConsoleTestState, OutputLocation},
+    test_result::TestResult,
+    time,
+    types::NamePadding,
+    types::TestDesc,
+};
+
+// insert a '\n' after 100 tests in quiet mode
+const QUIET_MODE_MAX_COLUMN: usize = 100;
 
 pub(crate) struct TerseFormatter<T> {
     out: OutputLocation<T>,
@@ -59,7 +71,7 @@ pub fn write_short_result(
             // we insert a new line every 100 dots in order to flush the
             // screen when dealing with line-buffered output (e.g., piping to
             // `stamp` in the rust CI).
-            let out = format!(" {}/{}\n", self.test_count+1, self.total_test_count);
+            let out = format!(" {}/{}\n", self.test_count + 1, self.total_test_count);
             self.write_plain(&out)?;
         }
 
@@ -164,7 +176,7 @@ fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> {
         // in order to indicate benchmarks.
         // When running benchmarks, terse-mode should still print their name as if
         // it is the Pretty formatter.
-        if !self.is_multithreaded && desc.name.padding() == PadOnRight {
+        if !self.is_multithreaded && desc.name.padding() == NamePadding::PadOnRight {
             self.write_test_name(desc)?;
         }
 
@@ -180,11 +192,13 @@ fn write_result(
         _: &ConsoleTestState,
     ) -> io::Result<()> {
         match *result {
-            TrOk => self.write_ok(),
-            TrFailed | TrFailedMsg(_) | TrTimedFail => self.write_failed(),
-            TrIgnored => self.write_ignored(),
-            TrAllowedFail => self.write_allowed_fail(),
-            TrBench(ref bs) => {
+            TestResult::TrOk => self.write_ok(),
+            TestResult::TrFailed | TestResult::TrFailedMsg(_) | TestResult::TrTimedFail => {
+                self.write_failed()
+            }
+            TestResult::TrIgnored => self.write_ignored(),
+            TestResult::TrAllowedFail => self.write_allowed_fail(),
+            TestResult::TrBench(ref bs) => {
                 if self.is_multithreaded {
                     self.write_test_name(desc)?;
                 }
@@ -197,7 +211,8 @@ fn write_result(
     fn write_timeout(&mut self, desc: &TestDesc) -> io::Result<()> {
         self.write_plain(&format!(
             "test {} has been running for over {} seconds\n",
-            desc.name, time::TEST_WARN_TIMEOUT_S
+            desc.name,
+            time::TEST_WARN_TIMEOUT_S
         ))
     }