Properly return a non 0 exit code in case a test times out and fix tests which used to time out (#152329)

This commit is contained in:
Alexandru Dima 2022-06-16 15:02:37 +02:00 committed by GitHub
parent 192f8bf12b
commit 3530e85ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 21 deletions

View file

@ -33,7 +33,7 @@ suite('UserDataAutoSyncService', () => {
teardown(() => disposableStore.clear());
test('test auto sync with sync resource change triggers sync', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -57,7 +57,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test auto sync with sync resource change triggers sync for every change', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -85,7 +85,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test auto sync with non sync resource change triggers sync', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -109,7 +109,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test auto sync with non sync resource change does not trigger continuous syncs', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -135,7 +135,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test first auto sync requests', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -175,7 +175,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test further auto sync requests without changes', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -196,7 +196,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test further auto sync requests with changes', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -233,7 +233,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test auto sync send execution id header', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
// Setup the client
const target = new UserDataSyncTestServer();
const client = disposableStore.add(new UserDataSyncClient(target));
@ -258,7 +258,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test delete on one client throws turned off error on other client while syncing', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer();
// Set up and sync from the client
@ -294,7 +294,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test disabling the machine turns off sync', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer();
// Set up and sync from the test client
@ -328,7 +328,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test removing the machine adds machine back', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer();
// Set up and sync from the test client
@ -353,7 +353,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test creating new session from one client throws session expired error on another client while syncing', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer();
// Set up and sync from the client
@ -392,7 +392,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test rate limit on server', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer(5);
// Set up and sync from the test client
@ -412,7 +412,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test auto sync is suspended when server donot accepts requests', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer(5, 1);
// Set up and sync from the test client
@ -432,7 +432,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test cache control header with no cache is sent when triggered with disable cache option', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer(5, 1);
// Set up and sync from the test client
@ -446,7 +446,7 @@ suite('UserDataAutoSyncService', () => {
});
test('test cache control header is not sent when triggered without disable cache option', async () => {
await runWithFakedTimers({ useSetImmediate: true }, async () => {
await runWithFakedTimers({}, async () => {
const target = new UserDataSyncTestServer(5, 1);
// Set up and sync from the test client

View file

@ -147,18 +147,22 @@ async function runTestsInBrowser(testModules, browserType) {
withReporter(browserType, new EchoRunner(emitter, browserType.toUpperCase()));
// collection failures for console printing
const fails = [];
const failingModuleIds = [];
const failingTests = [];
emitter.on('fail', (test, err) => {
if (err.stack) {
const regex = /(vs\/.*\.test)\.js/;
for (const line of String(err.stack).split('\n')) {
const match = regex.exec(line);
if (match) {
fails.push(match[1]);
break;
failingModuleIds.push(match[1]);
return;
}
}
}
// We could not determine the module id
failingTests.push(test.fullTitle);
});
try {
@ -172,8 +176,11 @@ async function runTestsInBrowser(testModules, browserType) {
}
await browser.close();
if (fails.length > 0) {
return `to DEBUG, open ${browserType.toUpperCase()} and navigate to ${target.href}?${fails.map(module => `m=${module}`).join('&')}`;
if (failingModuleIds.length > 0) {
return `to DEBUG, open ${browserType.toUpperCase()} and navigate to ${target.href}?${failingModuleIds.map(module => `m=${module}`).join('&')}`;
}
if (failingTests.length > 0) {
return `The followings tests are failing:\n - ${failingTests.join('\n - ')}`;
}
}