diff options
Diffstat (limited to 'packages/taler-harness/src/integrationtests')
-rw-r--r-- | packages/taler-harness/src/integrationtests/testrunner.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts index 226fd6b09..501af98a4 100644 --- a/packages/taler-harness/src/integrationtests/testrunner.ts +++ b/packages/taler-harness/src/integrationtests/testrunner.ts @@ -27,10 +27,12 @@ import * as path from "path"; import url from "url"; import { GlobalTestState, + runCommand, runTestWithState, shouldLingerInTest, TestRunResult, } from "../harness/harness.js"; +import { spawnSync } from "child_process"; import { runAgeRestrictionsMerchantTest } from "./test-age-restrictions-merchant.js"; import { runBankApiTest } from "./test-bank-api.js"; import { runClaimLoopTest } from "./test-claim-loop.js"; @@ -111,6 +113,7 @@ import { runPaymentShareTest } from "./test-payment-share.js"; import { runSimplePaymentTest } from "./test-simple-payment.js"; import { runTermOfServiceFormatTest } from "./test-tos-format.js"; import { runExchangePurseTest } from "./test-exchange-purse.js"; +import { getSharedTestDir } from "../harness/helpers.js"; /** * Test runner. @@ -264,7 +267,37 @@ interface RunTestChildInstruction { testRootDir: string; } +function purgeSharedTestEnvironment() { + const rmRes = spawnSync("rm", ["-rf", `${getSharedTestDir()}`]); + if (rmRes.status != 0) { + logger.warn("can't delete shared test directory"); + } + const psqlRes = spawnSync("psql", ["-Aqtl"], { + encoding: "utf-8", + }); + if (psqlRes.status != 0) { + logger.warn("could not list available postgres databases"); + return; + } + if (psqlRes.output[1]!!.indexOf("taler-integrationtest-shared") >= 0) { + const dropRes = spawnSync("dropdb", ["taler-integrationtest-shared"], { + encoding: "utf-8", + }); + if (dropRes.status != 0) { + logger.warn("could not drop taler-integrationtest-shared database"); + return; + } + } +} + export async function runTests(spec: TestRunSpec) { + if (!process.env.TALER_HARNESS_KEEP) { + logger.info("purging shared test environment"); + purgeSharedTestEnvironment(); + } else { + logger.info("keeping shared test environment"); + } + const testRootDir = fs.mkdtempSync( path.join(os.tmpdir(), "taler-integrationtests-"), ); |