1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-02 04:57:46 +02:00

Pass earlyExit parameter to run method so tests don't hang

This commit is contained in:
Chad Kimes 2023-08-08 15:15:33 +00:00
parent a29b2aba12
commit 74148e1261
2 changed files with 16 additions and 8 deletions

View file

@ -1,12 +1,14 @@
import restoreImpl from "./restoreImpl"; import restoreImpl from "./restoreImpl";
import { StateProvider } from "./stateProvider"; import { StateProvider } from "./stateProvider";
async function run(): Promise<void> { async function run(earlyExit?: boolean | undefined): Promise<void> {
try { try {
await restoreImpl(new StateProvider()); await restoreImpl(new StateProvider());
} catch (err) { } catch (err) {
console.error(err); console.error(err);
process.exit(1); if (earlyExit) {
process.exit(1);
}
} }
// node will stay alive if any promises are not resolved, // node will stay alive if any promises are not resolved,
@ -14,9 +16,11 @@ async function run(): Promise<void> {
// due to retries or timeouts. We know that if we got here // due to retries or timeouts. We know that if we got here
// that all promises that we care about have successfully // that all promises that we care about have successfully
// resolved, so simply exit with success. // resolved, so simply exit with success.
process.exit(0); if (earlyExit) {
process.exit(0);
}
} }
run(); run(true);
export default run; export default run;

View file

@ -1,12 +1,14 @@
import restoreImpl from "./restoreImpl"; import restoreImpl from "./restoreImpl";
import { NullStateProvider } from "./stateProvider"; import { NullStateProvider } from "./stateProvider";
async function run(): Promise<void> { async function run(earlyExit?: boolean | undefined): Promise<void> {
try { try {
await restoreImpl(new NullStateProvider()); await restoreImpl(new NullStateProvider());
} catch (err) { } catch (err) {
console.error(err); console.error(err);
process.exit(1); if (earlyExit) {
process.exit(1);
}
} }
// node will stay alive if any promises are not resolved, // node will stay alive if any promises are not resolved,
@ -14,9 +16,11 @@ async function run(): Promise<void> {
// due to retries or timeouts. We know that if we got here // due to retries or timeouts. We know that if we got here
// that all promises that we care about have successfully // that all promises that we care about have successfully
// resolved, so simply exit with success. // resolved, so simply exit with success.
process.exit(0); if (earlyExit) {
process.exit(0);
}
} }
run(); run(true);
export default run; export default run;