@@ -24,19 +24,14 @@ pub struct TestOpts {
2424 pub list : bool ,
2525 pub filters : Vec < String > ,
2626 pub filter_exact : bool ,
27- pub force_run_in_process : bool ,
28- pub exclude_should_panic : bool ,
2927 pub run_ignored : RunIgnored ,
3028 pub run_tests : bool ,
3129 pub bench_benchmarks : bool ,
3230 pub nocapture : bool ,
3331 pub color : ColorConfig ,
3432 pub format : OutputFormat ,
35- pub shuffle : bool ,
36- pub shuffle_seed : Option < u64 > ,
3733 pub test_threads : Option < std:: num:: NonZeroUsize > ,
3834 pub skip : Vec < String > ,
39- pub time_options : Option < TestTimeOptions > ,
4035 /// Stop at first failing test.
4136 /// May run a few more tests due to threading, but will
4237 /// abort as soon as possible.
@@ -83,8 +78,6 @@ pub enum OutputFormat {
8378 Terse ,
8479 /// JSON output
8580 Json ,
86- /// JUnit output
87- Junit ,
8881}
8982
9083impl Default for OutputFormat {
@@ -93,90 +86,6 @@ impl Default for OutputFormat {
9386 }
9487}
9588
96- /// Structure with parameters for calculating test execution time (see [`TestOpts::time_options`])
97- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
98- pub struct TestTimeOptions {
99- /// Denotes if the test critical execution time limit excess should be considered
100- /// a test failure.
101- pub error_on_excess : bool ,
102- pub unit_threshold : TimeThreshold ,
103- pub integration_threshold : TimeThreshold ,
104- pub doctest_threshold : TimeThreshold ,
105- }
106-
107- impl Default for TestTimeOptions {
108- fn default ( ) -> Self {
109- Self {
110- error_on_excess : false ,
111- unit_threshold : TimeThreshold {
112- warn : std:: time:: Duration :: from_millis ( 50 ) ,
113- critical : std:: time:: Duration :: from_millis ( 100 ) ,
114- } ,
115- integration_threshold : TimeThreshold {
116- warn : std:: time:: Duration :: from_millis ( 50 ) ,
117- critical : std:: time:: Duration :: from_millis ( 100 ) ,
118- } ,
119- doctest_threshold : TimeThreshold {
120- warn : std:: time:: Duration :: from_millis ( 50 ) ,
121- critical : std:: time:: Duration :: from_millis ( 100 ) ,
122- } ,
123- }
124- }
125- }
126-
127- /// Structure denoting time limits for test execution (see [`TestTimeOptions`])
128- #[ derive( Copy , Clone , Debug , Default , PartialEq , Eq ) ]
129- pub struct TimeThreshold {
130- pub warn : std:: time:: Duration ,
131- pub critical : std:: time:: Duration ,
132- }
133-
134- impl TimeThreshold {
135- /// Attempts to create a `TimeThreshold` instance with values obtained
136- /// from the environment variable, and returns `None` if the variable
137- /// is not set.
138- /// Environment variable format is expected to match `\d+,\d+`.
139- ///
140- /// # Panics
141- ///
142- /// Panics if variable with provided name is set but contains inappropriate
143- /// value.
144- fn from_env_var ( env_var_name : & str ) -> Result < Option < Self > , ErrorContext < ' static > > {
145- use std:: str:: FromStr ;
146-
147- let durations_str = match std:: env:: var ( env_var_name) {
148- Ok ( value) => value,
149- Err ( _) => {
150- return Ok ( None ) ;
151- }
152- } ;
153- let ( warn_str, critical_str) = durations_str. split_once ( ',' ) . ok_or_else ( || {
154- ErrorContext :: msg ( format_args ! (
155- "Duration variable {env_var_name} expected to have 2 numbers separated by comma, but got {durations_str}"
156- ) )
157- } ) ?;
158-
159- let parse_u64 = |v| {
160- u64:: from_str ( v) . map_err ( |_err| {
161- ErrorContext :: msg ( format_args ! (
162- "Duration value in variable {env_var_name} is expected to be a number, but got {v}"
163- ) )
164- } )
165- } ;
166-
167- let warn = parse_u64 ( warn_str) ?;
168- let critical = parse_u64 ( critical_str) ?;
169- if warn > critical {
170- panic ! ( "Test execution warn time should be less or equal to the critical time" ) ;
171- }
172-
173- Ok ( Some ( Self {
174- warn : std:: time:: Duration :: from_millis ( warn) ,
175- critical : std:: time:: Duration :: from_millis ( critical) ,
176- } ) )
177- }
178- }
179-
18089/// Options for the test run defined by the caller (instead of CLI arguments) (see
18190/// [`TestOpts::options`])
18291///
@@ -194,10 +103,6 @@ Options:
194103 --include-ignored
195104 Run ignored and not ignored tests
196105 --ignored Run only ignored tests
197- --force-run-in-process
198- Forces tests to run in-process when panic=abort
199- --exclude-should-panic
200- Excludes tests marked as should_panic
201106 --test Run tests and not benchmarks
202107 --bench Run benchmarks instead of tests
203108 --list List all tests and benchmarks
@@ -216,12 +121,11 @@ Options:
216121 on serially (default);
217122 always = always colorize output;
218123 never = never colorize output;
219- --format pretty|terse|json|junit
124+ --format pretty|terse|json
220125 Configure formatting of output:
221126 pretty = Print verbose output;
222127 terse = Display one character per test;
223128 json = Output a json document;
224- junit = Output a JUnit document
225129 --show-output Show captured stdout of successful tests
226130 -Z unstable-options Enable nightly-only flags:
227131 unstable-options = Allow use of experimental features
@@ -247,10 +151,6 @@ Options:
247151 `VARIABLE=WARN_TIME,CRITICAL_TIME`.
248152 `CRITICAL_TIME` here means the limit that should not
249153 be exceeded by test.
250- --shuffle Run tests in random order
251- --shuffle-seed SEED
252- Run tests in random order; seed the random number
253- generator with SEED
254154"# ;
255155
256156pub const AFTER_HELP : & str = r#"
@@ -262,12 +162,6 @@ By default, all tests are run in parallel. This can be altered with the
262162--test-threads flag or the RUST_TEST_THREADS environment variable when running
263163tests (set it to 1).
264164
265- By default, the tests are run in alphabetical order. Use --shuffle or set
266- RUST_TEST_SHUFFLE to run the tests in random order. Pass the generated
267- "shuffle seed" to --shuffle-seed (or set RUST_TEST_SHUFFLE_SEED) to run the
268- tests in the same order again. Note that --shuffle and --shuffle-seed do not
269- affect whether the tests are run in parallel.
270-
271165All tests have their standard output and standard error captured by default.
272166This can be overridden with the --nocapture flag or setting RUST_TEST_NOCAPTURE
273167environment variable to a value other than "0". Logging is not captured by default.
@@ -318,12 +212,6 @@ impl TestOptsBuilder {
318212 self . include_ignored = true ;
319213 }
320214 Long ( "ignored" ) => self . ignored = true ,
321- Long ( "force-run-in-process" ) => {
322- self . opts . force_run_in_process = true ;
323- }
324- Long ( "exclude-should-panic" ) => {
325- self . opts . exclude_should_panic = true ;
326- }
327215 Long ( "test" ) => {
328216 self . opts . run_tests = true ;
329217 }
@@ -377,13 +265,12 @@ impl TestOptsBuilder {
377265 let format = parser
378266 . next_flag_value ( )
379267 . ok_or_missing ( Value ( std:: ffi:: OsStr :: new ( "FORMAT" ) ) )
380- . one_of ( & [ "pretty" , "terse" , "json" , "junit" ] )
268+ . one_of ( & [ "pretty" , "terse" , "json" ] )
381269 . within ( arg) ?;
382270 self . format = Some ( match format {
383271 "pretty" => OutputFormat :: Pretty ,
384272 "terse" => OutputFormat :: Terse ,
385273 "json" => OutputFormat :: Json ,
386- "junit" => OutputFormat :: Junit ,
387274 _ => unreachable ! ( "`one_of` should prevent this" ) ,
388275 } ) ;
389276 }
@@ -402,34 +289,6 @@ impl TestOptsBuilder {
402289 // Don't validate `feature` as other parsers might provide values
403290 self . opts . allowed_unstable . push ( feature. to_owned ( ) ) ;
404291 }
405- Long ( "report-time" ) => {
406- self . opts . time_options . get_or_insert_with ( Default :: default) ;
407- }
408- Long ( "ensure-time" ) => {
409- let time = self . opts . time_options . get_or_insert_with ( Default :: default) ;
410- time. error_on_excess = true ;
411- if let Some ( threshold) = TimeThreshold :: from_env_var ( "RUST_TEST_TIME_UNIT" ) ? {
412- time. unit_threshold = threshold;
413- }
414- if let Some ( threshold) = TimeThreshold :: from_env_var ( "RUST_TEST_TIME_INTEGRATION" ) ?
415- {
416- time. integration_threshold = threshold;
417- }
418- if let Some ( threshold) = TimeThreshold :: from_env_var ( "RUST_TEST_TIME_DOCTEST" ) ? {
419- time. doctest_threshold = threshold;
420- }
421- }
422- Long ( "shuffle" ) => {
423- self . opts . shuffle = true ;
424- }
425- Long ( "shuffle-seed" ) => {
426- let seed = parser
427- . next_flag_value ( )
428- . ok_or_missing ( Value ( std:: ffi:: OsStr :: new ( "SEED" ) ) )
429- . parse ( )
430- . within ( arg) ?;
431- self . opts . shuffle_seed = Some ( seed) ;
432- }
433292 Value ( filter) => {
434293 let filter = filter. string ( "FILTER" ) ?;
435294 self . opts . filters . push ( filter. to_owned ( ) ) ;
@@ -449,49 +308,6 @@ impl TestOptsBuilder {
449308 . iter ( )
450309 . any ( |f| f == UNSTABLE_OPTIONS ) ;
451310
452- if self . opts . force_run_in_process && !allow_unstable_options {
453- return Err ( ErrorContext :: msg (
454- "`--force-run-in-process` requires `-Zunstable-options`" ,
455- ) ) ;
456- }
457-
458- if self . opts . exclude_should_panic && !allow_unstable_options {
459- return Err ( ErrorContext :: msg (
460- "`--exclude-should-panic` requires `-Zunstable-options`" ,
461- ) ) ;
462- }
463-
464- if self . opts . shuffle && !allow_unstable_options {
465- return Err ( ErrorContext :: msg (
466- "`--shuffle` requires `-Zunstable-options`" ,
467- ) ) ;
468- }
469- if !self . opts . shuffle && allow_unstable_options {
470- self . opts . shuffle = match std:: env:: var ( "RUST_TEST_SHUFFLE" ) {
471- Ok ( val) => & val != "0" ,
472- Err ( _) => false ,
473- } ;
474- }
475-
476- if self . opts . shuffle_seed . is_some ( ) && !allow_unstable_options {
477- return Err ( ErrorContext :: msg (
478- "`--shuffle-seed` requires `-Zunstable-options`" ,
479- ) ) ;
480- }
481- if self . opts . shuffle_seed . is_none ( ) && allow_unstable_options {
482- self . opts . shuffle_seed = match std:: env:: var ( "RUST_TEST_SHUFFLE_SEED" ) {
483- Ok ( val) => match val. parse :: < u64 > ( ) {
484- Ok ( n) => Some ( n) ,
485- Err ( _) => {
486- return Err ( ErrorContext :: msg (
487- "RUST_TEST_SHUFFLE_SEED is `{val}`, should be a number." ,
488- ) ) ;
489- }
490- } ,
491- Err ( _) => None ,
492- } ;
493- }
494-
495311 if !self . opts . nocapture {
496312 self . opts . nocapture = match std:: env:: var ( "RUST_TEST_NOCAPTURE" ) {
497313 Ok ( val) => & val != "0" ,
0 commit comments