Skip to content

Commit 5c1338a

Browse files
committed
add ability to run multi-crate tests, run tests with --inline
1 parent aa77cf3 commit 5c1338a

File tree

8 files changed

+80
-24
lines changed

8 files changed

+80
-24
lines changed

mk/tests.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,9 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
253253
--compile-lib-path $$(HLIB$(1)_H_$(3)) \
254254
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
255255
--rustc-path $$(HBIN$(1)_H_$(3))/rustc$$(X) \
256+
--aux-base $$(S)src/test/aux/ \
256257
--stage-id stage$(1)-$(2) \
257-
--rustcflags "$$(CFG_RUSTC_FLAGS) --target=$(2)" \
258+
--rustcflags "$$(CFG_RUSTC_FLAGS) --target=$(2) --inline" \
258259
$$(CTEST_TESTARGS)
259260

260261
CFAIL_ARGS$(1)-T-$(2)-H-$(3) := \

src/comp/metadata/astencode.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn visit_ids(item: @ast::item, vfn: fn@(ast::node_id)) {
134134
},
135135

136136
visit_item: fn@(i: @ast::item) {
137-
vfn(i.id)
137+
vfn(i.id);
138138
},
139139

140140
visit_local: fn@(l: @ast::local) {
@@ -772,7 +772,8 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
772772
let id0 = entry_doc[c::tag_table_id].as_int();
773773
let id = xcx.tr_id(id0);
774774

775-
#debug[">> Side table document with tag 0x%x found for id %d (orig %d)",
775+
#debug[">> Side table document with tag 0x%x \
776+
found for id %d (orig %d)",
776777
tag, id, id0];
777778

778779
if tag == (c::tag_table_mutbl as uint) {

src/compiletest/common.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,43 @@ import option;
22

33
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }
44

5-
type config =
5+
type config = {
66
// The library paths required for running the compiler
7+
compile_lib_path: str,
8+
79
// The library paths required for running compiled programs
10+
run_lib_path: str,
11+
812
// The rustc executable
13+
rustc_path: str,
14+
915
// The directory containing the tests to run
16+
src_base: str,
17+
1018
// The directory where programs should be built
19+
build_base: str,
20+
21+
// Directory for auxiliary libraries
22+
aux_base: str,
23+
1124
// The name of the stage being built (stage1, etc)
25+
stage_id: str,
26+
1227
// The test mode, compile-fail, run-fail, run-pass
28+
mode: mode,
29+
1330
// Run ignored tests
31+
run_ignored: bool,
32+
1433
// Only run tests that match this filter
34+
filter: option<str>,
35+
1536
// A command line to prefix program execution with,
1637
// for running under valgrind
38+
runtool: option<str>,
39+
1740
// Flags to pass to the compiler
41+
rustcflags: option<str>,
42+
1843
// Explain what's going on
19-
{compile_lib_path: str,
20-
run_lib_path: str,
21-
rustc_path: str,
22-
src_base: str,
23-
build_base: str,
24-
stage_id: str,
25-
mode: mode,
26-
run_ignored: bool,
27-
filter: option<str>,
28-
runtool: option<str>,
29-
rustcflags: option<str>,
30-
verbose: bool};
44+
verbose: bool};

