mirror of https://github.com/actions/cache.git
Pass earlyExit parameter to run method so tests don't hang
parent
a29b2aba12
commit
74148e1261
@ -1,22 +1,26 @@
|
|||||||
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);
|
||||||
|
if (earlyExit) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// node will stay alive if any promises are not resolved,
|
// node will stay alive if any promises are not resolved,
|
||||||
// which is a possibility if HTTP requests are dangling
|
// which is a possibility if HTTP requests are dangling
|
||||||
// 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.
|
||||||
|
if (earlyExit) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run(true);
|
||||||
|
|
||||||
export default run;
|
export default run;
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
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);
|
||||||
|
if (earlyExit) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// node will stay alive if any promises are not resolved,
|
// node will stay alive if any promises are not resolved,
|
||||||
// which is a possibility if HTTP requests are dangling
|
// which is a possibility if HTTP requests are dangling
|
||||||
// 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.
|
||||||
|
if (earlyExit) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run(true);
|
||||||
|
|
||||||
export default run;
|
export default run;
|
||||||
|
Loading…
Reference in New Issue