harness: allow running tests without timeout

This commit is contained in:
Florian Dold 2023-02-10 00:02:27 +01:00
parent ebb3e7e338
commit 1a3040d872
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 11 additions and 2 deletions

View File

@ -271,6 +271,9 @@ testingCli
.flag("quiet", ["--quiet"], {
help: "Produce less output.",
})
.flag("noTimeout", ["--no-timeout"], {
help: "Do not time out tests."
})
.action(async (args) => {
await runTests({
includePattern: args.runIntegrationtests.pattern,
@ -278,6 +281,7 @@ testingCli
dryRun: args.runIntegrationtests.dryRun,
verbosity: args.runIntegrationtests.quiet ? 0 : 1,
includeExperimental: args.runIntegrationtests.experimental ?? false,
noTimeout: args.runIntegrationtests.noTimeout,
});
});

View File

@ -198,6 +198,7 @@ export interface TestRunSpec {
suiteSpec?: string;
dryRun?: boolean;
includeExperimental: boolean;
noTimeout: boolean;
verbosity: number;
}
@ -331,9 +332,13 @@ export async function runTests(spec: TestRunSpec) {
const defaultTimeout = 60000;
const testTimeoutMs = testCase.timeoutMs ?? defaultTimeout;
console.log(`running ${testName} with timeout ${testTimeoutMs}ms`);
if (spec.noTimeout) {
console.log(`running ${testName}, no timeout`);
} else {
console.log(`running ${testName} with timeout ${testTimeoutMs}ms`);
}
const { token } = CancellationToken.timeout(testTimeoutMs);
const token = spec.noTimeout ? CancellationToken.CONTINUE : CancellationToken.timeout(testTimeoutMs).token;
const resultPromise: Promise<TestRunResult> = new Promise(
(resolve, reject) => {