src/compiletest/compiletest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ fn parse_config(args: [str]) -> config {
3535
let opts =
3636
[getopts::reqopt("compile-lib-path"), getopts::reqopt("run-lib-path"),
3737
getopts::reqopt("rustc-path"), getopts::reqopt("src-base"),
38-
getopts::reqopt("build-base"), getopts::reqopt("stage-id"),
38+
getopts::reqopt("build-base"), getopts::reqopt("aux-base"),
39+
getopts::reqopt("stage-id"),
3940
getopts::reqopt("mode"), getopts::optflag("ignored"),
4041
getopts::optopt("runtool"), getopts::optopt("rustcflags"),
4142
getopts::optflag("verbose")];
@@ -53,6 +54,7 @@ fn parse_config(args: [str]) -> config {
5354
rustc_path: getopts::opt_str(match, "rustc-path"),
5455
src_base: getopts::opt_str(match, "src-base"),
5556
build_base: getopts::opt_str(match, "build-base"),
57+
aux_base: getopts::opt_str(match, "aux-base"),
5658
stage_id: getopts::opt_str(match, "stage-id"),
5759
mode: str_mode(getopts::opt_str(match, "mode")),
5860
run_ignored: getopts::opt_present(match, "ignored"),

src/compiletest/header.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ type test_props = {
1717
compile_flags: option<str>,
1818
// If present, the name of a file that this test should match when
1919
// pretty-printed
20-
pp_exact: option<str>
20+
pp_exact: option<str>,
21+
// Modules from aux directory that should be compiled
22+
aux_builds: [str]
2123
};
2224

2325
// Load any test directives embedded in the file
2426
fn load_props(testfile: str) -> test_props {
2527
let error_patterns = [];
28+
let aux_builds = [];
2629
let compile_flags = option::none;
2730
let pp_exact = option::none;
2831
iter_header(testfile) {|ln|
@@ -38,11 +41,16 @@ fn load_props(testfile: str) -> test_props {
3841
if option::is_none(pp_exact) {
3942
pp_exact = parse_pp_exact(ln, testfile);
4043
}
44+
45+
option::may(parse_aux_build(ln)) {|ab|
46+
aux_builds += [ab];
47+
}
4148
};
4249
ret {
4350
error_patterns: error_patterns,
4451
compile_flags: compile_flags,
45-
pp_exact: pp_exact
52+
pp_exact: pp_exact,
53+
aux_builds: aux_builds
4654
};
4755
}
4856

@@ -82,6 +90,10 @@ fn parse_error_pattern(line: str) -> option<str> {
8290
parse_name_value_directive(line, "error-pattern")
8391
}
8492

93+
fn parse_aux_build(line: str) -> option<str> {
94+
parse_name_value_directive(line, "aux-build")
95+
}
96+
8597
fn parse_compile_flags(line: str) -> option<str> {
8698
parse_name_value_directive(line, "compile-flags")
8799
}

src/compiletest/runtest.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ actual:\n\
179179

180180
fn make_typecheck_args(config: config, _testfile: str) -> procargs {
181181
let prog = config.rustc_path;
182-
let args = ["-", "--no-trans", "--lib"];
182+
let args = ["-", "--no-trans", "--lib", "-L", config.build_base];
183183
args += split_maybe_args(config.rustcflags);
184184
ret {prog: prog, args: args};
185185
}
@@ -287,7 +287,16 @@ type procres = {status: int, stdout: str, stderr: str, cmdline: str};
287287

288288
fn compile_test(config: config, props: test_props,
289289
testfile: str) -> procres {
290-
compose_and_run(config, testfile, bind make_compile_args(_, props, _),
290+
vec::iter(props.aux_builds) {|rel_ab|
291+
let abs_ab = fs::connect(config.aux_base, rel_ab);
292+
compose_and_run(config, abs_ab,
293+
make_compile_args(_, props, ["--lib"],
294+
make_lib_name, _),
295+
config.compile_lib_path, option::none);
296+
}
297+
298+
compose_and_run(config, testfile,
299+
make_compile_args(_, props, [], make_exe_name, _),
291300
config.compile_lib_path, option::none)
292301
}
293302

@@ -305,15 +314,23 @@ fn compose_and_run(config: config, testfile: str,
305314
procargs.prog, procargs.args, input);
306315
}
307316

308-
fn make_compile_args(config: config, props: test_props, testfile: str) ->
317+
fn make_compile_args(config: config, props: test_props, extras: [str],
318+
xform: fn(config, str) -> str, testfile: str) ->
309319
procargs {
310320
let prog = config.rustc_path;
311-
let args = [testfile, "-o", make_exe_name(config, testfile)];
321+
let args = [testfile, "-o", xform(config, testfile),
322+
"-L", config.build_base] + extras;
312323
args += split_maybe_args(config.rustcflags);
313324
args += split_maybe_args(props.compile_flags);
314325
ret {prog: prog, args: args};
315326
}
316327

328+
fn make_lib_name(config: config, testfile: str) -> str {
329+
// what we return here is not particularly important, as it
330+
// happens; rustc ignores everything except for the directory.
331+
output_base_name(config, testfile)
332+
}
333+
317334
fn make_exe_name(config: config, testfile: str) -> str {
318335
output_base_name(config, testfile) + os::exec_suffix()
319336
}

src/libstd/serialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fn test_option_int() {
387387
}
388388

389389
fn deserialize_0<S: deserializer>(s: S) -> option<int> {
390-
s.read_enum("option") {||
390+
s.read_enum("core::option::t") {||
391391
s.read_enum_variant {|i|
392392
alt check i {
393393
0u { none }

src/test/aux/cci_iter_lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[inline]
2+
fn iter<T>(v: [T], f: fn(T)) {
3+
let i = 0u;
4+
let n = vec::len(v);
5+
while i < n {
6+
f(v[i]);
7+
i += 1u;
8+
}
9+
}

0 commit comments

Comments
 (0)