Skip to content

Commit

Permalink
Add JIT testing to compiletest with --jit
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Aug 29, 2012
1 parent b74e625 commit 25a0f74
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/compiletest/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@ type config = {
// Flags to pass to the compiler
rustcflags: Option<~str>,

// Run tests using the JIT
jit: bool,

// Explain what's going on
verbose: bool};
verbose: bool

};
5 changes: 4 additions & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ fn parse_config(args: ~[~str]) -> config {
getopts::reqopt(~"mode"), getopts::optflag(~"ignored"),
getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"),
getopts::optflag(~"verbose"),
getopts::optopt(~"logfile")];
getopts::optopt(~"logfile"),
getopts::optflag(~"jit")];

assert (vec::is_not_empty(args));
let args_ = vec::tail(args);
Expand Down Expand Up @@ -64,6 +65,7 @@ fn parse_config(args: ~[~str]) -> config {
|s| Path(s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
jit: getopts::opt_present(matches, ~"jit"),
verbose: getopts::opt_present(matches, ~"verbose")};
}

Expand All @@ -81,6 +83,7 @@ fn log_config(config: config) {
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)));
logv(c, fmt!("jit: %b", config.jit));
logv(c, fmt!("verbose: %b", config.verbose));
logv(c, fmt!("\n"));
}
Expand Down
35 changes: 27 additions & 8 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ fn run_cfail_test(config: config, props: test_props, testfile: &Path) {
}

fn run_rfail_test(config: config, props: test_props, testfile: &Path) {
let mut procres = compile_test(config, props, testfile);
let procres = if !config.jit {
let procres = compile_test(config, props, testfile);

if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }

procres = exec_compiled_test(config, props, testfile);
exec_compiled_test(config, props, testfile)
} else {
jit_test(config, props, testfile)
};

// The value our Makefile configures valgrind to return on failure
const valgrind_err: int = 100;
Expand All @@ -76,13 +80,19 @@ fn check_correct_failure_status(procres: procres) {
}

fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
let mut procres = compile_test(config, props, testfile);
if !config.jit {
let mut procres = compile_test(config, props, testfile);

if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }

if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
procres = exec_compiled_test(config, props, testfile);

procres = exec_compiled_test(config, props, testfile);
if procres.status != 0 { fatal_procres(~"test run failed!", procres); }
} else {
let mut procres = jit_test(config, props, testfile);

if procres.status != 0 { fatal_procres(~"test run failed!", procres); }
if procres.status != 0 { fatal_procres(~"jit failed!", procres); }
}
}

fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
Expand Down Expand Up @@ -295,10 +305,19 @@ type procres = {status: int, stdout: ~str, stderr: ~str, cmdline: ~str};

fn compile_test(config: config, props: test_props,
testfile: &Path) -> procres {
compile_test_(config, props, testfile, [])
}

fn jit_test(config: config, props: test_props, testfile: &Path) -> procres {
compile_test_(config, props, testfile, [~"--jit"])
}

fn compile_test_(config: config, props: test_props,
testfile: &Path, extra_args: &[~str]) -> procres {
let link_args = ~[~"-L", aux_output_dir_name(config, testfile).to_str()];
compose_and_run_compiler(
config, props, testfile,
make_compile_args(config, props, link_args,
make_compile_args(config, props, link_args + extra_args,
make_exe_name, testfile),
None)
}
Expand Down

0 comments on commit 25a0f74

Please sign in to comment.