summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-08-06 18:16:04 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-08-06 18:16:04 +0530
commitecf763126e858a7878b078fa94f96cee18b5900d (patch)
treea3ed31f16998930bfa1b2e3d5b7a1819721def93
parent710f8ade3372975612fbce65dc87a256805c6a3b (diff)
downloadwallet-core-ecf763126e858a7878b078fa94f96cee18b5900d.tar.gz
wallet-core-ecf763126e858a7878b078fa94f96cee18b5900d.tar.bz2
wallet-core-ecf763126e858a7878b078fa94f96cee18b5900d.zip
improve test shutdown on errors
-rw-r--r--packages/taler-integrationtests/src/harness.ts40
1 files changed, 22 insertions, 18 deletions
diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts
index 21ab51ebd..17a21232a 100644
--- a/packages/taler-integrationtests/src/harness.ts
+++ b/packages/taler-integrationtests/src/harness.ts
@@ -869,33 +869,37 @@ export interface MerchantInstanceConfig {
defaultPayDelay?: time.Duration;
}
+function shouldLinger(): boolean {
+ return process.env["TALER_TEST_KEEP"] == "1";
+}
+
export function runTest(testMain: (gc: GlobalTestState) => Promise<void>) {
const main = async () => {
- const gc = new GlobalTestState({
- testDir: await makeTempDir(),
- });
+ let gc: GlobalTestState | undefined;
+ let ret = 0;
try {
+ gc = new GlobalTestState({
+ testDir: await makeTempDir(),
+ });
await testMain(gc);
+ } catch (e) {
+ console.error("FATAL: test failed with exception", e);
+ ret = 1;
} finally {
- await gc.terminate();
- if (process.env["TALER_TEST_KEEP"] !== "1") {
- console.log("test logs and config can be found under", gc.testDir);
+ if (gc) {
+ if (shouldLinger()) {
+ console.log("test logs and config can be found under", gc.testDir);
+ console.log("keeping test environment running");
+ } else {
+ await gc.terminate();
+ console.log("test logs and config can be found under", gc.testDir);
+ process.exit(ret);
+ }
}
}
};
- main().catch((e) => {
- console.error("FATAL: test failed with exception");
- if (e instanceof Error) {
- console.error(e);
- } else {
- console.error(e);
- }
-
- if (process.env["TALER_TEST_KEEP"] !== "1") {
- process.exit(1);
- }
- });
+ main();
}
function shellWrap(s: string) {