about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-24 02:21:27 -0700
committerbors <bors@rust-lang.org>2013-08-24 02:21:27 -0700
commitbb9c71fe82005d2d85f459988d9986f7c817717e (patch)
tree0ae6b97bda3c8039d0b529808cf49a8a09415921 /src/libextra
parent8bf65a156c981f4f7f83bcee080343bc75a0790e (diff)
parent2fb5c49abbab97820f24b8574e574dde1f344249 (diff)
downloadrust-bb9c71fe82005d2d85f459988d9986f7c817717e.tar.gz
rust-bb9c71fe82005d2d85f459988d9986f7c817717e.zip
auto merge of #8722 : graydon/rust/2013-08-23-test-shard, r=msullivan
This makes it relatively easy for us to split testsuite load between machines in buildbot. I've added buildbot-side support for setting up builders with -a.b suffixes (eg. linux-64-opt-vg-0.5, linux-64-opt-vg-1.5, linux-64-opt-vg-2.5, linux-64-opt-vg-3.5, linux-64-opt-vg-4.5 causes the valgrind-supervised testsuite to split 5 ways across hosts).

Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/test.rs38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/libextra/test.rs b/src/libextra/test.rs
index d940e8bb473..f477235bdfc 100644
--- a/src/libextra/test.rs
+++ b/src/libextra/test.rs
@@ -38,6 +38,7 @@ use std::task;
 use std::to_str::ToStr;
 use std::f64;
 use std::os;
+use std::uint;
 
 
 // The name of a test. By convention this follows the rules for rust
@@ -164,6 +165,7 @@ pub struct TestOpts {
     ratchet_metrics: Option<Path>,
     ratchet_noise_percent: Option<f64>,
     save_metrics: Option<Path>,
+    test_shard: Option<(uint,uint)>,
     logfile: Option<Path>
 }
 
@@ -184,7 +186,9 @@ fn optgroups() -> ~[getopts::groups::OptGroup] {
                      "Tests within N% of the recorded metrics will be \
                       considered as passing", "PERCENTAGE"),
       groups::optopt("", "logfile", "Write logs to the specified file instead \
-                          of stdout", "PATH")]
+                          of stdout", "PATH"),
+      groups::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
+                     "A.B")]
 }
 
 fn usage(binary: &str, helpstr: &str) -> ! {
@@ -255,6 +259,9 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
     let save_metrics = getopts::opt_maybe_str(&matches, "save-metrics");
     let save_metrics = save_metrics.map_move(|s| Path(s));
 
+    let test_shard = getopts::opt_maybe_str(&matches, "test-shard");
+    let test_shard = opt_shard(test_shard);
+
     let test_opts = TestOpts {
         filter: filter,
         run_ignored: run_ignored,
@@ -263,12 +270,29 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
         ratchet_metrics: ratchet_metrics,
         ratchet_noise_percent: ratchet_noise_percent,
         save_metrics: save_metrics,
+        test_shard: test_shard,
         logfile: logfile
     };
 
     either::Left(test_opts)
 }
 
+pub fn opt_shard(maybestr: Option<~str>) -> Option<(uint,uint)> {
+    match maybestr {
+        None => None,
+        Some(s) => {
+            match s.split_iter('.').to_owned_vec() {
+                [a, b] => match (uint::from_str(a), uint::from_str(b)) {
+                    (Some(a), Some(b)) => Some((a,b)),
+                    _ => None
+                },
+                _ => None
+            }
+        }
+    }
+}
+
+
 #[deriving(Clone, Eq)]
 pub struct BenchSamples {
     ns_iter_summ: stats::Summary,
@@ -772,7 +796,15 @@ pub fn filter_tests(
     }
     sort::quick_sort(filtered, lteq);
 
-    filtered
+    // Shard the remaining tests, if sharding requested.
+    match opts.test_shard {
+        None => filtered,
+        Some((a,b)) =>
+            filtered.move_iter().enumerate()
+            .filter(|&(i,_)| i % b == a)
+            .map(|(_,t)| t)
+            .to_owned_vec()
+    }
 }
 
 struct TestFuture {
@@ -1234,6 +1266,7 @@ mod tests {
             ratchet_noise_percent: None,
             ratchet_metrics: None,
             save_metrics: None,
+            test_shard: None
         };
 
         let tests = ~[
@@ -1272,6 +1305,7 @@ mod tests {
             ratchet_noise_percent: None,
             ratchet_metrics: None,
             save_metrics: None,
+            test_shard: None
         };
 
         let names =