Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix flaky test for slow machines #2205

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ describe('CompletionProviderImpl', function () {
const item = completions?.items?.[0];
assert.strictEqual(item?.label, 'abc');
}
}).timeout(4000);
}).timeout(this.timeout() * 2);

it('provides default slot-let completion for components with type definition', async () => {
const { completionProvider, document } = setup('component-events-completion-ts-def.svelte');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('DiagnosticsProvider', function () {

const diagnostics3 = await plugin.getDiagnostics(document);
assert.deepStrictEqual(diagnostics3.length, 1);
}).timeout(5000);
}).timeout(this.timeout() * 2.5);

it('notices changes of module resolution because of new file', async () => {
const { plugin, document, lsAndTsDocResolver } = setup('unresolvedimport.svelte');
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('DiagnosticsProvider', function () {
unlinkSync(newTsFilePath);
unlinkSync(newFilePath);
}
}).timeout(5000);
}).timeout(this.timeout() * 2.5);

it('notices update of imported module', async () => {
const { plugin, document, lsAndTsDocResolver } = setup(
Expand All @@ -116,7 +116,7 @@ describe('DiagnosticsProvider', function () {
const diagnostics2 = await plugin.getDiagnostics(document);
assert.deepStrictEqual(diagnostics2.length, 0);
await lsAndTsDocResolver.deleteSnapshot(newFilePath);
}).timeout(5000);
}).timeout(this.timeout() * 2.5);

it('notices file changes in all services that reference that file', async () => {
// Hacky but ensures that this tests is not interfered with by other tests
Expand Down Expand Up @@ -169,5 +169,5 @@ describe('DiagnosticsProvider', function () {
assert.deepStrictEqual(diagnostics3.length, 0);
const diagnostics4 = await plugin.getDiagnostics(otherDocument);
assert.deepStrictEqual(diagnostics4.length, 0);
}).timeout(5000);
}).timeout(this.timeout() * 2.5);
phanen marked this conversation as resolved.
Show resolved Hide resolved
});
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ export async function createJsonSnapshotFormatter(dir: string) {
export function serviceWarmup(suite: Mocha.Suite, testDir: string, rootUri = pathToUrl(testDir)) {
const defaultTimeout = suite.timeout();

suite.timeout(5_000);
// allow to set a higher timeout for slow machines from cli flag
const warmupTimeout = Math.max(defaultTimeout, 5_000);
suite.timeout(warmupTimeout);
before(async () => {
const start = Date.now();
console.log('Warming up language service...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ describe('TypeScript Plugin Performance Tests', () => {
return { plugin, document, append, prepend };
}

it('should be fast enough', async function () {
it('should be fast enough', async function() {
const { document, plugin, append, prepend } = setup('performance.svelte');

// allow to set a higher timeout for slow machines from cli flag
const performanceTimeout = Math.max(this.timeout(), 25_000);
this.timeout(performanceTimeout);

const benchmarkElapse = Math.ceil(await benchmark());
// it usually takes around 5-6 times of the benchmark result
// plus 1 for the benchmark itself
const newTimeout = benchmarkElapse * 7;

if (newTimeout < this.timeout()) {
if (newTimeout < performanceTimeout) {
console.log(`Benchmark took ${benchmarkElapse}ms. Setting timeout to ${newTimeout}ms`);
this.timeout(newTimeout);
}
Expand Down Expand Up @@ -78,5 +83,5 @@ describe('TypeScript Plugin Performance Tests', () => {

return end - start;
}
}).timeout(25_000);
jasonlyu123 marked this conversation as resolved.
Show resolved Hide resolved
});
});