about summary refs log tree commit diff
diff options
context:
space:
mode:
authorIgor Aleksanov <popzxc@yandex.ru>2019-10-17 19:21:05 +0300
committerIgor Aleksanov <popzxc@yandex.ru>2019-10-17 19:37:01 +0300
commitcb5733de868600aab889730effe4077641a46981 (patch)
tree7ebc1dc83eecca0167f809e5d3ab882d929fa3c7
parent85628e80637cf21caa9d6fef31d9fed53e7156aa (diff)
downloadrust-cb5733de868600aab889730effe4077641a46981.tar.gz
rust-cb5733de868600aab889730effe4077641a46981.zip
Improve code style
-rw-r--r--src/libtest/cli.rs6
-rw-r--r--src/libtest/event.rs7
-rw-r--r--src/libtest/formatters/json.rs3
-rw-r--r--src/libtest/formatters/terse.rs4
-rw-r--r--src/libtest/helpers/isatty.rs2
-rw-r--r--src/libtest/lib.rs12
-rw-r--r--src/libtest/test_result.rs9
-rw-r--r--src/libtest/tests.rs15
-rw-r--r--src/libtest/time.rs4
9 files changed, 41 insertions, 21 deletions
diff --git a/src/libtest/cli.rs b/src/libtest/cli.rs
index 0c47bc8ae94..f95d5aad18a 100644
--- a/src/libtest/cli.rs
+++ b/src/libtest/cli.rs
@@ -329,7 +329,11 @@ fn get_test_threads(matches: &getopts::Matches) -> OptPartRes<Option<usize>> {
     Ok(test_threads)
 }
 
