@@ -4,14 +4,9 @@ import * as path from 'path';
4
4
import * as glob from 'glob' ;
5
5
6
6
/**
7
- * The number of browsers we run the tests in .
7
+ * Assume that each test runs for 3s .
8
8
*/
9
- const NUM_BROWSERS = 3 ;
10
-
11
- /**
12
- * Assume that each test runs for 2s.
13
- */
14
- const ASSUMED_TEST_DURATION_SECONDS = 2 ;
9
+ const ASSUMED_TEST_DURATION_SECONDS = 3 ;
15
10
16
11
/**
17
12
* We keep the runtime of the detector if possible under 30min.
@@ -51,22 +46,12 @@ ${changedPaths.join('\n')}
51
46
try {
52
47
await new Promise < void > ( ( resolve , reject ) => {
53
48
const cp = childProcess . spawn (
54
- `npx playwright test ${
55
- testPaths . length ? testPaths . join ( ' ' ) : './suites'
56
- } --reporter='line' --repeat-each ${ repeatEachCount } `,
57
- { shell : true , cwd } ,
49
+ `npx playwright test ${ testPaths . length ? testPaths . join ( ' ' ) : './suites' } --repeat-each ${ repeatEachCount } ` ,
50
+ { shell : true , cwd, stdio : 'inherit' } ,
58
51
) ;
59
52
60
53
let error : Error | undefined ;
61
54
62
- cp . stdout . on ( 'data' , data => {
63
- console . log ( data ? ( data as object ) . toString ( ) : '' ) ;
64
- } ) ;
65
-
66
- cp . stderr . on ( 'data' , data => {
67
- console . log ( data ? ( data as object ) . toString ( ) : '' ) ;
68
- } ) ;
69
-
70
55
cp . on ( 'error' , e => {
71
56
console . error ( e ) ;
72
57
error = e ;
@@ -107,15 +92,16 @@ function getPerTestRunCount(testPaths: string[]) {
107
92
const estimatedNumberOfTests = testPaths . map ( getApproximateNumberOfTests ) . reduce ( ( a , b ) => a + b ) ;
108
93
console . log ( `Estimated number of tests: ${ estimatedNumberOfTests } ` ) ;
109
94
110
- // tests are usually run against all browsers we test with, so let's assume this
111
- const testRunCount = estimatedNumberOfTests * NUM_BROWSERS ;
95
+ const testRunCount = estimatedNumberOfTests ;
112
96
console . log ( `Estimated test runs for one round: ${ testRunCount } ` ) ;
113
97
114
98
const estimatedTestRuntime = testRunCount * ASSUMED_TEST_DURATION_SECONDS ;
115
99
console . log ( `Estimated test runtime: ${ estimatedTestRuntime } s` ) ;
116
100
117
101
const expectedPerTestRunCount = Math . floor ( MAX_TARGET_TEST_RUNTIME_SECONDS / estimatedTestRuntime ) ;
118
- console . log ( `Expected per-test run count: ${ expectedPerTestRunCount } ` ) ;
102
+ console . log (
103
+ `Calculated # of repetitions: ${ expectedPerTestRunCount } (min ${ MIN_PER_TEST_RUN_COUNT } , max ${ MAX_PER_TEST_RUN_COUNT } )` ,
104
+ ) ;
119
105
120
106
return Math . min ( MAX_PER_TEST_RUN_COUNT , Math . max ( expectedPerTestRunCount , MIN_PER_TEST_RUN_COUNT ) ) ;
121
107
}
@@ -128,22 +114,7 @@ function getTestPaths(): string[] {
128
114
cwd : path . join ( __dirname , '../' ) ,
129
115
} ) ;
130
116
131
- return paths . map ( p => path . dirname ( p ) ) ;
132
- }
133
-
134
- function logError ( error : unknown ) {
135
- if ( process . env . CI ) {
136
- console . log ( '::group::Test failed' ) ;
137
- } else {
138
- console . error ( ' ⚠️ Test failed:' ) ;
139
- }
140
-
141
- console . log ( ( error as any ) . stdout ) ;
142
- console . log ( ( error as any ) . stderr ) ;
143
-
144
- if ( process . env . CI ) {
145
- console . log ( '::endgroup::' ) ;
146
- }
117
+ return paths . map ( p => `${ path . dirname ( p ) } /` ) ;
147
118
}
148
119
149
120
/**
@@ -156,7 +127,7 @@ function logError(error: unknown) {
156
127
function getApproximateNumberOfTests ( testPath : string ) : number {
157
128
try {
158
129
const content = fs . readFileSync ( path . join ( process . cwd ( ) , testPath , 'test.ts' ) , 'utf-8' ) ;
159
- const matches = content . match ( / i t \( | t e s t \( | s e n t r y T e s t \( / g) ;
130
+ const matches = content . match ( / s e n t r y T e s t \( / g) ;
160
131
return Math . max ( matches ? matches . length : 1 , 1 ) ;
161
132
} catch ( e ) {
162
133
console . error ( `Could not read file ${ testPath } ` ) ;
0 commit comments