improve test shutdown on errors
This commit is contained in:
parent
710f8ade33
commit
ecf763126e
@ -869,33 +869,37 @@ export interface MerchantInstanceConfig {
|
|||||||
defaultPayDelay?: time.Duration;
|
defaultPayDelay?: time.Duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldLinger(): boolean {
|
||||||
|
return process.env["TALER_TEST_KEEP"] == "1";
|
||||||
|
}
|
||||||
|
|
||||||
export function runTest(testMain: (gc: GlobalTestState) => Promise<void>) {
|
export function runTest(testMain: (gc: GlobalTestState) => Promise<void>) {
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const gc = new GlobalTestState({
|
let gc: GlobalTestState | undefined;
|
||||||
|
let ret = 0;
|
||||||
|
try {
|
||||||
|
gc = new GlobalTestState({
|
||||||
testDir: await makeTempDir(),
|
testDir: await makeTempDir(),
|
||||||
});
|
});
|
||||||
try {
|
|
||||||
await testMain(gc);
|
await testMain(gc);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("FATAL: test failed with exception", e);
|
||||||
|
ret = 1;
|
||||||
} finally {
|
} finally {
|
||||||
await gc.terminate();
|
if (gc) {
|
||||||
if (process.env["TALER_TEST_KEEP"] !== "1") {
|
if (shouldLinger()) {
|
||||||
console.log("test logs and config can be found under", gc.testDir);
|
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) => {
|
main();
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function shellWrap(s: string) {
|
function shellWrap(s: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user