@@ -333,6 +333,7 @@ pub struct TestFlags {
333
333
pub doc : bool ,
334
334
pub no_run : bool ,
335
335
pub coverage_dir : Option < String > ,
336
+ pub clean : bool ,
336
337
pub fail_fast : Option < NonZeroUsize > ,
337
338
pub files : FileFlags ,
338
339
pub allow_none : bool ,
@@ -2630,6 +2631,14 @@ Directory arguments are expanded to all contained files matching the glob
2630
2631
. conflicts_with ( "inspect-brk" )
2631
2632
. help ( "Collect coverage profile data into DIR. If DIR is not specified, it uses 'coverage/'." ) ,
2632
2633
)
2634
+ . arg (
2635
+ Arg :: new ( "clean" )
2636
+ . long ( "clean" )
2637
+ . help ( "Empty the temporary coverage profile data directory before running tests.
2638
+
2639
+ Note: running multiple `deno test --clean` calls in series or parallel for the same coverage directory may cause race conditions." )
2640
+ . action ( ArgAction :: SetTrue ) ,
2641
+ )
2633
2642
. arg (
2634
2643
Arg :: new ( "parallel" )
2635
2644
. long ( "parallel" )
@@ -4240,6 +4249,7 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
4240
4249
let doc = matches. get_flag ( "doc" ) ;
4241
4250
let allow_none = matches. get_flag ( "allow-none" ) ;
4242
4251
let filter = matches. remove_one :: < String > ( "filter" ) ;
4252
+ let clean = matches. get_flag ( "clean" ) ;
4243
4253
4244
4254
let fail_fast = if matches. contains_id ( "fail-fast" ) {
4245
4255
Some (
@@ -4325,6 +4335,7 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
4325
4335
no_run,
4326
4336
doc,
4327
4337
coverage_dir : matches. remove_one :: < String > ( "coverage" ) ,
4338
+ clean,
4328
4339
fail_fast,
4329
4340
files : FileFlags { include, ignore } ,
4330
4341
filter,
@@ -8189,7 +8200,7 @@ mod tests {
8189
8200
#[ test]
8190
8201
fn test_with_flags ( ) {
8191
8202
#[ rustfmt:: skip]
8192
- let r = flags_from_vec ( svec ! [ "deno" , "test" , "--unstable" , "--no-npm" , "--no-remote" , "--trace-leaks" , "--no-run" , "--filter" , "- foo" , "--coverage=cov" , "--location" , "https:foo" , "--allow-net" , "--allow-none" , "dir1/" , "dir2/" , "--" , "arg1" , "arg2" ] ) ;
8203
+ let r = flags_from_vec ( svec ! [ "deno" , "test" , "--unstable" , "--no-npm" , "--no-remote" , "--trace-leaks" , "--no-run" , "--filter" , "- foo" , "--coverage=cov" , "--clean" , "-- location", "https:foo" , "--allow-net" , "--allow-none" , "dir1/" , "dir2/" , "--" , "arg1" , "arg2" ] ) ;
8193
8204
assert_eq ! (
8194
8205
r. unwrap( ) ,
8195
8206
Flags {
@@ -8207,6 +8218,7 @@ mod tests {
8207
8218
concurrent_jobs: None ,
8208
8219
trace_leaks: true ,
8209
8220
coverage_dir: Some ( "cov" . to_string( ) ) ,
8221
+ clean: true ,
8210
8222
watch: Default :: default ( ) ,
8211
8223
reporter: Default :: default ( ) ,
8212
8224
junit_path: None ,
@@ -8294,6 +8306,7 @@ mod tests {
8294
8306
concurrent_jobs: Some ( NonZeroUsize :: new( 4 ) . unwrap( ) ) ,
8295
8307
trace_leaks: false ,
8296
8308
coverage_dir: None ,
8309
+ clean: false ,
8297
8310
watch: Default :: default ( ) ,
8298
8311
junit_path: None ,
8299
8312
} ) ,
@@ -8330,6 +8343,7 @@ mod tests {
8330
8343
concurrent_jobs: None ,
8331
8344
trace_leaks: false ,
8332
8345
coverage_dir: None ,
8346
+ clean: false ,
8333
8347
watch: Default :: default ( ) ,
8334
8348
reporter: Default :: default ( ) ,
8335
8349
junit_path: None ,
@@ -8371,6 +8385,7 @@ mod tests {
8371
8385
concurrent_jobs: None ,
8372
8386
trace_leaks: false ,
8373
8387
coverage_dir: None ,
8388
+ clean: false ,
8374
8389
watch: Default :: default ( ) ,
8375
8390
reporter: Default :: default ( ) ,
8376
8391
junit_path: None ,
@@ -8506,6 +8521,7 @@ mod tests {
8506
8521
concurrent_jobs: None ,
8507
8522
trace_leaks: false ,
8508
8523
coverage_dir: None ,
8524
+ clean: false ,
8509
8525
watch: Default :: default ( ) ,
8510
8526
reporter: Default :: default ( ) ,
8511
8527
junit_path: None ,
@@ -8540,6 +8556,7 @@ mod tests {
8540
8556
concurrent_jobs: None ,
8541
8557
trace_leaks: false ,
8542
8558
coverage_dir: None ,
8559
+ clean: false ,
8543
8560
watch: Some ( Default :: default ( ) ) ,
8544
8561
reporter: Default :: default ( ) ,
8545
8562
junit_path: None ,
@@ -8573,6 +8590,7 @@ mod tests {
8573
8590
concurrent_jobs: None ,
8574
8591
trace_leaks: false ,
8575
8592
coverage_dir: None ,
8593
+ clean: false ,
8576
8594
watch: Some ( Default :: default ( ) ) ,
8577
8595
reporter: Default :: default ( ) ,
8578
8596
junit_path: None ,
@@ -8608,6 +8626,7 @@ mod tests {
8608
8626
concurrent_jobs: None ,
8609
8627
trace_leaks: false ,
8610
8628
coverage_dir: None ,
8629
+ clean: false ,
8611
8630
watch: Some ( WatchFlags {
8612
8631
hmr: false ,
8613
8632
no_clear_screen: true ,
0 commit comments