about summary refs log tree commit diff
path: root/src/libtest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-02-03 03:44:05 +0000
committerbors <bors@rust-lang.org>2015-02-03 03:44:05 +0000
commit7858cb432d3f2efc0374424cb2b51518f697c172 (patch)
treebccd460a861e61f758d2d459cb9da02b1ad8792b /src/libtest
parenteaf4c5c784637f3df8bdebc6ec21dbd4bc69420a (diff)
parent9ece22ee00033cdf0b6b418c451112c92c8ad922 (diff)
downloadrust-7858cb432d3f2efc0374424cb2b51518f697c172.tar.gz
rust-7858cb432d3f2efc0374424cb2b51518f697c172.zip
Auto merge of #21872 - alexcrichton:rollup, r=alexcrichton
Diffstat (limited to 'src/libtest')
-rw-r--r--src/libtest/lib.rs30
-rw-r--r--src/libtest/stats.rs8
2 files changed, 18 insertions, 20 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index f22c58c54a6..0692d7e5faa 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -16,7 +16,7 @@
 //! benchmarks themselves) should be done via the `#[test]` and
 //! `#[bench]` attributes.
 //!
-//! See the [Testing Guide](../guide-testing.html) for more details.
+//! See the [Testing Chapter](../book/testing.html) of the book for more details.
 
 // Currently, not much of this is meant for users. It is intended to
 // support the simplest interface possible for representing and
@@ -32,16 +32,14 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![cfg_attr(not(stage0), allow(unused_mut))] // NOTE: remove after stage0 snap
-
 #![feature(asm, slicing_syntax)]
 #![feature(box_syntax)]
 #![feature(collections)]
 #![feature(core)]
+#![feature(env)]
 #![feature(hash)]
 #![feature(int_uint)]
 #![feature(io)]
-#![feature(os)]
 #![feature(path)]
 #![feature(rustc_private)]
 #![feature(staged_api)]
@@ -75,7 +73,7 @@ use std::old_io::{File, ChanReader, ChanWriter};
 use std::old_io;
 use std::iter::repeat;
 use std::num::{Float, Int};
-use std::os;
+use std::env;
 use std::sync::mpsc::{channel, Sender};
 use std::thread::{self, Thread};
 use std::thunk::{Thunk, Invoke};
@@ -388,7 +386,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
 
     let mut nocapture = matches.opt_present("nocapture");
     if !nocapture {
-        nocapture = os::getenv("RUST_TEST_NOCAPTURE").is_some();
+        nocapture = env::var("RUST_TEST_NOCAPTURE").is_some();
     }
 
     let color = match matches.opt_str("color").as_ref().map(|s| s.as_slice()) {
@@ -576,7 +574,7 @@ impl<T: Writer> ConsoleTestState<T> {
         try!(self.write_plain("\nfailures:\n"));
         let mut failures = Vec::new();
         let mut fail_out = String::new();
-        for &(ref f, ref stdout) in self.failures.iter() {
+        for &(ref f, ref stdout) in &self.failures {
             failures.push(f.name.to_string());
             if stdout.len() > 0 {
                 fail_out.push_str(format!("---- {} stdout ----\n\t",
@@ -593,7 +591,7 @@ impl<T: Writer> ConsoleTestState<T> {
 
         try!(self.write_plain("\nfailures:\n"));
         failures.sort();
-        for name in failures.iter() {
+        for name in &failures {
             try!(self.write_plain(format!("    {}\n",
                                           name.as_slice()).as_slice()));
         }
@@ -652,7 +650,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn> ) -> old_io:
                     TrMetrics(mm) => {
                         let tname = test.name.as_slice();
                         let MetricMap(mm) = mm;
-                        for (k,v) in mm.iter() {
+                        for (k,v) in &mm {
                             st.metrics
                               .insert_metric(format!("{}.{}",
                                                      tname,
@@ -806,7 +804,7 @@ fn run_tests<F>(opts: &TestOpts,
 
     // All benchmarks run at the end, in serial.
     // (this includes metric fns)
-    for b in filtered_benchs_and_metrics.into_iter() {
+    for b in filtered_benchs_and_metrics {
         try!(callback(TeWait(b.desc.clone(), b.testfn.padding())));
         run_test(opts, !opts.run_benchmarks, b, tx.clone());
         let (test, result, stdout) = rx.recv().unwrap();
@@ -817,15 +815,15 @@ fn run_tests<F>(opts: &TestOpts,
 
 fn get_concurrency() -> uint {
     use std::rt;
-    match os::getenv("RUST_TEST_TASKS") {
-        Some(s) => {
+    match env::var_string("RUST_TEST_TASKS") {
+        Ok(s) => {
             let opt_n: Option<uint> = s.parse().ok();
             match opt_n {
                 Some(n) if n > 0 => n,
                 _ => panic!("RUST_TEST_TASKS is `{}`, should be a positive integer.", s)
             }
         }
-        None => {
+        Err(..) => {
             rt::default_sched_threads()
         }
     }
@@ -1060,7 +1058,7 @@ impl Bencher {
 
             let loop_run = Duration::span(|| {
 
-                for p in samples.iter_mut() {
+                for p in &mut *samples {
                     self.bench_n(n, |x| f(x));
                     *p = self.ns_per_iter() as f64;
                 };
@@ -1068,7 +1066,7 @@ impl Bencher {
                 stats::winsorize(samples, 5.0);
                 summ = Some(stats::Summary::new(samples));
 
-                for p in samples.iter_mut() {
+                for p in &mut *samples {
                     self.bench_n(5 * n, |x| f(x));
                     *p = self.ns_per_iter() as f64;
                 };
@@ -1299,7 +1297,7 @@ mod tests {
         {
             fn testfn() { }
             let mut tests = Vec::new();
-            for name in names.iter() {
+            for name in &names {
                 let test = TestDescAndFn {
                     desc: TestDesc {
                         name: DynTestName((*name).clone()),
diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs
index 237acbd7b65..ebd86dbf61c 100644
--- a/src/libtest/stats.rs
+++ b/src/libtest/stats.rs
@@ -167,7 +167,7 @@ impl<T: Float + FromPrimitive> Stats<T> for [T] {
     fn sum(&self) -> T {
         let mut partials = vec![];
 
-        for &x in self.iter() {
+        for &x in self {
             let mut x = x;
             let mut j = 0;
             // This inner loop applies `hi`/`lo` summation to each
@@ -223,7 +223,7 @@ impl<T: Float + FromPrimitive> Stats<T> for [T] {
         } else {
             let mean = self.mean();
             let mut v: T = Float::zero();
-            for s in self.iter() {
+            for s in self {
                 let x = *s - mean;
                 v = v + x*x;
             }
@@ -321,7 +321,7 @@ pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
     let lo = percentile_of_sorted(tmp.as_slice(), pct);
     let hundred: T = FromPrimitive::from_uint(100).unwrap();
     let hi = percentile_of_sorted(tmp.as_slice(), hundred-pct);
-    for samp in samples.iter_mut() {
+    for samp in samples {
         if *samp > hi {
             *samp = hi
         } else if *samp < lo {
@@ -332,7 +332,7 @@ pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
 
 /// Returns a HashMap with the number of occurrences of every element in the
 /// sequence that the iterator exposes.
-pub fn freq_count<T, U>(mut iter: T) -> hash_map::HashMap<U, uint>
+pub fn freq_count<T, U>(iter: T) -> hash_map::HashMap<U, uint>
   where T: Iterator<Item=U>, U: Eq + Clone + Hash<Hasher>
 {
     let mut map: hash_map::HashMap<U,uint> = hash_map::HashMap::new();