Skip to content

Commit f195b3a

Browse files
committed
fix!: Remove unstable --shuffle and --shuffle-seed
1 parent 139211c commit f195b3a

9 files changed

Lines changed: 11 additions & 270 deletions

File tree

crates/libtest-json/event.schema.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@
4444
"elapsed_s": {
4545
"$ref": "#/$defs/Elapsed"
4646
},
47-
"seed": {
48-
"type": [
49-
"integer",
50-
"null"
51-
],
52-
"format": "uint64",
53-
"minimum": 0
54-
},
5547
"event": {
5648
"type": "string",
5749
"const": "discover-complete"

crates/libtest-json/src/event.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub enum Event {
1313
DiscoverComplete {
1414
#[allow(dead_code)]
1515
elapsed_s: Elapsed,
16-
seed: Option<u64>,
1716
},
1817
SuiteStart,
1918
CaseStart {

crates/libtest-lexarg/src/lib.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ pub struct TestOpts {
3030
pub nocapture: bool,
3131
pub color: ColorConfig,
3232
pub format: OutputFormat,
33-
pub shuffle: bool,
34-
pub shuffle_seed: Option<u64>,
3533
pub test_threads: Option<std::num::NonZeroUsize>,
3634
pub skip: Vec<String>,
3735
/// Stop at first failing test.
@@ -156,10 +154,6 @@ Options:
156154
`VARIABLE=WARN_TIME,CRITICAL_TIME`.
157155
`CRITICAL_TIME` here means the limit that should not
158156
be exceeded by test.
159-
--shuffle Run tests in random order
160-
--shuffle-seed SEED
161-
Run tests in random order; seed the random number
162-
generator with SEED
163157
"#;
164158

165159
pub const AFTER_HELP: &str = r#"
@@ -171,12 +165,6 @@ By default, all tests are run in parallel. This can be altered with the
171165
--test-threads flag or the RUST_TEST_THREADS environment variable when running
172166
tests (set it to 1).
173167
174-
By default, the tests are run in alphabetical order. Use --shuffle or set
175-
RUST_TEST_SHUFFLE to run the tests in random order. Pass the generated
176-
"shuffle seed" to --shuffle-seed (or set RUST_TEST_SHUFFLE_SEED) to run the
177-
tests in the same order again. Note that --shuffle and --shuffle-seed do not
178-
affect whether the tests are run in parallel.
179-
180168
All tests have their standard output and standard error captured by default.
181169
This can be overridden with the --nocapture flag or setting RUST_TEST_NOCAPTURE
182170
environment variable to a value other than "0". Logging is not captured by default.
@@ -305,17 +293,6 @@ impl TestOptsBuilder {
305293
// Don't validate `feature` as other parsers might provide values
306294
self.opts.allowed_unstable.push(feature.to_owned());
307295
}
308-
Long("shuffle") => {
309-
self.opts.shuffle = true;
310-
}
311-
Long("shuffle-seed") => {
312-
let seed = parser
313-
.next_flag_value()
314-
.ok_or_missing(Value(std::ffi::OsStr::new("SEED")))
315-
.parse()
316-
.within(arg)?;
317-
self.opts.shuffle_seed = Some(seed);
318-
}
319296
Value(filter) => {
320297
let filter = filter.string("FILTER")?;
321298
self.opts.filters.push(filter.to_owned());
@@ -335,37 +312,6 @@ impl TestOptsBuilder {
335312
.iter()
336313
.any(|f| f == UNSTABLE_OPTIONS);
337314

338-
if self.opts.shuffle && !allow_unstable_options {
339-
return Err(ErrorContext::msg(
340-
"`--shuffle` requires `-Zunstable-options`",
341-
));
342-
}
343-
if !self.opts.shuffle && allow_unstable_options {
344-
self.opts.shuffle = match std::env::var("RUST_TEST_SHUFFLE") {
345-
Ok(val) => &val != "0",
346-
Err(_) => false,
347-
};
348-
}
349-
350-
if self.opts.shuffle_seed.is_some() && !allow_unstable_options {
351-
return Err(ErrorContext::msg(
352-
"`--shuffle-seed` requires `-Zunstable-options`",
353-
));
354-
}
355-
if self.opts.shuffle_seed.is_none() && allow_unstable_options {
356-
self.opts.shuffle_seed = match std::env::var("RUST_TEST_SHUFFLE_SEED") {
357-
Ok(val) => match val.parse::<u64>() {
358-
Ok(n) => Some(n),
359-
Err(_) => {
360-
return Err(ErrorContext::msg(
361-
"RUST_TEST_SHUFFLE_SEED is `{val}`, should be a number.",
362-
));
363-
}
364-
},
365-
Err(_) => None,
366-
};
367-
}
368-
369315
if !self.opts.nocapture {
370316
self.opts.nocapture = match std::env::var("RUST_TEST_NOCAPTURE") {
371317
Ok(val) => &val != "0",

crates/libtest2-harness/src/harness.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use libtest_lexarg::OutputFormat;
22

3-
use crate::{cli, notify, shuffle, Case, RunError, RunMode, State};
3+
use crate::{cli, notify, Case, RunError, RunMode, State};
44

55
pub struct Harness {
66
raw: Vec<std::ffi::OsString>,
@@ -172,10 +172,6 @@ fn discover(
172172

173173
// Do this first so it applies to both discover and running
174174
cases.sort_unstable_by_key(|case| case.name().to_owned());
175-
let seed = shuffle::get_shuffle_seed(opts);
176-
if let Some(seed) = seed {
177-
shuffle::shuffle_tests(seed, cases);
178-
}
179175

180176
let matches_filter = |case: &dyn Case, filter: &str| {
181177
let test_name = case.name();
@@ -207,7 +203,6 @@ fn discover(
207203

208204
notifier.notify(notify::Event::DiscoverComplete {
209205
elapsed_s: notify::Elapsed(timer.elapsed()),
210-
seed,
211206
})?;
212207

213208
Ok(())

crates/libtest2-harness/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
mod case;
2929
mod harness;
3030
mod notify;
31-
mod shuffle;
3231
mod state;
3332

3433
pub mod cli;

crates/libtest2-harness/src/notify/summary.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use super::OK;
55

66
#[derive(Default, Clone, Debug)]
77
pub(crate) struct Summary {
8-
pub(crate) seed: Option<u64>,
98
pub(crate) failures: std::collections::BTreeMap<String, Option<String>>,
109
pub(crate) elapsed_s: super::Elapsed,
1110

@@ -29,13 +28,9 @@ impl Summary {
2928

3029
pub(crate) fn write_start(&self, writer: &mut dyn std::io::Write) -> std::io::Result<()> {
3130
let s = if self.num_run == 1 { "" } else { "s" };
32-
let seed = self
33-
.seed
34-
.map(|s| format!(" (shuffle seed: {s})"))
35-
.unwrap_or_default();
3631

3732
writeln!(writer)?;
38-
writeln!(writer, "running {} test{s}{seed}", self.num_run)?;
33+
writeln!(writer, "running {} test{s}", self.num_run)?;
3934
Ok(())
4035
}
4136

@@ -95,9 +90,7 @@ impl super::Notifier for Summary {
9590
self.num_filtered_out += 1;
9691
}
9792
}
98-
Event::DiscoverComplete { seed, .. } => {
99-
self.seed = seed;
100-
}
93+
Event::DiscoverComplete { .. } => {}
10194
Event::SuiteStart => {}
10295
Event::CaseStart { .. } => {}
10396
Event::CaseComplete {

crates/libtest2-harness/src/shuffle.rs

Lines changed: 0 additions & 63 deletions
This file was deleted.

crates/libtest2-mimic/tests/testsuite/mixed_bag.rs

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ fn list_json() {
629629
{"event":"discover-case","name":"fox","mode":"test","run":false}
630630
{"event":"discover-case","name":"frog","mode":"test","run":false}
631631
{"event":"discover-case","name":"owl","mode":"test","run":false}
632-
{"event":"discover-complete","elapsed_s":"[..]","seed":null}
632+
{"event":"discover-complete","elapsed_s":"[..]"}
633633
"#,
634634
r#"{"event":"discover-start"}
635635
{"event":"discover-case","name":"bear","mode":"test","run":true}
@@ -640,7 +640,7 @@ fn list_json() {
640640
{"event":"discover-case","name":"fox","mode":"test","run":false}
641641
{"event":"discover-case","name":"frog","mode":"test","run":false}
642642
{"event":"discover-case","name":"owl","mode":"test","run":false}
643-
{"event":"discover-complete","elapsed_s":"[..]","seed":null}
643+
{"event":"discover-complete","elapsed_s":"[..]"}
644644
"#,
645645
);
646646
}
@@ -660,7 +660,7 @@ fn test_json() {
660660
{"event":"discover-case","name":"fox","mode":"test","run":false}
661661
{"event":"discover-case","name":"frog","mode":"test","run":false}
662662
{"event":"discover-case","name":"owl","mode":"test","run":false}
663-
{"event":"discover-complete","elapsed_s":"[..]","seed":null}
663+
{"event":"discover-complete","elapsed_s":"[..]"}
664664
{"event":"suite-start"}
665665
{"event":"case-start","name":"bear"}
666666
{"event":"case-complete","name":"bear","mode":"test","status":"ignored","message":"fails","elapsed_s":"[..]"}
@@ -677,7 +677,7 @@ fn test_json() {
677677
{"event":"discover-case","name":"fox","mode":"test","run":false}
678678
{"event":"discover-case","name":"frog","mode":"test","run":false}
679679
{"event":"discover-case","name":"owl","mode":"test","run":false}
680-
{"event":"discover-complete","elapsed_s":"[..]","seed":null}
680+
{"event":"discover-complete","elapsed_s":"[..]"}
681681
{"event":"suite-start"}
682682
[..]
683683
[..]
@@ -773,63 +773,3 @@ test result: FAILED. 2 passed; 1 failed; 5 ignored; 0 filtered out; finished in
773773
"#,
774774
);
775775
}
776-
777-
#[test]
778-
fn shuffle() {
779-
check(
780-
&["-Zunstable-options", "--list", "--shuffle-seed=1"],
781-
0,
782-
r#"fox: test
783-
cat: test
784-
fly: test
785-
bear: test
786-
owl: test
787-
frog: test
788-
bunny: test
789-
dog: test
790-
791-
8 tests
792-
793-
"#,
794-
r#"fox: test
795-
cat: test
796-
fly: test
797-
bear: test
798-
owl: test
799-
frog: test
800-
bunny: test
801-
dog: test
802-
803-
8 tests
804-
805-
"#,
806-
);
807-
check(
808-
&["-Zunstable-options", "--list", "--shuffle-seed=2"],
809-
0,
810-
r#"owl: test
811-
dog: test
812-
fox: test
813-
frog: test
814-
bear: test
815-
fly: test
816-
bunny: test
817-
cat: test
818-
819-
8 tests
820-
821-
"#,
822-
r#"owl: test
823-
dog: test
824-
fox: test
825-
frog: test
826-
bear: test
827-
fly: test
828-
bunny: test
829-
cat: test
830-
831-
8 tests
832-
833-
"#,
834-
);
835-
}

0 commit comments

Comments
 (0)