about summary refs log tree commit diff
path: root/src/libtest
diff options
context:
space:
mode:
Diffstat (limited to 'src/libtest')
-rw-r--r--src/libtest/cli.rs6
-rw-r--r--src/libtest/console.rs2
-rw-r--r--src/libtest/formatters/json.rs2
-rw-r--r--src/libtest/formatters/mod.rs2
-rw-r--r--src/libtest/helpers/concurrency.rs1
-rw-r--r--src/libtest/lib.rs7
-rw-r--r--src/libtest/options.rs2
-rw-r--r--src/libtest/stats.rs16
-rw-r--r--src/libtest/stats/tests.rs1
-rw-r--r--src/libtest/test_result.rs4
-rw-r--r--src/libtest/types.rs8
11 files changed, 25 insertions, 26 deletions
diff --git a/src/libtest/cli.rs b/src/libtest/cli.rs
index 778600b2196..aac454c023c 100644
--- a/src/libtest/cli.rs
+++ b/src/libtest/cli.rs
@@ -213,7 +213,7 @@ macro_rules! unstable_optflag {
         let opt = $matches.opt_present($option_name);
         if !$allow_unstable && opt {
             return Err(format!(
-                "The \"{}\" flag is only accepted on the nightly compiler",
+                "The \"{}\" flag is only accepted on the nightly compiler with -Z unstable-options",
                 $option_name
             ));
         }
@@ -273,7 +273,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes {
     Ok(test_opts)
 }
 
-// FIXME: Copied from libsyntax until linkage errors are resolved. Issue #47566
+// FIXME: Copied from librustc_ast until linkage errors are resolved. Issue #47566
 fn is_nightly() -> bool {
     // Whether this is a feature-staged build, i.e., on the beta or stable channel
     let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
@@ -283,7 +283,7 @@ fn is_nightly() -> bool {
     bootstrap || !disable_unstable_features
 }
 
-// Gets the CLI options assotiated with `report-time` feature.
+// Gets the CLI options associated with `report-time` feature.
 fn get_time_options(
     matches: &getopts::Matches,
     allow_unstable: bool,
diff --git a/src/libtest/console.rs b/src/libtest/console.rs
index 149c9202e6e..ff741e3bd53 100644
--- a/src/libtest/console.rs
+++ b/src/libtest/console.rs
@@ -169,7 +169,7 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Res
 
     if !quiet {
         if ntest != 0 || nbench != 0 {
-            writeln!(output, "")?;
+            writeln!(output)?;
         }
 
         writeln!(output, "{}, {}", plural(ntest, "test"), plural(nbench, "benchmark"))?;
diff --git a/src/libtest/formatters/json.rs b/src/libtest/formatters/json.rs
index 863cad9f9d7..9ebc991d638 100644
--- a/src/libtest/formatters/json.rs
+++ b/src/libtest/formatters/json.rs
@@ -80,7 +80,7 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
         state: &ConsoleTestState,
     ) -> io::Result<()> {
         let display_stdout = state.options.display_output || *result != TestResult::TrOk;
-        let stdout = if display_stdout && stdout.len() > 0 {
+        let stdout = if display_stdout && !stdout.is_empty() {
             Some(String::from_utf8_lossy(stdout))
         } else {
             None
diff --git a/src/libtest/formatters/mod.rs b/src/libtest/formatters/mod.rs
index a64c0fc263d..1fb840520a6 100644
--- a/src/libtest/formatters/mod.rs
+++ b/src/libtest/formatters/mod.rs
@@ -36,5 +36,5 @@ pub(crate) fn write_stderr_delimiter(test_output: &mut Vec<u8>, test_name: &Test
         Some(_) => test_output.push(b'\n'),
         None => (),
     }
-    write!(test_output, "---- {} stderr ----\n", test_name).unwrap();
+    writeln!(test_output, "---- {} stderr ----", test_name).unwrap();
 }
diff --git a/src/libtest/helpers/concurrency.rs b/src/libtest/helpers/concurrency.rs
index 6b0c8a8af32..e8f3820558a 100644
--- a/src/libtest/helpers/concurrency.rs
+++ b/src/libtest/helpers/concurrency.rs
@@ -77,6 +77,7 @@ pub fn get_concurrency() -> usize {
         target_os = "linux",
         target_os = "macos",
         target_os = "solaris",
+        target_os = "illumos",
     ))]
     fn num_cpus() -> usize {
         unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as usize }
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index de001cacbe1..933b647071f 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -13,14 +13,13 @@
 // running tests while providing a base that other test frameworks may
 // build off of.
 
-// N.B., this is also specified in this crate's Cargo.toml, but libsyntax contains logic specific to
+// N.B., this is also specified in this crate's Cargo.toml, but librustc_ast contains logic specific to
 // this crate, which relies on this attribute (rather than the value of `--crate-name` passed by
 // cargo) to detect this crate.
 
 #![crate_name = "test"]
 #![unstable(feature = "test", issue = "50297")]
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
-#![feature(asm)]
 #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
 #![feature(rustc_private)]
 #![feature(nll)]
@@ -96,7 +95,7 @@ use time::TestExecTime;
 // Process exit code to be used to indicate test failures.
 const ERROR_EXIT_CODE: i32 = 101;
 
-const SECONDARY_TEST_INVOKER_VAR: &'static str = "__RUST_TEST_INVOKE";
+const SECONDARY_TEST_INVOKER_VAR: &str = "__RUST_TEST_INVOKE";
 
 // The default console test runner. It accepts the command line
 // arguments and a vector of test_descs.
@@ -158,7 +157,7 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) {
             .filter(|test| test.desc.name.as_slice() == name)
             .map(make_owned_test)
             .next()
-            .expect(&format!("couldn't find a test with the provided name '{}'", name));
+            .unwrap_or_else(|| panic!("couldn't find a test with the provided name '{}'", name));
         let TestDescAndFn { desc, testfn } = test;
         let testfn = match testfn {
             StaticTestFn(f) => f,
diff --git a/src/libtest/options.rs b/src/libtest/options.rs
index 7db164c269a..8e7bd8de924 100644
--- a/src/libtest/options.rs
+++ b/src/libtest/options.rs
@@ -41,7 +41,7 @@ pub enum OutputFormat {
     Json,
 }
 
-/// Whether ignored test should be runned or not
+/// Whether ignored test should be run or not
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 pub enum RunIgnored {
     Yes,
diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs
index aab8d012fdf..077005371c0 100644
--- a/src/libtest/stats.rs
+++ b/src/libtest/stats.rs
@@ -204,7 +204,7 @@ impl Stats for [f64] {
     }
 
     fn median(&self) -> f64 {
-        self.percentile(50 as f64)
+        self.percentile(50_f64)
     }
 
     fn var(&self) -> f64 {
@@ -230,7 +230,7 @@ impl Stats for [f64] {
     }
 
     fn std_dev_pct(&self) -> f64 {
-        let hundred = 100 as f64;
+        let hundred = 100_f64;
         (self.std_dev() / self.mean()) * hundred
     }
 
@@ -244,7 +244,7 @@ impl Stats for [f64] {
     }
 
     fn median_abs_dev_pct(&self) -> f64 {
-        let hundred = 100 as f64;
+        let hundred = 100_f64;
         (self.median_abs_dev() / self.median()) * hundred
     }
 
@@ -257,11 +257,11 @@ impl Stats for [f64] {
     fn quartiles(&self) -> (f64, f64, f64) {
         let mut tmp = self.to_vec();
         local_sort(&mut tmp);
-        let first = 25f64;
+        let first = 25_f64;
         let a = percentile_of_sorted(&tmp, first);
-        let second = 50f64;
+        let second = 50_f64;
         let b = percentile_of_sorted(&tmp, second);
-        let third = 75f64;
+        let third = 75_f64;
         let c = percentile_of_sorted(&tmp, third);
         (a, b, c)
     }
@@ -281,7 +281,7 @@ fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 {
     }
     let zero: f64 = 0.0;
     assert!(zero <= pct);
-    let hundred = 100f64;
+    let hundred = 100_f64;
     assert!(pct <= hundred);
     if pct == hundred {
         return sorted_samples[sorted_samples.len() - 1];
@@ -307,7 +307,7 @@ pub fn winsorize(samples: &mut [f64], pct: f64) {
     let mut tmp = samples.to_vec();
     local_sort(&mut tmp);
     let lo = percentile_of_sorted(&tmp, pct);
-    let hundred = 100 as f64;
+    let hundred = 100_f64;
     let hi = percentile_of_sorted(&tmp, hundred - pct);
     for samp in samples {
         if *samp > hi {
diff --git a/src/libtest/stats/tests.rs b/src/libtest/stats/tests.rs
index 5bfd1d3885f..3a6e8401bf1 100644
--- a/src/libtest/stats/tests.rs
+++ b/src/libtest/stats/tests.rs
@@ -2,7 +2,6 @@ use super::*;
 
 extern crate test;
 use self::test::test::Bencher;
-use std::f64;
 use std::io;
 use std::io::prelude::*;
 
diff --git a/src/libtest/test_result.rs b/src/libtest/test_result.rs
index bfa572c887a..465f3f8f994 100644
--- a/src/libtest/test_result.rs
+++ b/src/libtest/test_result.rs
@@ -27,7 +27,7 @@ pub enum TestResult {
 unsafe impl Send for TestResult {}
 
 /// Creates a `TestResult` depending on the raw result of test execution
-/// and assotiated data.
+/// and associated data.
 pub fn calc_result<'a>(
     desc: &TestDesc,
     task_result: Result<(), &'a (dyn Any + 'static + Send)>,
@@ -40,7 +40,7 @@ pub fn calc_result<'a>(
             let maybe_panic_str = err
                 .downcast_ref::<String>()
                 .map(|e| &**e)
-                .or_else(|| err.downcast_ref::<&'static str>().map(|e| *e));
+                .or_else(|| err.downcast_ref::<&'static str>().copied());
 
             if maybe_panic_str.map(|e| e.contains(msg)).unwrap_or(false) {
                 TestResult::TrOk
diff --git a/src/libtest/types.rs b/src/libtest/types.rs
index 2619f99592a..5b75d2f367f 100644
--- a/src/libtest/types.rs
+++ b/src/libtest/types.rs
@@ -59,10 +59,10 @@ impl TestName {
     }
 
     pub fn with_padding(&self, padding: NamePadding) -> TestName {
-        let name = match self {
-            &TestName::StaticTestName(name) => Cow::Borrowed(name),
-            &TestName::DynTestName(ref name) => Cow::Owned(name.clone()),
-            &TestName::AlignedTestName(ref name, _) => name.clone(),
+        let name = match *self {
+            TestName::StaticTestName(name) => Cow::Borrowed(name),
+            TestName::DynTestName(ref name) => Cow::Owned(name.clone()),
+            TestName::AlignedTestName(ref name, _) => name.clone(),
         };
 
         TestName::AlignedTestName(name, padding)