-fn get_format(matches: &getopts::Matches, quiet: bool, allow_unstable: bool) -> OptPartRes<OutputFormat> {
+fn get_format(
+    matches: &getopts::Matches,
+    quiet: bool,
+    allow_unstable: bool
+) -> OptPartRes<OutputFormat> {
     let format = match matches.opt_str("format").as_ref().map(|s| &**s) {
         None if quiet => OutputFormat::Terse,
         Some("pretty") | None => OutputFormat::Pretty,
diff --git a/src/libtest/event.rs b/src/libtest/event.rs
index e1b606149c5..eefbd2d6a81 100644
--- a/src/libtest/event.rs
+++ b/src/libtest/event.rs
@@ -14,7 +14,12 @@ pub struct CompletedTest {
 }
 
 impl CompletedTest {
-    pub fn new(desc: TestDesc, result: TestResult, exec_time: Option<TestExecTime>, stdout: Vec<u8>) -> Self {
+    pub fn new(
+        desc: TestDesc,
+        result: TestResult,
+        exec_time: Option<TestExecTime>,
+        stdout: Vec<u8>
+    ) -> Self {
         Self {
             desc,
             result,
diff --git a/src/libtest/formatters/json.rs b/src/libtest/formatters/json.rs
index fc677036dab..b73d7349678 100644
--- a/src/libtest/formatters/json.rs
+++ b/src/libtest/formatters/json.rs
@@ -92,7 +92,8 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
         stdout: &[u8],
         state: &ConsoleTestState,
     ) -> io::Result<()> {
-        let stdout = if (state.options.display_output || *result != TestResult::TrOk) && stdout.len() > 0 {
+        let display_stdout = state.options.display_output || *result != TestResult::TrOk;
+        let stdout = if display_stdout && stdout.len() > 0 {
             Some(String::from_utf8_lossy(stdout))
         } else {
             None
diff --git a/src/libtest/formatters/terse.rs b/src/libtest/formatters/terse.rs
index 90eb62251fb..fe56157d9c1 100644
--- a/src/libtest/formatters/terse.rs
+++ b/src/libtest/formatters/terse.rs
@@ -196,7 +196,9 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
     ) -> io::Result<()> {
         match *result {
             TestResult::TrOk => self.write_ok(),
-            TestResult::TrFailed | TestResult::TrFailedMsg(_) | TestResult::TrTimedFail => self.write_failed(),
+            TestResult::TrFailed
+                | TestResult::TrFailedMsg(_)
+                | TestResult::TrTimedFail => self.write_failed(),
             TestResult::TrIgnored => self.write_ignored(),
             TestResult::TrAllowedFail => self.write_allowed_fail(),
             TestResult::TrBench(ref bs) => {
diff --git a/src/libtest/helpers/isatty.rs b/src/libtest/helpers/isatty.rs
index 638328aea18..6e4954778e6 100644
--- a/src/libtest/helpers/isatty.rs
+++ b/src/libtest/helpers/isatty.rs
@@ -30,4 +30,4 @@ pub fn stdout_isatty() -> bool {
         let mut out = 0;
         GetConsoleMode(handle, &mut out) != 0
     }
-}
\ No newline at end of file
+}
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 31da97b736a..89f527b6bd7 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -46,8 +46,8 @@ pub mod test {
         test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk},
         time::{TestTimeOptions, TestExecTime},
         types::{
-            DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, TestDescAndFn,
-            TestName, TestType,
+            DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName,
+            TestDesc, TestDescAndFn, TestName, TestType,
         },
         assert_test_result, filter_tests, run_test, test_main, test_main_static,
     };
@@ -199,7 +199,11 @@ pub fn assert_test_result<T: Termination>(result: T) {
     );
 }
 
-pub fn run_tests<F>(opts: &TestOpts, tests: Vec<TestDescAndFn>, mut notify_about_test_event: F) -> io::Result<()>
+pub fn run_tests<F>(
+    opts: &TestOpts,
+    tests: Vec<TestDescAndFn>,
+    mut notify_about_test_event: F
+) -> io::Result<()>
 where
     F: FnMut(TestEvent) -> io::Result<()>,
 {
@@ -325,7 +329,7 @@ where
                         _ => {
                             // We've got a result, stop the loop.
                             break;
-                        }            
+                        }
                     }
                 } else {
                     res = rx.recv().map_err(|_| RecvTimeoutError::Disconnected);
diff --git a/src/libtest/test_result.rs b/src/libtest/test_result.rs
index dd4dfd9997f..80ca9dea18f 100644
--- a/src/libtest/test_result.rs
+++ b/src/libtest/test_result.rs
@@ -1,4 +1,3 @@
-
 use std::any::Any;
 
 use super::bench::BenchSamples;
@@ -50,11 +49,15 @@ pub fn calc_result<'a>(
                 if desc.allow_fail {
                     TestResult::TrAllowedFail
                 } else {
-                    TestResult::TrFailedMsg(format!("panic did not include expected string '{}'", msg))
+                    TestResult::TrFailedMsg(
+                        format!("panic did not include expected string '{}'", msg)
+                    )
                 }
             }
         }
-        (&ShouldPanic::Yes, Ok(())) => TestResult::TrFailedMsg("test did not panic as expected".to_string()),
+        (&ShouldPanic::Yes, Ok(())) => {
+            TestResult::TrFailedMsg("test did not panic as expected".to_string())
+        }
         _ if desc.allow_fail => TestResult::TrAllowedFail,
         _ => TestResult::TrFailed,
     };
diff --git a/src/libtest/tests.rs b/src/libtest/tests.rs
index f6470b40a39..9de774555e9 100644
--- a/src/libtest/tests.rs
+++ b/src/libtest/tests.rs
@@ -7,11 +7,12 @@ use crate::{
     time::{TimeThreshold, TestTimeOptions},
     formatters::PrettyFormatter,
     test::{
-        filter_tests, parse_opts, run_test, DynTestFn, DynTestName, MetricMap, RunIgnored, RunStrategy,
+        filter_tests, parse_opts, run_test, DynTestFn, DynTestName, MetricMap,
+        RunIgnored, RunStrategy, ShouldPanic, StaticTestName, TestDesc,
+        TestDescAndFn, TestOpts, TrIgnored, TrOk,
+        // FIXME (introduced by #65251)
         // ShouldPanic, StaticTestName, TestDesc, TestDescAndFn, TestOpts, TestTimeOptions,
         // TestType, TrFailedMsg, TrIgnored, TrOk,
-        ShouldPanic, StaticTestName, TestDesc, TestDescAndFn, TestOpts,
-        TrIgnored, TrOk,
     },
 };
 use std::sync::mpsc::channel;
@@ -104,7 +105,7 @@ pub fn ignored_tests_result_in_ignored() {
     assert!(result == TrIgnored);
 }
 
-// FIXME: Re-enable emscripten once it can catch panics again
+// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251)
 #[test]
 #[cfg(not(target_os = "emscripten"))]
 fn test_should_panic() {
@@ -127,7 +128,7 @@ fn test_should_panic() {
     assert!(result == TrOk);
 }
 
-// FIXME: Re-enable emscripten once it can catch panics again
+// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251)
 #[test]
 #[cfg(not(target_os = "emscripten"))]
 fn test_should_panic_good_message() {
@@ -150,7 +151,7 @@ fn test_should_panic_good_message() {
     assert!(result == TrOk);
 }
 
-// FIXME: Re-enable emscripten once it can catch panics again
+// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251)
 #[test]
 #[cfg(not(target_os = "emscripten"))]
 fn test_should_panic_bad_message() {
@@ -176,7 +177,7 @@ fn test_should_panic_bad_message() {
     assert!(result == TrFailedMsg(format!("{} '{}'", failed_msg, expected)));
 }
 
-// FIXME: Re-enable emscripten once it can catch panics again
+// FIXME: Re-enable emscripten once it can catch panics again (introduced by #65251)
 #[test]
 #[cfg(not(target_os = "emscripten"))]
 fn test_should_panic_but_succeeds() {
diff --git a/src/libtest/time.rs b/src/libtest/time.rs
index 83a545470ef..f4d4b17b620 100644
--- a/src/libtest/time.rs
+++ b/src/libtest/time.rs
@@ -2,7 +2,7 @@
 //! execution.
 //! Two main purposes of this module:
 //! - Check whether test is timed out.
-//! - Provide helpers for `report-time` and `measure-time` options. 
+//! - Provide helpers for `report-time` and `measure-time` options.
 
 use std::time::{Duration, Instant};
 use std::str::FromStr;
@@ -55,7 +55,7 @@ pub mod time_constants {
 }
 
 /// Returns an `Instance` object denoting when the test should be considered
-/// timed out. 
+/// timed out.
 pub fn get_default_test_timeout() -> Instant {
     Instant::now() + Duration::from_secs(TEST_WARN_TIMEOUT_S)
 }