8000 Tests: fix flakey message logs; ignore delete worker failures · jquery/jquery@02d2347 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02d2347

Browse files
authored
Tests: fix flakey message logs; ignore delete worker failures
Close gh-5432
1 parent 95a4c94 commit 02d2347

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

test/runner/browserstack/browsers.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,19 @@ export async function cleanupAllBrowsers( { verbose } ) {
187187
const workersRemaining = Object.values( workers );
188188
const numRemaining = workersRemaining.length;
189189
if ( numRemaining ) {
190-
await Promise.all(
191-
workersRemaining.map( ( worker ) => deleteWorker( worker.id ) )
192-
);
193-
if ( verbose ) {
194-
console.log(
195-
`Stopped ${ numRemaining } browser${ numRemaining > 1 ? "s" : "" }.`
190+
try {
191+
await Promise.all(
192+
workersRemaining.map( ( worker ) => deleteWorker( worker.id ) )
196193
);
194+
if ( verbose ) {
195+
console.log(
196+
`Stopped ${ numRemaining } browser${ numRemaining > 1 ? "s" : "" }.`
197+
);
198+
}
199+
} catch ( error ) {
200+
201+
// Log the error, but do not consider the test run failed
202+
console.error( error );
197203
}
198204
}
199205
}

test/runner/browserstack/queue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function retryTest( reportId, maxRetries ) {
3939
console.log(
4040
`Retrying test ${ reportId } for ${ chalk.yellow(
4141
test.options.modules.join( ", " )
42-
) }...`
42+
) }...${ test.retries }`
4343
);
4444
return test;
4545
}

test/runner/run.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,19 @@ export async function run( {
8383
if ( errors ) {
8484
pendingErrors[ reportId ][ message.data.name ] = errors;
8585
} else {
86-
delete pendingErrors[ reportId ][ message.data.name ];
86+
const existing = pendingErrors[ reportId ][ message.data.name ];
87+
88+
// Show a message for flakey tests
89+
if ( existing ) {
90+
console.log();
91+
console.warn(
92+
chalk.italic(
93+
chalk.gray( existing.replace( "Test failed", "Test flakey" ) )
94+
)
95+
);
96+
console.log();
97+
delete pendingErrors[ reportId ][ message.data.name ];
98+
}
8799
}
88100
break;
89101
}
@@ -103,24 +115,15 @@ export async function run( {
103115
// Handle failure
104116
if ( failed ) {
105117
const retry = retryTest( reportId, retries );
118+
119+
// Retry if retryTest returns a test
106120
if ( retry ) {
107121
return retry;
108122
}
109123
errorMessages.push( ...Object.values( pendingErrors[ reportId ] ) );
110-
return getNextBrowserTest( reportId );
111124
}
112125

113-
// Handle success
114-
if (
115-
pendingErrors[ reportId ] &&
116-
Object.keys( pendingErrors[ reportId ] ).length
117-
) {
118-
console.warn( "Detected flaky tests:" );
119-
for ( const [ , error ] in Object.entries( pendingErrors[ reportId ] ) ) {
120-
console.warn( chalk.italic( chalk.gray( error ) ) );
121-
}
122-
delete pendingErrors[ reportId ];
123-
}
126+
// Run the next test
124127
return getNextBrowserTest( reportId );
125128
}
126129
case "ack": {

0 commit comments

Comments
 (0)
0