Skip to content

Commit 4088952

Browse files
committed
Allow skipping tests from the commandline
1 parent 255ec65 commit 4088952

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

build_system/main.rs

+8
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ fn main() {
9090
let mut sysroot_kind = SysrootKind::Clif;
9191
let mut use_unstable_features = true;
9292
let mut frozen = false;
93+
let mut skip_tests = vec![];
9394
let mut use_backend = None;
9495
while let Some(arg) = args.next().as_deref() {
9596
match arg {
@@ -115,6 +116,12 @@ fn main() {
115116
}
116117
"--no-unstable-features" => use_unstable_features = false,
117118
"--frozen" => frozen = true,
119+
"--skip-test" => {
120+
// FIXME check that all passed in tests actually exist
121+
skip_tests.push(args.next().unwrap_or_else(|| {
122+
arg_error!("--skip-test requires argument");
123+
}));
124+
}
118125
"--use-backend" => {
119126
use_backend = Some(match args.next() {
120127
Some(name) => name,
@@ -218,6 +225,7 @@ fn main() {
218225
channel,
219226
sysroot_kind,
220227
use_unstable_features,
228+
&skip_tests.iter().map(|test| &**test).collect::<Vec<_>>(),
221229
&cg_clif_dylib,
222230
&bootstrap_host_compiler,
223231
rustup_toolchain_name.as_deref(),

build_system/tests.rs

+19-8
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ struct TestCase {
1919
}
2020

2121
enum TestCaseCmd {
22-
Custom { func: &'static dyn Fn(&TestRunner) },
22+
Custom { func: &'static dyn Fn(&TestRunner<'_>) },
2323
BuildLib { source: &'static str, crate_types: &'static str },
2424
BuildBinAndRun { source: &'static str, args: &'static [&'static str] },
2525
JitBin { source: &'static str, args: &'static str },
2626
}
2727

2828
impl TestCase {
2929
// FIXME reduce usage of custom test case commands
30-
const fn custom(config: &'static str, func: &'static dyn Fn(&TestRunner)) -> Self {
30+
const fn custom(config: &'static str, func: &'static dyn Fn(&TestRunner<'_>)) -> Self {
3131
Self { config, cmd: TestCaseCmd::Custom { func } }
3232
}
3333

@@ -247,6 +247,7 @@ pub(crate) fn run_tests(
247247
channel: &str,
248248
sysroot_kind: SysrootKind,
249249
use_unstable_features: bool,
250+
skip_tests: &[&str],
250251
cg_clif_dylib: &CodegenBackend,
251252
bootstrap_host_compiler: &Compiler,
252253
rustup_toolchain_name: Option<&str>,
@@ -256,7 +257,7 @@ pub(crate) fn run_tests(
256257
get_default_sysroot(&bootstrap_host_compiler.rustc).join("lib/rustlib/src/rust");
257258
assert!(stdlib_source.exists());
258259

259-
if config::get_bool("testsuite.no_sysroot") {
260+
if config::get_bool("testsuite.no_sysroot") && !skip_tests.contains(&"testsuite.no_sysroot") {
260261
let target_compiler = build_sysroot::build_sysroot(
261262
dirs,
262263
channel,
@@ -271,6 +272,7 @@ pub(crate) fn run_tests(
271272
dirs.clone(),
272273
target_compiler,
273274
use_unstable_features,
275+
skip_tests,
274276
bootstrap_host_compiler.triple == target_triple,
275277
stdlib_source.clone(),
276278
);
@@ -281,8 +283,10 @@ pub(crate) fn run_tests(
281283
eprintln!("[SKIP] no_sysroot tests");
282284
}
283285

284-
let run_base_sysroot = config::get_bool("testsuite.base_sysroot");
285-
let run_extended_sysroot = config::get_bool("testsuite.extended_sysroot");
286+
let run_base_sysroot = config::get_bool("testsuite.base_sysroot")
287+
&& !skip_tests.contains(&"testsuite.base_sysroot");
288+
let run_extended_sysroot = config::get_bool("testsuite.extended_sysroot")
289+
&& !skip_tests.contains(&"testsuite.extended_sysroot");
286290

287291
if run_base_sysroot || run_extended_sysroot {
288292
let mut target_compiler = build_sysroot::build_sysroot(
@@ -302,6 +306,7 @@ pub(crate) fn run_tests(
302306
dirs.clone(),
303307
target_compiler,
304308
use_unstable_features,
309+
skip_tests,
305310
bootstrap_host_compiler.triple == target_triple,
306311
stdlib_source,
307312
);
@@ -320,20 +325,22 @@ pub(crate) fn run_tests(
320325
}
321326
}
322327

323-
struct TestRunner {
328+
struct TestRunner<'a> {
324329
is_native: bool,
325330
jit_supported: bool,
326331
use_unstable_features: bool,
332+
skip_tests: &'a [&'a str],
327333
dirs: Dirs,
328334
target_compiler: Compiler,
329335
stdlib_source: PathBuf,
330336
}
331337

332-
impl TestRunner {
338+
impl<'a> TestRunner<'a> {
333339
fn new(
334340
dirs: Dirs,
335341
mut target_compiler: Compiler,
336342
use_unstable_features: bool,
343+
skip_tests: &'a [&'a str],
337344
is_native: bool,
338345
stdlib_source: PathBuf,
339346
) -> Self {
@@ -360,6 +367,7 @@ impl TestRunner {
360367
is_native,
361368
jit_supported,
362369
use_unstable_features,
370+
skip_tests,
363371
dirs,
364372
target_compiler,
365373
stdlib_source,
@@ -372,7 +380,10 @@ impl TestRunner {
372380
let tag = tag.to_uppercase();
373381
let is_jit_test = tag == "JIT";
374382

375-
if !config::get_bool(config) || (is_jit_test && !self.jit_supported) {
383+
if !config::get_bool(config)
384+
|| (is_jit_test && !self.jit_supported)
385+
|| self.skip_tests.contains(&config)
386+
{
376387
eprintln!("[{tag}] {testname} (skipped)");
377388
continue;
378389
} else {

build_system/usage.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ The build system of cg_clif.
33
USAGE:
44
./y.sh prepare [--out-dir DIR] [--download-dir DIR]
55
./y.sh build [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
6-
./y.sh test [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
6+
./y.sh test [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen] [--skip-test TESTNAME]
77
./y.sh abi-cafe [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
88
./y.sh bench [--debug] [--sysroot none|clif|llvm] [--out-dir DIR] [--download-dir DIR] [--no-unstable-features] [--frozen]
99

@@ -32,6 +32,9 @@ OPTIONS:
3232
--frozen
3333
Require Cargo.lock and cache are up to date
3434

35+
--skip-test TESTNAME
36+
Skip testing the TESTNAME test. The test name format is the same as config.txt.
37+
3538
--use-backend NAME
3639
Use the existing Cranelift (or other) backend of the rustc with which we built.
3740
Warning: This is meant for use in rust's CI only!

0 commit comments

Comments
 (0)