Skip to content

Commit aeb2f88

Browse files
committed
Raise the file descriptor limits when running compiletest
We already do this for libstd tests automatically, and compiletest runs into the same problems where when forking lots of processes lots of file descriptors are created. On OSX we can use specific syscalls to raise the limits, in this situation, though. Closes #8904
1 parent fc9fa2c commit aeb2f88

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/compiletest/compiletest.rs

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
extern mod extra;
1717

1818
use std::os;
19+
use std::rt;
1920
use std::f64;
2021

2122
use extra::getopts;
@@ -223,6 +224,10 @@ pub fn mode_str(mode: mode) -> ~str {
223224
pub fn run_tests(config: &config) {
224225
let opts = test_opts(config);
225226
let tests = make_tests(config);
227+
// sadly osx needs some file descriptor limits raised for running tests in
228+
// parallel (especially when we have lots and lots of child processes).
229+
// For context, see #8904
230+
rt::test::prepare_for_lots_of_tests();
226231
let res = test::run_tests_console(&opts, tests);
227232
if !res { fail!("Some tests failed"); }
228233
}

src/libstd/rt/test.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ mod darwin_fd_limit {
144144
pub unsafe fn raise_fd_limit() {}
145145
}
146146

147+
#[doc(hidden)]
148+
pub fn prepare_for_lots_of_tests() {
149+
// Bump the fd limit on OS X. See darwin_fd_limit for an explanation.
150+
unsafe { darwin_fd_limit::raise_fd_limit() }
151+
}
152+
147153
/// Create more than one scheduler and run a function in a task
148154
/// in one of the schedulers. The schedulers will stay alive
149155
/// until the function `f` returns.
@@ -153,8 +159,8 @@ pub fn run_in_mt_newsched_task(f: ~fn()) {
153159
use rt::sched::Shutdown;
154160
use rt::util;
155161

156-
// Bump the fd limit on OS X. See darwin_fd_limit for an explanation.
157-
unsafe { darwin_fd_limit::raise_fd_limit() }
162+
// see comment in other function (raising fd limits)
163+
prepare_for_lots_of_tests();
158164

159165
let f = Cell::new(f);
160166

0 commit comments

Comments
 (0)