diff options
| author | bors <bors@rust-lang.org> | 2014-11-06 08:06:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-06 08:06:50 +0000 |
| commit | e84e7a00ddec76570bbaa9afea385d544f616814 (patch) | |
| tree | 5757b1eec689ab03459c9f2518cc602284c44733 /src/libtest | |
| parent | 0e2f9b948564708085373fc28d91b4524c821fa3 (diff) | |
| parent | 11f4baeafb83459befd0196b2b82cda7ed5ea2f1 (diff) | |
| download | rust-e84e7a00ddec76570bbaa9afea385d544f616814.tar.gz rust-e84e7a00ddec76570bbaa9afea385d544f616814.zip | |
auto merge of #18467 : japaric/rust/eq, r=alexcrichton
`eq`, `ne`, `cmp`, etc methods now require one less level of indirection when dealing with `&str`/`&[T]`
``` rust
"foo".ne(&"bar") -> "foo".ne("bar")
slice.cmp(&another_slice) -> slice.cmp(another_slice)
// slice and another_slice have type `&[T]`
```
[breaking-change]
Diffstat (limited to 'src/libtest')
| -rw-r--r-- | src/libtest/lib.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 81d0bb76d14..74bead9e5f2 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -973,6 +973,8 @@ fn get_concurrency() -> uint { } } +// NOTE(stage0): remove function after a snapshot +#[cfg(stage0)] pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> { let mut filtered = tests; @@ -1020,6 +1022,54 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescA } } +#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot +pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescAndFn> { + let mut filtered = tests; + + // Remove tests that don't match the test filter + filtered = match opts.filter { + None => filtered, + Some(ref re) => { + filtered.into_iter() + .filter(|test| re.is_match(test.desc.name.as_slice())).collect() + } + }; + + // Maybe pull out the ignored test and unignore them + filtered = if !opts.run_ignored { + filtered + } else { + fn filter(test: TestDescAndFn) -> Option<TestDescAndFn> { + if test.desc.ignore { + let TestDescAndFn {desc, testfn} = test; + Some(TestDescAndFn { + desc: TestDesc {ignore: false, ..desc}, + testfn: testfn + }) + } else { + None + } + }; + filtered.into_iter().filter_map(|x| filter(x)).collect() + }; + + // Sort the tests alphabetically + filtered.sort_by(|t1, t2| t1.desc.name.as_slice().cmp(t2.desc.name.as_slice())); + + // Shard the remaining tests, if sharding requested. + match opts.test_shard { + None => filtered, + Some((a,b)) => { + filtered.into_iter().enumerate() + // note: using a - 1 so that the valid shards, for example, are + // 1.2 and 2.2 instead of 0.2 and 1.2 + .filter(|&(i,_)| i % b == (a - 1)) + .map(|(_,t)| t) + .collect() + } + } +} + pub fn run_test(opts: &TestOpts, force_ignore: bool, test: TestDescAndFn, |
