aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-harness/src/integrationtests/testrunner.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-harness/src/integrationtests/testrunner.ts')
-rw-r--r--packages/taler-harness/src/integrationtests/testrunner.ts42
1 files changed, 41 insertions, 1 deletions
diff --git a/packages/taler-harness/src/integrationtests/testrunner.ts b/packages/taler-harness/src/integrationtests/testrunner.ts
index cbdca04b9..501af98a4 100644
--- a/packages/taler-harness/src/integrationtests/testrunner.ts
+++ b/packages/taler-harness/src/integrationtests/testrunner.ts
@@ -14,7 +14,12 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { CancellationToken, Logger, minimatch, setGlobalLogLevelFromString } from "@gnu-taler/taler-util";
+import {
+ CancellationToken,
+ Logger,
+ minimatch,
+ setGlobalLogLevelFromString,
+} from "@gnu-taler/taler-util";
import * as child_process from "child_process";
import * as fs from "fs";
import * as os from "os";
@@ -22,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";
@@ -105,6 +112,8 @@ import { runPeerRepairTest } from "./test-peer-repair.js";
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.
@@ -137,6 +146,7 @@ const allTests: TestMainFunction[] = [
runFeeRegressionTest,
runForcedSelectionTest,
runKycTest,
+ runExchangePurseTest,
runExchangeDepositTest,
runLibeufinAnastasisFacadeTest,
runLibeufinApiBankaccountTest,
@@ -257,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-"),
);