@@ -6,22 +6,19 @@ import { windows, windowsSync } from '../../src/index.js'
6
6
import { randomBytes } from 'crypto'
7
7
import assert from 'assert'
8
8
9
- const arrSame = ( arr1 : string [ ] , arr2 : string [ ] ) =>
10
- [ ...arr1 ] . sort ( ) . join ( ',' ) === [ ...arr2 ] . sort ( ) . join ( ',' )
11
-
12
9
const setup = ( t : Test ) => {
13
10
const [ iterations , depth , fileCount , fileKb ] =
14
11
process . env . CI && process . platform === 'win32' ?
15
- [ 20_000 , 15 , 7 , 100 ]
12
+ [ 1000 , 15 , 7 , 100 ]
16
13
: [ 200 , 8 , 3 , 10 ]
17
14
18
- t . plan ( 11 )
15
+ t . plan ( 10 )
19
16
const dir = t . testdir ( )
20
17
const readdir = ( ) => readdirSync ( dir )
21
18
22
19
const letters = ( length : number ) =>
23
20
Array . from ( { length } ) . map ( ( _ , i ) => ( 10 + i ) . toString ( 36 ) )
24
- const files = letters ( fileCount ) . map ( f => `__file_ ${ f } ` )
21
+ const files = letters ( fileCount ) . map ( f => `_file_ ${ f } ` )
25
22
const dirs = join ( ...letters ( depth ) )
26
23
. split ( sep )
27
24
. reduce < string [ ] > ( ( acc , d ) => acc . concat ( join ( acc . at ( - 1 ) ?? '' , d ) ) , [ ] )
@@ -30,6 +27,8 @@ const setup = (t: Test) => {
30
27
. map ( d => join ( dir , d ) )
31
28
32
29
let iteration = 0
30
+ let previous = Date . now ( )
31
+ const start = Date . now ( )
33
32
34
33
return function * ( ) {
35
34
while ( iteration !== iterations ) {
@@ -73,19 +72,19 @@ const setup = (t: Test) => {
73
72
. map ( m => join ( dir , m ) )
74
73
75
74
assert (
76
- arrSame ( matches , entries ) ,
75
+ [ ... matches ] . sort ( ) . join ( ) === [ ... entries ] . sort ( ) . join ( ) ,
77
76
new RunError ( `glob result does not match expected` , {
78
77
found : matches ,
79
78
wanted : entries ,
80
79
} ) ,
81
80
)
82
81
83
82
iteration += 1
84
- yield [
83
+ yield {
85
84
matches,
86
- ( error : unknown , path : string ) =>
85
+ error : ( error : unknown , path : string ) =>
87
86
new RunError ( 'rimraf error' , { path, error } ) ,
88
- ( result : [ string , boolean ] [ ] ) => {
87
+ assertResult : ( result : [ string , boolean ] [ ] ) => {
89
88
assert (
90
89
result . length === dirs . length * ( files . length + 1 ) ,
91
90
new RunError ( `result is missing entries` , {
@@ -101,13 +100,14 @@ const setup = (t: Test) => {
101
100
)
102
101
assertContents ( )
103
102
if ( iteration % ( iterations / 10 ) === 0 ) {
104
- t . ok ( true , `${ iteration } ` )
103
+ const now = Date . now ( )
104
+ t . ok ( true , `${ iteration } (${ now - previous } ms / ${ now - start } ms)` )
105
+ previous = now
105
106
}
106
107
} ,
107
- ] as const
108
+ }
108
109
}
109
110
110
- t . equal ( iteration , iterations , `ran all ${ iteration } iterations` )
111
111
t . end ( )
112
112
}
113
113
}
@@ -117,12 +117,8 @@ const setup = (t: Test) => {
117
117
// errors consistently in Windows CI environments.
118
118
// https://github.com/sindresorhus/del/blob/chore/update-deps/test.js#L116
119
119
t . test ( 'windows does not throw EPERM' , t => {
120
- if ( process . env . RIMRAF_TEST_SKIP_EPERM_INTEGRATION ) {
121
- return t . end ( )
122
- }
123
-
124
120
t . test ( 'sync' , t => {
125
- for ( const [ matches , error , assertResult ] of setup ( t ) ( ) ) {
121
+ for ( const { matches, error, assertResult } of setup ( t ) ( ) ) {
126
122
assertResult (
127
123
matches . map ( path => {
128
124
try {
@@ -136,7 +132,7 @@ t.test('windows does not throw EPERM', t => {
136
132
} )
137
133
138
134
t . test ( 'async' , async t => {
139
- for ( const [ matches , error , assertResult ] of setup ( t ) ( ) ) {
135
+ for ( const { matches, error, assertResult } of setup ( t ) ( ) ) {
140
136
assertResult (
141
137
await Promise . all (
142
138
matches . map ( async path => {
0 commit comments