Skip to content

Commit f08e1c7

Browse files
committed
Recurse to find test files in any subdirectory of the base path. If a
subdirectory contains `compiletest-ignore-dir`, then ignore it.
1 parent 1adcefd commit f08e1c7

File tree

3 files changed

+62
-29
lines changed

3 files changed

+62
-29
lines changed

mk/tests.mk

+16-15
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,22 @@ $(foreach host,$(CFG_HOST), \
458458
# Rules for the compiletest tests (rpass, rfail, etc.)
459459
######################################################################
460460

461-
RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
462-
RPASS_VALGRIND_RS := $(wildcard $(S)src/test/run-pass-valgrind/*.rs)
463-
RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
464-
RFAIL_FULL_RS := $(wildcard $(S)src/test/run-fail-fulldeps/*.rs)
465-
CFAIL_FULL_RS := $(wildcard $(S)src/test/compile-fail-fulldeps/*.rs)
466-
RFAIL_RS := $(wildcard $(S)src/test/run-fail/*.rs)
467-
CFAIL_RS := $(wildcard $(S)src/test/compile-fail/*.rs)
468-
PFAIL_RS := $(wildcard $(S)src/test/parse-fail/*.rs)
469-
PRETTY_RS := $(wildcard $(S)src/test/pretty/*.rs)
470-
DEBUGINFO_GDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
471-
DEBUGINFO_LLDB_RS := $(wildcard $(S)src/test/debuginfo/*.rs)
472-
CODEGEN_RS := $(wildcard $(S)src/test/codegen/*.rs)
473-
CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
474-
CODEGEN_UNITS_RS := $(wildcard $(S)src/test/codegen-units/*.rs)
475-
RUSTDOCCK_RS := $(wildcard $(S)src/test/rustdoc/*.rs)
461+
RPASS_RS := $(call rwildcard,$(S)src/test/run-pass/,*.rs)
462+
RPASS_VALGRIND_RS := $(call rwildcard,$(S)src/test/run-pass-valgrind/,*.rs)
463+
RPASS_FULL_RS := $(call rwildcard,$(S)src/test/run-pass-fulldeps/,*.rs)
464+
RFAIL_FULL_RS := $(call rwildcard,$(S)src/test/run-fail-fulldeps/,*.rs)
465+
CFAIL_FULL_RS := $(call rwildcard,$(S)src/test/compile-fail-fulldeps/,*.rs)
466+
RFAIL_RS := $(call rwildcard,$(S)src/test/run-fail/,*.rs)
467+
RFAIL_RS := $(call rwildcard,$(S)src/test/run-fail/,*.rs)
468+
CFAIL_RS := $(call rwildcard,$(S)src/test/compile-fail/,*.rs)
469+
PFAIL_RS := $(call rwildcard,$(S)src/test/parse-fail/,*.rs)
470+
PRETTY_RS := $(call rwildcard,$(S)src/test/pretty/,*.rs)
471+
DEBUGINFO_GDB_RS := $(call rwildcard,$(S)src/test/debuginfo/,*.rs)
472+
DEBUGINFO_LLDB_RS := $(call rwildcard,$(S)src/test/debuginfo/,*.rs)
473+
CODEGEN_RS := $(call rwildcard,$(S)src/test/codegen/,*.rs)
474+
CODEGEN_CC := $(call rwildcard,$(S)src/test/codegen/,*.cc)
475+
CODEGEN_UNITS_RS := $(call rwildcard,$(S)src/test/codegen-units/,*.rs)
476+
RUSTDOCCK_RS := $(call rwildcard,$(S)src/test/rustdoc/,*.rs)
476477

477478
RPASS_TESTS := $(RPASS_RS)
478479
RPASS_VALGRIND_TESTS := $(RPASS_VALGRIND_RS)

src/compiletest/compiletest.rs

+26-11
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,16 @@ fn collect_tests_from_dir(config: &Config,
284284
relative_dir_path: &Path,
285285
tests: &mut Vec<test::TestDescAndFn>)
286286
-> io::Result<()> {
287+
// Ignore directories that contain a file
288+
// `compiletest-ignore-dir`.
289+
for file in try!(fs::read_dir(dir)) {
290+
let file = try!(file);
291+
if file.file_name() == *"compiletest-ignore-dir" {
292+
return Ok(());
293+
}
294+
}
295+
296+
let dirs = try!(fs::read_dir(dir));
287297
for file in dirs {
288298
let file = try!(file);
289299
let file_path = file.path();
@@ -295,6 +305,13 @@ fn collect_tests_from_dir(config: &Config,
295305
relative_dir: relative_dir_path.to_path_buf(),
296306
};
297307
tests.push(make_test(config, &paths))
308+
} else if file_path.is_dir() {
309+
let relative_file_path = relative_dir_path.join(file.file_name());
310+
try!(collect_tests_from_dir(config,
311+
base,
312+
&file_path,
313+
&relative_file_path,
314+
tests));
298315
}
299316
}
300317
Ok(())
@@ -338,17 +355,15 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn
338355
}
339356
}
340357

341-
pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
342-
343-
// Try to elide redundant long paths
344-
fn shorten(path: &Path) -> String {
345-
let filename = path.file_name().unwrap().to_str();
346-
let p = path.parent().unwrap();
347-
let dir = p.file_name().unwrap().to_str();
348-
format!("{}/{}", dir.unwrap_or(""), filename.unwrap_or(""))
349-
}
350-
351-
test::DynTestName(format!("[{}] {}", config.mode, shorten(testfile)))
358+
pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName {
359+
// Convert a complete path to something like
360+
//
361+
// run-pass/foo/bar/baz.rs
362+
let path =
363+
PathBuf::from(config.mode.to_string())
364+
.join(&testpaths.relative_dir)
365+
.join(&testpaths.file.file_name().unwrap());
366+
test::DynTestName(format!("[{}] {}", config.mode, path.display()))
352367
}
353368

354369
pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::TestFn {

src/compiletest/runtest.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,21 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
12141214
}
12151215
}
12161216

1217+
fn compute_aux_test_paths(config: &Config,
1218+
testpaths: &TestPaths,
1219+
rel_ab: &str)
1220+
-> TestPaths
1221+
{
1222+
let abs_ab = config.aux_base.join(rel_ab);
1223+
TestPaths {
1224+
file: abs_ab,
1225+
base: testpaths.base.clone(),
1226+
relative_dir: Path::new(rel_ab).parent()
1227+
.map(|p| p.to_path_buf())
1228+
.unwrap_or_else(|| PathBuf::new())
1229+
}
1230+
}
1231+
12171232
fn compose_and_run_compiler(config: &Config, props: &TestProps,
12181233
testpaths: &TestPaths, args: ProcArgs,
12191234
input: Option<String>) -> ProcRes {
@@ -1501,9 +1516,11 @@ fn output_testname(filepath: &Path) -> PathBuf {
15011516
PathBuf::from(filepath.file_stem().unwrap())
15021517
}
15031518

1504-
fn output_base_name(config: &Config, testfile: &Path) -> PathBuf {
1505-
config.build_base
1506-
.join(&output_testname(testfile))
1519+
fn output_base_name(config: &Config, testpaths: &TestPaths) -> PathBuf {
1520+
let dir = config.build_base.join(&testpaths.relative_dir);
1521+
fs::create_dir_all(&dir).unwrap();
1522+
dir
1523+
.join(&output_testname(&testpaths.file))
15071524
.with_extension(&config.stage_id)
15081525
}
15091526

0 commit comments

Comments
 (0)