Skip to content

Commit 25a0f74

Browse files
committed
Add JIT testing to compiletest with --jit
1 parent b74e625 commit 25a0f74

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

src/compiletest/common.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,10 @@ type config = {
4343
// Flags to pass to the compiler
4444
rustcflags: Option<~str>,
4545

46+
// Run tests using the JIT
47+
jit: bool,
48+
4649
// Explain what's going on
47-
verbose: bool};
50+
verbose: bool
51+
52+
};

src/compiletest/compiletest.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ fn parse_config(args: ~[~str]) -> config {
3232
getopts::reqopt(~"mode"), getopts::optflag(~"ignored"),
3333
getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"),
3434
getopts::optflag(~"verbose"),
35-
getopts::optopt(~"logfile")];
35+
getopts::optopt(~"logfile"),
36+
getopts::optflag(~"jit")];
3637

3738
assert (vec::is_not_empty(args));
3839
let args_ = vec::tail(args);
@@ -64,6 +65,7 @@ fn parse_config(args: ~[~str]) -> config {
6465
|s| Path(s)),
6566
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
6667
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
68+
jit: getopts::opt_present(matches, ~"jit"),
6769
verbose: getopts::opt_present(matches, ~"verbose")};
6870
}
6971

@@ -81,6 +83,7 @@ fn log_config(config: config) {
8183
logv(c, fmt!("filter: %s", opt_str(config.filter)));
8284
logv(c, fmt!("runtool: %s", opt_str(config.runtool)));
8385
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
86+
logv(c, fmt!("jit: %b", config.jit));
8487
logv(c, fmt!("verbose: %b", config.verbose));
8588
logv(c, fmt!("\n"));
8689
}

src/compiletest/runtest.rs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ fn run_cfail_test(config: config, props: test_props, testfile: &Path) {
4848
}
4949

5050
fn run_rfail_test(config: config, props: test_props, testfile: &Path) {
51-
let mut procres = compile_test(config, props, testfile);
51+
let procres = if !config.jit {
52+
let procres = compile_test(config, props, testfile);
5253

53-
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
54+
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
5455
55-
procres = exec_compiled_test(config, props, testfile);
56+
exec_compiled_test(config, props, testfile)
57+
} else {
58+
jit_test(config, props, testfile)
59+
};
5660
5761
// The value our Makefile configures valgrind to return on failure
5862
const valgrind_err: int = 100;
@@ -76,13 +80,19 @@ fn check_correct_failure_status(procres: procres) {
7680
}
7781

7882
fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
79-
let mut procres = compile_test(config, props, testfile);
83+
if !config.jit {
84+
let mut procres = compile_test(config, props, testfile);
85+
86+
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
8087
81-
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
88+
procres = exec_compiled_test(config, props, testfile);
8289
83-
procres = exec_compiled_test(config, props, testfile);
90+
if procres.status != 0 { fatal_procres(~"test run failed!", procres); }
91+
} else {
92+
let mut procres = jit_test(config, props, testfile);
8493
85-
if procres.status != 0 { fatal_procres(~"test run failed!", procres); }
94+
if procres.status != 0 { fatal_procres(~"jit failed!", procres); }
95+
}
8696
}
8797
8898
fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
@@ -295,10 +305,19 @@ type procres = {status: int, stdout: ~str, stderr: ~str, cmdline: ~str};
295305

296306
fn compile_test(config: config, props: test_props,
297307
testfile: &Path) -> procres {
308+
compile_test_(config, props, testfile, [])
309+
}
310+
311+
fn jit_test(config: config, props: test_props, testfile: &Path) -> procres {
312+
compile_test_(config, props, testfile, [~"--jit"])
313+
}
314+
315+
fn compile_test_(config: config, props: test_props,
316+
testfile: &Path, extra_args: &[~str]) -> procres {
298317
let link_args = ~[~"-L", aux_output_dir_name(config, testfile).to_str()];
299318
compose_and_run_compiler(
300319
config, props, testfile,
301-
make_compile_args(config, props, link_args,
320+
make_compile_args(config, props, link_args + extra_args,
302321
make_exe_name, testfile),
303322
None)
304323
}

0 commit comments

Comments
 (0)