Skip to content

Commit 5fe2286

Browse files
committed
Add a skip-huge option
1 parent 52c5dc4 commit 5fe2286

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/etc/test-float-parse/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub struct Config {
4848
/// Failures per test
4949
pub max_failures: Option<u64>,
5050
pub fuzz_count: Option<u64>,
51+
pub skip_huge: bool,
5152
}
5253

5354
/// Collect, filter, and launch all tests.
@@ -60,26 +61,34 @@ pub fn run(cfg: Config, include: &[String], exclude: &[String]) -> ExitCode {
6061
rayon::ThreadPoolBuilder::new().num_threads(threads).build_global().unwrap();
6162

6263
let mut tests = register_tests();
64+
let initial_tests: Vec<_> = tests.iter().map(|t| t.name.clone()).collect();
6365

6466
let unmatched: Vec<_> = include
6567
.iter()
6668
.chain(exclude.iter())
6769
.filter(|filt| !tests.iter().any(|t| t.matches(filt)))
6870
.collect();
71+
6972
assert!(
7073
unmatched.is_empty(),
7174
"filters were provided that have no matching tests: {unmatched:#?}"
7275
);
76+
7377
tests.retain(|test| !exclude.iter().any(|exc| test.matches(exc)));
7478

79+
if cfg.skip_huge {
80+
tests.retain(|test| !test.is_huge_test());
81+
}
82+
7583
if !include.is_empty() {
7684
tests.retain(|test| include.iter().any(|inc| test.matches(inc)));
7785
}
7886

7987
let (logfile, logfile_name) = create_log_file();
8088
let mut out = Tee { f: &logfile };
8189

82-
for exc in exclude {
90+
for exc in initial_tests.iter().filter(|orig_name| !tests.iter().any(|t| t.name == **orig_name))
91+
{
8392
out.write_sout(format!("Skipping test '{exc}'"));
8493
}
8594

src/etc/test-float-parse/src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use test_float_parse as tfp;
55

66
static HELP: &str = r#"Usage:
77
8-
./test-float-parse [--timeout x] [--exclude x] [INCLUDE ...]
8+
./test-float-parse [--timeout x] [--exclude x] [--max-failures x] [INCLUDE ...]
9+
./test-float-parse [--fuzz-count x] [INCLUDE ...]
10+
./test-float-parse [--skip-huge] [INCLUDE ...]
911
./test-float-parse --list
1012
1113
Args:
@@ -22,6 +24,7 @@ Args:
2224
--fuzz-count N Run the fuzzer with N iterations. Only has an effect
2325
if fuzz tests are enabled. Pass `--fuzz-count none`
2426
to remove this limit.
27+
--skip-huge Skip tests that run for a long time.
2528
"#;
2629

2730
enum ArgMode {
@@ -67,6 +70,7 @@ fn parse_args(args: Vec<String>) -> (tfp::Config, Vec<String>, Vec<String>) {
6770
timeout: Duration::from_secs(60 * 60 * 3),
6871
max_failures: Some(20),
6972
fuzz_count: Some(tfp::DEFAULT_FUZZ_COUNT),
73+
skip_huge: false,
7074
};
7175

7276
let mut mode = ArgMode::Any;
@@ -79,6 +83,10 @@ fn parse_args(args: Vec<String>) -> (tfp::Config, Vec<String>, Vec<String>) {
7983
ArgMode::Any if arg == "--exclude" => ArgMode::Exclude,
8084
ArgMode::Any if arg == "--max-failures" => ArgMode::MaxFailures,
8185
ArgMode::Any if arg == "--fuzz-count" => ArgMode::FuzzCount,
86+
ArgMode::Any if arg == "--skip-huge" => {
87+
cfg.skip_huge = true;
88+
ArgMode::Any
89+
}
8290
ArgMode::Any if arg.starts_with('-') => {
8391
panic!("Unknown argument {arg}. Usage:\n{HELP}")
8492
}

0 commit comments

Comments
 (0)