From b3cdd3409e172843d43cace16592230478096338 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 24 Apr 2023 13:13:20 -0300 Subject: improved log, added allow-http flag and prevent thrott --- .../src/integrationtests/testrunner.ts | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'packages/taler-harness/src/integrationtests/testrunner.ts') diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index f845f4e99..c76ce1b18 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see */ -import { CancellationToken, minimatch } from "@gnu-taler/taler-util"; +import { CancellationToken, Logger, minimatch } from "@gnu-taler/taler-util"; import * as child_process from "child_process"; import * as fs from "fs"; import * as os from "os"; @@ -105,6 +105,7 @@ import { runExchangeDepositTest } from "./test-exchange-deposit.js"; /** * Test runner. */ +const logger = new Logger("testrunner.ts"); /** * Spec for one test. @@ -199,6 +200,8 @@ export interface TestRunSpec { includePattern?: string; suiteSpec?: string; dryRun?: boolean; + failFast?: boolean; + waitOnFail?: boolean; includeExperimental: boolean; noTimeout: boolean; verbosity: number; @@ -357,7 +360,7 @@ export async function runTests(spec: TestRunSpec) { if (token.isCancelled) { return; } - console.log(`process exited code=${code} signal=${signal}`); + logger.info(`process exited code=${code} signal=${signal}`); if (signal) { reject(new Error(`test worker exited with signal ${signal}`)); } else if (code != 0) { @@ -385,6 +388,10 @@ export async function runTests(spec: TestRunSpec) { try { result = await token.racePromise(resultPromise); + if (result.status === "fail" && spec.failFast) { + logger.error("test failed and failing fast, exit!"); + throw Error("exit on fail fast"); + } } catch (e: any) { console.error(`test ${testName} timed out`); if (token.isCancelled) { @@ -469,10 +476,9 @@ if (runTestInstrStr && process.argv.includes("__TWCLI_TESTWORKER")) { const { testRootDir, testName } = JSON.parse( runTestInstrStr, ) as RunTestChildInstruction; - console.log(`running test ${testName} in worker process`); process.on("disconnect", () => { - console.log("got disconnect from parent"); + logger.trace("got disconnect from parent"); process.exit(3); }); @@ -486,35 +492,36 @@ if (runTestInstrStr && process.argv.includes("__TWCLI_TESTWORKER")) { } if (!process.send) { - console.error("can't communicate with parent"); + logger.error("can't communicate with parent"); process.exit(2); } if (!testMain) { - console.log(`test ${testName} not found`); + logger.info(`test ${testName} not found`); process.exit(2); } const testDir = path.join(testRootDir, testName); - console.log(`running test ${testName}`); + logger.info(`running test ${testName}`); const gc = new GlobalTestState({ testDir, }); const testResult = await runTestWithState(gc, testMain, testName); + logger.info(`done test ${testName}: ${testResult.status}`); process.send(testResult); }; runTest() .then(() => { - console.log(`test ${testName} finished in worker`); + logger.trace(`test ${testName} finished in worker`); if (shouldLingerInTest()) { - console.log("lingering ..."); + logger.trace("lingering ..."); return; } process.exit(0); }) .catch((e) => { - console.log(e); + logger.error(e); process.exit(1); }); } -- cgit v1.2.3