The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
import std::option;
|
|
|
|
import std::getopts;
|
|
|
|
import std::test;
|
|
|
|
import std::fs;
|
|
|
|
import std::str;
|
|
|
|
import std::vec;
|
|
|
|
import std::ivec;
|
|
|
|
import std::io;
|
|
|
|
import std::generic_os::setenv;
|
|
|
|
import std::generic_os::getenv;
|
|
|
|
import std::os;
|
|
|
|
import std::run;
|
2011-07-25 21:25:32 -07:00
|
|
|
import std::task;
|
2011-07-28 23:24:07 -07:00
|
|
|
import std::unsafe;
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
tag mode { mode_compile_fail; mode_run_fail; mode_run_pass; }
|
|
|
|
|
2011-07-27 11:17:03 -07:00
|
|
|
type config = {
|
|
|
|
// The library paths required for running the compiler
|
|
|
|
compile_lib_path: str,
|
|
|
|
// The library paths required for running compiled programs
|
|
|
|
run_lib_path: str,
|
|
|
|
// The rustc executable
|
|
|
|
rustc_path: str,
|
|
|
|
// The directory containing the tests to run
|
|
|
|
src_base: str,
|
|
|
|
// The directory where programs should be built
|
|
|
|
build_base: str,
|
|
|
|
// The name of the stage being built (stage1, etc)
|
|
|
|
stage_id: str,
|
|
|
|
// The test mode, compile-fail, run-fail, run-pass
|
|
|
|
mode: mode,
|
|
|
|
// Run ignored tests
|
|
|
|
run_ignored: bool,
|
|
|
|
// Only run tests that match this filter
|
|
|
|
filter: option::t[str],
|
|
|
|
// A command line to prefix program execution with,
|
|
|
|
// for running under valgrind
|
|
|
|
runtool: option::t[str],
|
|
|
|
// Flags to pass to the compiler
|
|
|
|
rustcflags: option::t[str],
|
|
|
|
// Explain what's going on
|
|
|
|
verbose: bool
|
|
|
|
};
|
2011-07-27 14:19:39 +02:00
|
|
|
|
|
|
|
fn main(args: vec[str]) {
|
|
|
|
|
|
|
|
let ivec_args =
|
|
|
|
{
|
|
|
|
let ivec_args = ~[];
|
|
|
|
for arg: str in args { ivec_args += ~[arg]; }
|
|
|
|
ivec_args
|
|
|
|
};
|
|
|
|
|
|
|
|
let config = parse_config(ivec_args);
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
log_config(config);
|
|
|
|
run_tests(config);
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn parse_config(args: &str[]) -> config {
|
|
|
|
let opts =
|
|
|
|
~[getopts::reqopt("compile-lib-path"),
|
|
|
|
getopts::reqopt("run-lib-path"), getopts::reqopt("rustc-path"),
|
|
|
|
getopts::reqopt("src-base"), getopts::reqopt("build-base"),
|
|
|
|
getopts::reqopt("stage-id"), getopts::reqopt("mode"),
|
|
|
|
getopts::optflag("ignored"), getopts::optopt("runtool"),
|
|
|
|
getopts::optopt("rustcflags"), getopts::optflag("verbose")];
|
|
|
|
|
|
|
|
check (ivec::is_not_empty(args));
|
|
|
|
let args_ = ivec::tail(args);
|
|
|
|
let match =
|
|
|
|
alt getopts::getopts_ivec(args_, opts) {
|
|
|
|
getopts::success(m) { m }
|
|
|
|
getopts::failure(f) { fail getopts::fail_str(f) }
|
|
|
|
};
|
|
|
|
|
|
|
|
ret {compile_lib_path: getopts::opt_str(match, "compile-lib-path"),
|
|
|
|
run_lib_path: getopts::opt_str(match, "run-lib-path"),
|
|
|
|
rustc_path: getopts::opt_str(match, "rustc-path"),
|
|
|
|
src_base: getopts::opt_str(match, "src-base"),
|
|
|
|
build_base: getopts::opt_str(match, "build-base"),
|
|
|
|
stage_id: getopts::opt_str(match, "stage-id"),
|
|
|
|
mode: str_mode(getopts::opt_str(match, "mode")),
|
|
|
|
run_ignored: getopts::opt_present(match, "ignored"),
|
|
|
|
filter:
|
|
|
|
if vec::len(match.free) > 0u {
|
|
|
|
option::some(match.free.(0))
|
|
|
|
} else { option::none },
|
|
|
|
runtool: getopts::opt_maybe_str(match, "runtool"),
|
|
|
|
rustcflags: getopts::opt_maybe_str(match, "rustcflags"),
|
|
|
|
verbose: getopts::opt_present(match, "verbose")};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn log_config(config: &config) {
|
|
|
|
let c = config;
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
logv(c, #fmt("configuration:"));
|
|
|
|
logv(c, #fmt("compile_lib_path: %s", config.compile_lib_path));
|
|
|
|
logv(c, #fmt("run_lib_path: %s", config.run_lib_path));
|
|
|
|
logv(c, #fmt("rustc_path: %s", config.rustc_path));
|
2011-07-27 14:19:39 +02:00
|
|
|
logv(c, #fmt("src_base: %s", config.src_base));
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
logv(c, #fmt("build_base: %s", config.build_base));
|
|
|
|
logv(c, #fmt("stage_id: %s", config.stage_id));
|
|
|
|
logv(c, #fmt("mode: %s", mode_str(config.mode)));
|
|
|
|
logv(c, #fmt("run_ignored: %b", config.run_ignored));
|
2011-07-26 18:34:29 -07:00
|
|
|
logv(c, #fmt("filter: %s", opt_str(config.filter)));
|
|
|
|
logv(c, #fmt("runtool: %s", opt_str(config.runtool)));
|
|
|
|
logv(c, #fmt("rustcflags: %s", opt_str(config.rustcflags)));
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
logv(c, #fmt("verbose: %b", config.verbose));
|
|
|
|
logv(c, #fmt("\n"));
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn opt_str(maybestr: option::t[str]) -> str {
|
|
|
|
alt maybestr { option::some(s) { s } option::none. { "(none)" } }
|
2011-07-26 18:34:29 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn str_opt(maybestr: str) -> option::t[str] {
|
|
|
|
if maybestr != "(none)" { option::some(maybestr) } else { option::none }
|
2011-07-26 18:34:29 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn str_mode(s: str) -> mode {
|
2011-07-26 18:34:29 -07:00
|
|
|
alt s {
|
|
|
|
"compile-fail" { mode_compile_fail }
|
|
|
|
"run-fail" { mode_run_fail }
|
|
|
|
"run-pass" { mode_run_pass }
|
|
|
|
_ { fail "invalid mode" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn mode_str(mode: mode) -> str {
|
|
|
|
alt mode {
|
|
|
|
mode_compile_fail. { "compile-fail" }
|
|
|
|
mode_run_fail. { "run-fail" }
|
|
|
|
mode_run_pass. { "run-pass" }
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
type cx = {config: config, procsrv: procsrv::handle};
|
2011-07-25 21:25:32 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn run_tests(config: &config) {
|
|
|
|
let opts = test_opts(config);
|
|
|
|
let cx = {config: config, procsrv: procsrv::mk()};
|
|
|
|
let tests = make_tests(cx);
|
2011-07-26 18:34:29 -07:00
|
|
|
test::run_tests_console_(opts, tests.tests, tests.to_task);
|
2011-07-25 21:25:32 -07:00
|
|
|
procsrv::close(cx.procsrv);
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn test_opts(config: &config) -> test::test_opts {
|
|
|
|
{filter: config.filter, run_ignored: config.run_ignored}
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
type tests_and_conv_fn =
|
|
|
|
{tests: test::test_desc[], to_task: fn(&fn() ) -> task };
|
2011-07-26 18:34:29 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn make_tests(cx: &cx) -> tests_and_conv_fn {
|
2011-07-25 21:25:32 -07:00
|
|
|
log #fmt("making tests from %s", cx.config.src_base);
|
2011-07-27 14:19:39 +02:00
|
|
|
let configport = port[str]();
|
|
|
|
let tests = ~[];
|
|
|
|
for file: str in fs::list_dir(cx.config.src_base) {
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
log #fmt("inspecting file %s", file);
|
2011-07-27 14:19:39 +02:00
|
|
|
if is_test(file) { tests += ~[make_test(cx, file, configport)]; }
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
2011-07-27 14:19:39 +02:00
|
|
|
ret {tests: tests, to_task: bind closure_to_task(cx, configport, _)};
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn is_test(testfile: &str) -> bool {
|
|
|
|
let name = fs::basename(testfile);
|
|
|
|
(str::ends_with(name, ".rs") || str::ends_with(name, ".rc")) &&
|
|
|
|
!(str::starts_with(name, ".") || str::starts_with(name, "#") ||
|
|
|
|
str::starts_with(name, "~"))
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn make_test(cx: &cx, testfile: &str, configport: &port[str]) ->
|
|
|
|
test::test_desc {
|
|
|
|
{name: testfile,
|
|
|
|
fn: make_test_closure(testfile, chan(configport)),
|
2011-07-27 17:00:57 -07:00
|
|
|
ignore: header::is_test_ignored(cx.config, testfile)}
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
|
2011-07-26 18:34:29 -07:00
|
|
|
/*
|
|
|
|
So this is kind of crappy:
|
|
|
|
|
|
|
|
A test is just defined as a function, as you might expect, but tests have to
|
|
|
|
run their own tasks. Unfortunately, if your test needs dynamic data then it
|
|
|
|
needs to be a closure, and transferring closures across tasks without
|
|
|
|
committing a host of memory management transgressions is just impossible.
|
|
|
|
|
|
|
|
To get around this, the standard test runner allows you the opportunity do
|
|
|
|
your own conversion from a test function to a task. It gives you your function
|
|
|
|
and you give it back a task.
|
|
|
|
|
|
|
|
So that's what we're going to do. Here's where it gets stupid. To get the
|
|
|
|
the data out of the test function we are going to run the test function,
|
|
|
|
which will do nothing but send the data for that test to a port we've set
|
|
|
|
up. Then we'll spawn that data into another task and return the task.
|
|
|
|
Really convoluted. Need to think up of a better definition for tests.
|
|
|
|
*/
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn make_test_closure(testfile: &str, configchan: chan[str]) -> test::test_fn {
|
2011-07-26 18:34:29 -07:00
|
|
|
bind send_config(testfile, configchan)
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn send_config(testfile: str, configchan: chan[str]) {
|
2011-07-26 18:34:29 -07:00
|
|
|
task::send(configchan, testfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FIXME: Good god forgive me.
|
|
|
|
|
|
|
|
So actually shuttling structural data across tasks isn't possible at this
|
|
|
|
time, but we can send strings! Sadly, I need the whole config record, in the
|
|
|
|
test task so, instead of fixing the mechanism in the compiler I'm going to
|
|
|
|
break up the config record and pass everything individually to the spawned
|
2011-07-27 11:17:03 -07:00
|
|
|
function.
|
|
|
|
*/
|
2011-07-26 18:34:29 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn closure_to_task(cx: cx, configport: port[str], testfn: &fn() ) -> task {
|
2011-07-26 18:34:29 -07:00
|
|
|
testfn();
|
2011-07-27 14:19:39 +02:00
|
|
|
let testfile = task::recv(configport);
|
2011-07-26 18:34:29 -07:00
|
|
|
ret spawn run_test_task(cx.config.compile_lib_path,
|
2011-07-27 14:19:39 +02:00
|
|
|
cx.config.run_lib_path, cx.config.rustc_path,
|
|
|
|
cx.config.src_base, cx.config.build_base,
|
|
|
|
cx.config.stage_id, mode_str(cx.config.mode),
|
|
|
|
cx.config.run_ignored, opt_str(cx.config.filter),
|
2011-07-26 18:34:29 -07:00
|
|
|
opt_str(cx.config.runtool),
|
2011-07-27 14:19:39 +02:00
|
|
|
opt_str(cx.config.rustcflags), cx.config.verbose,
|
2011-07-28 23:24:07 -07:00
|
|
|
task::clone_chan(cx.procsrv.chan), testfile);
|
2011-07-27 14:19:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run_test_task(compile_lib_path: str, run_lib_path: str, rustc_path: str,
|
|
|
|
src_base: str, build_base: str, stage_id: str, mode: str,
|
|
|
|
run_ignored: bool, opt_filter: str, opt_runtool: str,
|
|
|
|
opt_rustcflags: str, verbose: bool,
|
|
|
|
procsrv_chan: procsrv::reqchan, testfile: str) {
|
|
|
|
|
|
|
|
let config =
|
|
|
|
{compile_lib_path: compile_lib_path,
|
|
|
|
run_lib_path: run_lib_path,
|
|
|
|
rustc_path: rustc_path,
|
|
|
|
src_base: src_base,
|
|
|
|
build_base: build_base,
|
|
|
|
stage_id: stage_id,
|
|
|
|
mode: str_mode(mode),
|
|
|
|
run_ignored: run_ignored,
|
|
|
|
filter: str_opt(opt_filter),
|
|
|
|
runtool: str_opt(opt_runtool),
|
|
|
|
rustcflags: str_opt(opt_rustcflags),
|
|
|
|
verbose: verbose};
|
|
|
|
|
|
|
|
let procsrv = procsrv::from_chan(procsrv_chan);
|
|
|
|
|
|
|
|
let cx = {config: config, procsrv: procsrv};
|
2011-07-25 23:11:10 -07:00
|
|
|
|
2011-07-27 17:00:57 -07:00
|
|
|
runtest::run(cx, testfile);
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn make_cmdline(libpath: &str, prog: &str, args: &vec[str]) -> str {
|
|
|
|
#fmt("%s %s %s", lib_path_cmd_prefix(libpath), prog,
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
str::connect(args, " "))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
|
|
|
|
// for diagnostic purposes
|
2011-07-27 14:19:39 +02:00
|
|
|
fn lib_path_cmd_prefix(path: &str) -> str {
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
#fmt("%s=\"%s\"", lib_path_env_var(), make_new_path(path))
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn make_new_path(path: &str) -> str {
|
|
|
|
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
// Windows just uses PATH as the library search path, so we have to
|
|
|
|
// maintain the current value while adding our own
|
|
|
|
alt getenv(lib_path_env_var()) {
|
2011-07-27 14:19:39 +02:00
|
|
|
option::some(curr) { #fmt("%s:%s", path, curr) }
|
|
|
|
option::none. { path }
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
fn lib_path_env_var() -> str { "LD_LIBRARY_PATH" }
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
fn lib_path_env_var() -> str { "DYLD_LIBRARY_PATH" }
|
|
|
|
|
|
|
|
#[cfg(target_os = "win32")]
|
|
|
|
fn lib_path_env_var() -> str { "PATH" }
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn make_exe_name(config: &config, testfile: &str) -> str {
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
output_base_name(config, testfile) + os::exec_suffix()
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn output_base_name(config: &config, testfile: &str) -> str {
|
|
|
|
let base = config.build_base;
|
|
|
|
let filename =
|
|
|
|
{
|
|
|
|
let parts = str::split(fs::basename(testfile), '.' as u8);
|
|
|
|
parts = vec::slice(parts, 0u, vec::len(parts) - 1u);
|
|
|
|
str::connect(parts, ".")
|
|
|
|
};
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
#fmt("%s%s.%s", base, filename, config.stage_id)
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn logv(config: &config, s: &str) {
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
log s;
|
2011-07-27 14:19:39 +02:00
|
|
|
if config.verbose { io::stdout().write_line(s); }
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
}
|
|
|
|
|
2011-07-28 23:24:07 -07:00
|
|
|
fn clone_str(s: &str) -> str {
|
|
|
|
let new = s + "";
|
|
|
|
// new should be a different pointer
|
|
|
|
let sptr: int = unsafe::reinterpret_cast(s);
|
|
|
|
let newptr: int = unsafe::reinterpret_cast(new);
|
|
|
|
assert sptr != newptr;
|
|
|
|
new
|
|
|
|
}
|
|
|
|
|
|
|
|
fn clone_ivecstr(v: &str[]) -> str[] {
|
|
|
|
let r = ~[];
|
|
|
|
for t: str in ivec::slice(v, 0u, ivec::len(v)) {
|
|
|
|
r += ~[clone_str(t)];
|
|
|
|
}
|
|
|
|
ret r;
|
|
|
|
}
|
|
|
|
|
2011-07-27 17:00:57 -07:00
|
|
|
mod header {
|
|
|
|
|
|
|
|
export test_props;
|
|
|
|
export load_props;
|
|
|
|
export is_test_ignored;
|
|
|
|
|
|
|
|
type test_props = {error_patterns: str[], compile_flags: option::t[str]};
|
|
|
|
|
|
|
|
// Load any test directives embedded in the file
|
|
|
|
fn load_props(testfile: &str) -> test_props {
|
|
|
|
let error_patterns = ~[];
|
|
|
|
let compile_flags = option::none;
|
|
|
|
for each ln: str in iter_header(testfile) {
|
|
|
|
alt parse_error_pattern(ln) {
|
|
|
|
option::some(ep) { error_patterns += ~[ep]; }
|
|
|
|
option::none. { }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if option::is_none(compile_flags) {
|
|
|
|
compile_flags = parse_compile_flags(ln);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret {error_patterns: error_patterns, compile_flags: compile_flags};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_test_ignored(config: &config, testfile: &str) -> bool {
|
|
|
|
let found = false;
|
|
|
|
for each ln: str in iter_header(testfile) {
|
|
|
|
// FIXME: Can't return or break from iterator
|
|
|
|
found = found
|
|
|
|
|| parse_name_directive(ln, "xfail-" + config.stage_id);
|
|
|
|
}
|
|
|
|
ret found;
|
|
|
|
}
|
|
|
|
|
|
|
|
iter iter_header(testfile: &str) -> str {
|
|
|
|
let rdr = io::file_reader(testfile);
|
|
|
|
while !rdr.eof() {
|
|
|
|
let ln = rdr.read_line();
|
|
|
|
|
|
|
|
// Assume that any directives will be found before the first
|
|
|
|
// module or function. This doesn't seem to be an optimization
|
|
|
|
// with a warm page cache. Maybe with a cold one.
|
|
|
|
if str::starts_with(ln, "fn") || str::starts_with(ln, "mod") {
|
|
|
|
break;
|
|
|
|
} else { put ln; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_error_pattern(line: &str) -> option::t[str] {
|
|
|
|
parse_name_value_directive(line, "error-pattern")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_compile_flags(line: &str) -> option::t[str] {
|
|
|
|
parse_name_value_directive(line, "compile-flags")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_name_directive(line: &str, directive: &str) -> bool {
|
|
|
|
str::find(line, directive) >= 0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_name_value_directive(line: &str,
|
|
|
|
directive: &str) -> option::t[str] {
|
|
|
|
let keycolon = directive + ":";
|
|
|
|
if str::find(line, keycolon) >= 0 {
|
|
|
|
let colon = str::find(line, keycolon) as uint;
|
|
|
|
let value =
|
|
|
|
str::slice(line, colon + str::byte_len(keycolon),
|
|
|
|
str::byte_len(line));
|
|
|
|
log #fmt("%s: %s", directive, value);
|
|
|
|
option::some(value)
|
|
|
|
} else { option::none }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod runtest {
|
|
|
|
|
|
|
|
import header::load_props;
|
|
|
|
import header::test_props;
|
|
|
|
|
|
|
|
export run;
|
|
|
|
|
|
|
|
fn run(cx: &cx, testfile: &str) {
|
2011-07-27 18:30:57 -07:00
|
|
|
test::configure_test_task();
|
2011-07-27 18:16:50 -07:00
|
|
|
if (cx.config.verbose) {
|
|
|
|
// We're going to be dumping a lot of info. Start on a new line.
|
|
|
|
io::stdout().write_str("\n\n");
|
|
|
|
}
|
2011-07-27 17:00:57 -07:00
|
|
|
log #fmt("running %s", testfile);
|
|
|
|
let props = load_props(testfile);
|
|
|
|
alt cx.config.mode {
|
2011-07-28 23:24:07 -07:00
|
|
|
mode_compile_fail. { run_cfail_test(cx, props, testfile); }
|
|
|
|
mode_run_fail. { run_rfail_test(cx, props, testfile); }
|
|
|
|
mode_run_pass. { run_rpass_test(cx, props, testfile); }
|
|
|
|
}
|
2011-07-27 17:00:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run_cfail_test(cx: &cx, props: &test_props, testfile: &str) {
|
|
|
|
let procres = compile_test(cx, props, testfile);
|
|
|
|
|
|
|
|
if procres.status == 0 {
|
|
|
|
fatal_procres("compile-fail test compiled successfully!",
|
|
|
|
procres);
|
|
|
|
}
|
|
|
|
|
|
|
|
check_error_patterns(props, testfile, procres);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_rfail_test(cx: &cx, props: &test_props, testfile: &str) {
|
|
|
|
let procres = compile_test(cx, props, testfile);
|
|
|
|
|
|
|
|
if procres.status != 0 {
|
|
|
|
fatal_procres("compilation failed!", procres); }
|
|
|
|
|
|
|
|
procres = exec_compiled_test(cx, testfile);
|
|
|
|
|
|
|
|
if procres.status == 0 {
|
|
|
|
fatal_procres("run-fail test didn't produce an error!",
|
|
|
|
procres);
|
|
|
|
}
|
|
|
|
|
|
|
|
check_error_patterns(props, testfile, procres);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_rpass_test(cx: &cx, props: &test_props, testfile: &str) {
|
|
|
|
let procres = compile_test(cx, props, testfile);
|
|
|
|
|
|
|
|
if procres.status != 0 {
|
|
|
|
fatal_procres("compilation failed!", procres); }
|
|
|
|
|
|
|
|
procres = exec_compiled_test(cx, testfile);
|
|
|
|
|
|
|
|
|
|
|
|
if procres.status != 0 { fatal_procres("test run failed!", procres); }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_error_patterns(props: &test_props, testfile: &str,
|
|
|
|
procres: &procres) {
|
|
|
|
if ivec::is_empty(props.error_patterns) {
|
|
|
|
fatal("no error pattern specified in " + testfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
let next_err_idx = 0u;
|
|
|
|
let next_err_pat = props.error_patterns.(next_err_idx);
|
2011-07-27 18:11:40 -07:00
|
|
|
for line: str in str::split(procres.stdout, '\n' as u8) {
|
2011-07-27 17:00:57 -07:00
|
|
|
if str::find(line, next_err_pat) > 0 {
|
|
|
|
log #fmt("found error pattern %s", next_err_pat);
|
|
|
|
next_err_idx += 1u;
|
|
|
|
if next_err_idx == ivec::len(props.error_patterns) {
|
|
|
|
log "found all error patterns";
|
|
|
|
ret;
|
|
|
|
}
|
|
|
|
next_err_pat = props.error_patterns.(next_err_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let missing_patterns =
|
|
|
|
ivec::slice(props.error_patterns, next_err_idx,
|
|
|
|
ivec::len(props.error_patterns));
|
|
|
|
if ivec::len(missing_patterns) == 1u {
|
|
|
|
fatal_procres(#fmt("error pattern '%s' not found!",
|
|
|
|
missing_patterns.(0)), procres);
|
|
|
|
} else {
|
|
|
|
for pattern: str in missing_patterns {
|
|
|
|
error(#fmt("error pattern '%s' not found!", pattern));
|
|
|
|
}
|
|
|
|
fatal_procres("multiple error patterns not found", procres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type procargs = {prog: str, args: vec[str]};
|
|
|
|
|
2011-07-27 18:11:40 -07:00
|
|
|
type procres = {status: int, stdout: str, stderr: str, cmdline: str};
|
2011-07-27 17:00:57 -07:00
|
|
|
|
|
|
|
fn compile_test(cx: &cx, props: &test_props, testfile: &str) -> procres {
|
|
|
|
compose_and_run(cx, testfile, bind make_compile_args(_, props, _),
|
|
|
|
cx.config.compile_lib_path)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn exec_compiled_test(cx: &cx, testfile: &str) -> procres {
|
|
|
|
compose_and_run(cx, testfile, make_run_args, cx.config.run_lib_path)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn compose_and_run(cx: &cx, testfile: &str,
|
|
|
|
make_args: fn(&config, &str) -> procargs ,
|
|
|
|
lib_path: &str) -> procres {
|
|
|
|
let procargs = make_args(cx.config, testfile);
|
|
|
|
ret program_output(cx, testfile, lib_path,
|
|
|
|
procargs.prog, procargs.args);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make_compile_args(config: &config,
|
|
|
|
props: &test_props, testfile: &str) ->
|
|
|
|
procargs {
|
|
|
|
let prog = config.rustc_path;
|
|
|
|
let args = [testfile, "-o", make_exe_name(config, testfile)];
|
|
|
|
args += split_maybe_args(config.rustcflags);
|
|
|
|
args += split_maybe_args(props.compile_flags);
|
|
|
|
ret {prog: prog, args: args};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make_run_args(config: &config, testfile: &str) -> procargs {
|
|
|
|
// If we've got another tool to run under (valgrind),
|
|
|
|
// then split apart its command
|
|
|
|
let args =
|
|
|
|
split_maybe_args(config.runtool)
|
|
|
|
+ [make_exe_name(config, testfile)];
|
|
|
|
ret {prog: args.(0), args: vec::slice(args, 1u, vec::len(args))};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn split_maybe_args(argstr: &option::t[str]) -> vec[str] {
|
2011-08-01 16:41:20 -07:00
|
|
|
fn rm_whitespace(v: vec[str]) -> vec[str] {
|
|
|
|
fn flt(s: &str) -> option::t[str] {
|
|
|
|
if !is_whitespace(s) {
|
|
|
|
option::some(s)
|
|
|
|
} else {
|
|
|
|
option::none
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: This should be in std
|
|
|
|
fn is_whitespace(s: str) -> bool {
|
|
|
|
for c: u8 in s {
|
|
|
|
if c != (' ' as u8) { ret false; }
|
|
|
|
}
|
|
|
|
ret true;
|
|
|
|
}
|
|
|
|
vec::filter_map(flt, v)
|
|
|
|
}
|
|
|
|
|
2011-07-27 17:00:57 -07:00
|
|
|
alt argstr {
|
2011-08-01 16:41:20 -07:00
|
|
|
option::some(s) { rm_whitespace(str::split(s, ' ' as u8)) }
|
2011-07-27 17:00:57 -07:00
|
|
|
option::none. { [] }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn program_output(cx: &cx, testfile: &str, lib_path: &str, prog: &str,
|
|
|
|
args: &vec[str]) -> procres {
|
|
|
|
let cmdline =
|
|
|
|
{
|
|
|
|
let cmdline = make_cmdline(lib_path, prog, args);
|
2011-07-27 18:16:50 -07:00
|
|
|
logv(cx.config, #fmt("executing %s", cmdline));
|
2011-07-27 17:00:57 -07:00
|
|
|
cmdline
|
|
|
|
};
|
|
|
|
let res = procsrv::run(cx.procsrv, lib_path, prog, args);
|
2011-07-27 18:11:40 -07:00
|
|
|
dump_output(cx.config, testfile, res.out, res.err);
|
|
|
|
ret {status: res.status, stdout: res.out,
|
|
|
|
stderr: res.err, cmdline: cmdline};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn dump_output(config: &config, testfile: &str,
|
|
|
|
out: &str, err: &str) {
|
|
|
|
dump_output_file(config, testfile, out, "out");
|
|
|
|
dump_output_file(config, testfile, err, "err");
|
|
|
|
maybe_dump_to_stdout(config, out, err);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "win32")]
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
fn dump_output_file(config: &config, testfile: &str,
|
|
|
|
out: &str, extension: &str) {
|
|
|
|
let outfile = make_out_name(config, testfile, extension);
|
|
|
|
let writer = io::file_writer(outfile, [io::create, io::truncate]);
|
|
|
|
writer.write_str(out);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME (726): Can't use file_writer on mac
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
fn dump_output_file(config: &config, testfile: &str,
|
|
|
|
out: &str, extension: &str) {
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make_out_name(config: &config, testfile: &str,
|
|
|
|
extension: &str) -> str {
|
|
|
|
output_base_name(config, testfile) + "." + extension
|
|
|
|
}
|
|
|
|
|
|
|
|
fn maybe_dump_to_stdout(config: &config,
|
|
|
|
out: &str, err: &str) {
|
|
|
|
if config.verbose {
|
2011-07-27 18:16:50 -07:00
|
|
|
let sep1 = #fmt("------%s------------------------------",
|
2011-07-27 18:11:40 -07:00
|
|
|
"stdout");
|
2011-07-27 18:16:50 -07:00
|
|
|
let sep2 = #fmt("------%s------------------------------",
|
2011-07-27 18:11:40 -07:00
|
|
|
"stderr");
|
|
|
|
let sep3 = "------------------------------------------";
|
|
|
|
io::stdout().write_line(sep1);
|
|
|
|
io::stdout().write_line(out);
|
|
|
|
io::stdout().write_line(sep2);
|
|
|
|
io::stdout().write_line(err);
|
|
|
|
io::stdout().write_line(sep3);
|
|
|
|
}
|
2011-07-27 17:00:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn error(err: &str) { io::stdout().write_line(#fmt("\nerror: %s", err)); }
|
|
|
|
|
|
|
|
fn fatal(err: &str) -> ! { error(err); fail; }
|
|
|
|
|
|
|
|
fn fatal_procres(err: &str, procres: procres) -> ! {
|
|
|
|
let msg =
|
|
|
|
#fmt("\n\
|
|
|
|
error: %s\n\
|
|
|
|
command: %s\n\
|
2011-07-27 18:11:40 -07:00
|
|
|
stdout:\n\
|
|
|
|
------------------------------------------\n\
|
|
|
|
%s\n\
|
|
|
|
------------------------------------------\n\
|
|
|
|
stderr:\n\
|
2011-07-27 17:00:57 -07:00
|
|
|
------------------------------------------\n\
|
|
|
|
%s\n\
|
|
|
|
------------------------------------------\n\
|
|
|
|
\n",
|
2011-07-27 18:11:40 -07:00
|
|
|
err, procres.cmdline, procres.stdout, procres.stderr);
|
2011-07-27 17:00:57 -07:00
|
|
|
io::stdout().write_str(msg);
|
|
|
|
fail;
|
|
|
|
}
|
|
|
|
}
|
2011-07-25 21:25:32 -07:00
|
|
|
|
|
|
|
// So when running tests in parallel there's a potential race on environment
|
|
|
|
// variables if we let each task spawn its own children - between the time the
|
|
|
|
// environment is set and the process is spawned another task could spawn its
|
|
|
|
// child process. Because of that we have to use a complicated scheme with a
|
|
|
|
// dedicated server for spawning processes.
|
|
|
|
mod procsrv {
|
|
|
|
|
|
|
|
export handle;
|
|
|
|
export mk;
|
2011-07-26 18:34:29 -07:00
|
|
|
export from_chan;
|
2011-07-25 21:25:32 -07:00
|
|
|
export clone;
|
|
|
|
export run;
|
|
|
|
export close;
|
2011-07-26 18:34:29 -07:00
|
|
|
export reqchan;
|
|
|
|
|
|
|
|
type reqchan = chan[request];
|
2011-07-25 21:25:32 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
type handle = {task: option::t[task], chan: reqchan};
|
2011-07-25 21:25:32 -07:00
|
|
|
|
2011-07-28 23:24:07 -07:00
|
|
|
tag request { exec(str, str, str[], chan[response]); stop; }
|
2011-07-25 21:25:32 -07:00
|
|
|
|
2011-07-27 18:11:40 -07:00
|
|
|
type response = {pid: int, outfd: int, errfd: int};
|
2011-07-25 21:25:32 -07:00
|
|
|
|
|
|
|
fn mk() -> handle {
|
2011-07-27 16:07:31 -07:00
|
|
|
let setupport = port();
|
|
|
|
let task = spawn fn(setupchan: chan[chan[request]]) {
|
|
|
|
let reqport = port();
|
|
|
|
let reqchan = chan(reqport);
|
2011-07-28 23:24:07 -07:00
|
|
|
task::send(setupchan, task::clone_chan(reqchan));
|
2011-07-27 15:52:25 -07:00
|
|
|
worker(reqport);
|
|
|
|
} (chan(setupport));
|
|
|
|
ret {task: option::some(task),
|
|
|
|
chan: task::recv(setupport)
|
|
|
|
};
|
2011-07-25 21:25:32 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn from_chan(ch: &reqchan) -> handle { {task: option::none, chan: ch} }
|
|
|
|
|
|
|
|
fn clone(handle: &handle) -> handle {
|
2011-07-26 18:34:29 -07:00
|
|
|
|
2011-07-25 23:18:31 -07:00
|
|
|
// Sharing tasks across tasks appears to be (yet another) recipe for
|
|
|
|
// disaster, so our handle clones will not get the task pointer.
|
2011-07-27 14:19:39 +02:00
|
|
|
{task: option::none, chan: task::clone_chan(handle.chan)}
|
2011-07-25 21:25:32 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn close(handle: &handle) {
|
2011-07-25 23:18:31 -07:00
|
|
|
task::send(handle.chan, stop);
|
|
|
|
task::join(option::get(handle.task));
|
2011-07-25 21:25:32 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn run(handle: &handle, lib_path: &str, prog: &str, args: &vec[str]) ->
|
2011-07-27 18:11:40 -07:00
|
|
|
{status: int, out: str, err: str} {
|
2011-07-27 14:19:39 +02:00
|
|
|
let p = port[response]();
|
|
|
|
let ch = chan(p);
|
2011-07-28 23:24:07 -07:00
|
|
|
task::send(handle.chan, exec(lib_path,
|
|
|
|
prog,
|
|
|
|
clone_ivecstr(ivec::from_vec(args)),
|
|
|
|
task::clone_chan(ch)));
|
2011-07-27 14:19:39 +02:00
|
|
|
let resp = task::recv(p);
|
2011-07-27 18:11:40 -07:00
|
|
|
let output = readclose(resp.outfd);
|
|
|
|
let errput = readclose(resp.errfd);
|
|
|
|
let status = os::waitpid(resp.pid);
|
|
|
|
ret {status: status, out: output, err: errput};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn readclose(fd: int) -> str {
|
2011-07-25 21:25:32 -07:00
|
|
|
// Copied from run::program_output
|
2011-07-27 18:11:40 -07:00
|
|
|
let file = os::fd_FILE(fd);
|
2011-07-29 13:31:44 +02:00
|
|
|
let reader = io::new_reader(io::FILE_buf_reader(file, option::none));
|
2011-07-27 14:19:39 +02:00
|
|
|
let buf = "";
|
|
|
|
while !reader.eof() {
|
|
|
|
let bytes = reader.read_bytes(4096u);
|
2011-07-25 21:25:32 -07:00
|
|
|
buf += str::unsafe_from_bytes(bytes);
|
|
|
|
}
|
2011-07-27 18:11:40 -07:00
|
|
|
os::libc::fclose(file);
|
|
|
|
ret buf;
|
2011-07-25 21:25:32 -07:00
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn worker(p: port[request]) {
|
2011-07-28 23:24:07 -07:00
|
|
|
|
2011-07-29 15:11:14 -07:00
|
|
|
// FIXME (787): If we declare this inside of the while loop and then
|
2011-07-28 23:24:07 -07:00
|
|
|
// break out of it before it's ever initialized (i.e. we don't run
|
|
|
|
// any tests), then the cleanups will puke, so we're initializing it
|
|
|
|
// here with defaults.
|
|
|
|
let execparms = {
|
|
|
|
lib_path: "",
|
|
|
|
prog: "",
|
|
|
|
args: ~[],
|
|
|
|
// This works because a NULL box is ignored during cleanup
|
|
|
|
respchan: unsafe::reinterpret_cast(0)
|
|
|
|
};
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
while true {
|
2011-07-28 23:24:07 -07:00
|
|
|
// FIXME: Sending strings across channels seems to still
|
|
|
|
// leave them refed on the sender's end, which causes problems if
|
|
|
|
// the receiver's poniters outlive the sender's. Here we clone
|
|
|
|
// everything and let the originals go out of scope before sending
|
|
|
|
// a response.
|
|
|
|
execparms = {
|
2011-07-29 15:20:24 -07:00
|
|
|
// FIXME (785): The 'discriminant' of an alt expression has
|
|
|
|
// the same scope as the alt expression itself, so we have to
|
|
|
|
// put the entire alt in another block to make sure the exec
|
2011-07-28 23:24:07 -07:00
|
|
|
// message goes out of scope. Seems like the scoping rules for
|
|
|
|
// the alt discriminant are wrong.
|
|
|
|
alt task::recv(p) {
|
|
|
|
exec(lib_path, prog, args, respchan) {
|
|
|
|
{
|
|
|
|
lib_path: clone_str(lib_path),
|
|
|
|
prog: clone_str(prog),
|
|
|
|
args: clone_ivecstr(args),
|
|
|
|
respchan: respchan
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stop. { ret }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// This is copied from run::start_program
|
|
|
|
let pipe_in = os::pipe();
|
|
|
|
let pipe_out = os::pipe();
|
|
|
|
let pipe_err = os::pipe();
|
|
|
|
let spawnproc =
|
|
|
|
bind run::spawn_process(execparms.prog,
|
|
|
|
ivec::to_vec(execparms.args),
|
|
|
|
pipe_in.in,
|
|
|
|
pipe_out.out,
|
|
|
|
pipe_err.out);
|
|
|
|
let pid = with_lib_path(execparms.lib_path, spawnproc);
|
|
|
|
os::libc::close(pipe_in.in);
|
|
|
|
os::libc::close(pipe_in.out);
|
|
|
|
os::libc::close(pipe_out.out);
|
|
|
|
os::libc::close(pipe_err.out);
|
2011-07-29 14:03:36 -07:00
|
|
|
if pid == -1 {
|
|
|
|
os::libc::close(pipe_out.in);
|
|
|
|
os::libc::close(pipe_err.in);
|
|
|
|
fail;
|
|
|
|
}
|
2011-07-28 23:24:07 -07:00
|
|
|
task::send(execparms.respchan,
|
|
|
|
{pid: pid,
|
|
|
|
outfd: pipe_out.in,
|
|
|
|
errfd: pipe_err.in});
|
2011-07-25 21:25:32 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn with_lib_path[T](path: &str, f: fn() -> T ) -> T {
|
|
|
|
let maybe_oldpath = getenv(lib_path_env_var());
|
2011-07-25 21:25:32 -07:00
|
|
|
append_lib_path(path);
|
2011-07-27 14:19:39 +02:00
|
|
|
let res = f();
|
2011-07-25 21:25:32 -07:00
|
|
|
if option::is_some(maybe_oldpath) {
|
|
|
|
export_lib_path(option::get(maybe_oldpath));
|
|
|
|
} else {
|
|
|
|
// FIXME: This should really be unset but we don't have that yet
|
|
|
|
export_lib_path("");
|
|
|
|
}
|
|
|
|
ret res;
|
|
|
|
}
|
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn append_lib_path(path: &str) { export_lib_path(make_new_path(path)); }
|
2011-07-25 21:25:32 -07:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
fn export_lib_path(path: &str) { setenv(lib_path_env_var(), path); }
|
2011-07-25 21:25:32 -07:00
|
|
|
}
|
|
|
|
|
The Big Test Suite Overhaul
This replaces the make-based test runner with a set of Rust-based test
runners. I believe that all existing functionality has been
preserved. The primary objective is to dogfood the Rust test
framework.
A few main things happen here:
1) The run-pass/lib-* tests are all moved into src/test/stdtest. This
is a standalone test crate intended for all standard library tests. It
compiles to build/test/stdtest.stageN.
2) rustc now compiles into yet another build artifact, this one a test
runner that runs any tests contained directly in the rustc crate. This
allows much more fine-grained unit testing of the compiler. It
compiles to build/test/rustctest.stageN.
3) There is a new custom test runner crate at src/test/compiletest
that reproduces all the functionality for running the compile-fail,
run-fail, run-pass and bench tests while integrating with Rust's test
framework. It compiles to build/test/compiletest.stageN.
4) The build rules have been completely changed to use the new test
runners, while also being less redundant, following the example of the
recent stageN.mk rewrite.
It adds two new features to the cfail/rfail/rpass/bench tests:
1) Tests can specify multiple 'error-pattern' directives which must be
satisfied in order.
2) Tests can specify a 'compile-flags' directive which will make the
test runner provide additional command line arguments to rustc.
There are some downsides, the primary being that Rust has to be
functioning pretty well just to run _any_ tests, which I imagine will
be the source of some frustration when the entire test suite
breaks. Will also cause some headaches during porting.
Not having individual make rules, each rpass, etc test no longer
remembers between runs whether it completed successfully. As a result,
it's not possible to incrementally fix multiple tests by just running
'make check', fixing a test, and repeating without re-running all the
tests contained in the test runner. Instead you can filter just the
tests you want to run by using the TESTNAME environment variable.
This also dispenses with the ability to run stage0 tests, but they
tended to be broken more often than not anyway.
2011-07-12 19:01:09 -07:00
|
|
|
// Local Variables:
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
|
|
|
// End:
|