Skip to content

Commit 33d6572

Browse files
committed
auto merge of #8823 : huonw/rust/6233, r=brson
Fixes #7335.
2 parents 518bd07 + 3f791ac commit 33d6572

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/libextra/test.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ The FILTER is matched against the name of all tests to run, and if any tests
203203
have a substring match, only those tests are run.
204204
205205
By default, all tests are run in parallel. This can be altered with the
206-
RUST_THREADS environment variable when running tests (set it to 1).
206+
RUST_TEST_TASKS environment variable when running tests (set it to 1).
207207
208208
Test Attributes:
209209
@@ -740,9 +740,20 @@ static SCHED_OVERCOMMIT : uint = 4u;
740740

741741
fn get_concurrency() -> uint {
742742
use std::rt;
743-
let threads = rt::util::default_sched_threads();
744-
if threads == 1 { 1 }
745-
else { threads * SCHED_OVERCOMMIT }
743+
match os::getenv("RUST_TEST_TASKS") {
744+
Some(s) => {
745+
let opt_n: Option<uint> = FromStr::from_str(s);
746+
match opt_n {
747+
Some(n) if n > 0 => n,
748+
_ => fail!("RUST_TEST_TASKS is `%s`, should be a non-negative integer.", s)
749+
}
750+
}
751+
None => {
752+
let threads = rt::util::default_sched_threads();
753+
if threads == 1 { 1 }
754+
else { threads * SCHED_OVERCOMMIT }
755+
}
756+
}
746757
}
747758

748759
pub fn filter_tests(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This checks that RUST_TEST_TASKS not being 1, 2, ... is detected
12+
// properly.
13+
14+
// error-pattern:should be a non-negative integer
15+
// compile-flags: --test
16+
// exec-env:RUST_TEST_TASKS=foo
17+
18+
#[test]
19+
fn do_nothing() {}

0 commit comments

Comments
 (0)