Public: anyone can read this; the crew can change it.
test/checks.test.ts runs under 10 s #3518
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/3494-test-checks-test-ts-runs-under-10-s → main 1 commit fork 1 thread · 1 unresolved
1 file
changed +13
−7
test/checks.test.ts +13 −7
| @@ -631,7 +631,7 @@ describe("checks", () => { | ||
| 631 | 631 | const slow = await commitToBranch(app, alice, repo, { |
| 632 | 632 | message: "A slow check", |
| 633 | 633 | files: [ |
| 634 | { path: "forge.json", content: checkJson("sleep 2 && test -f OK.md") }, | |
| 634 | { path: "forge.json", content: checkJson("sleep 0.5 && test -f OK.md") }, | |
| 635 | 635 | ], |
| 636 | 636 | }); |
| 637 | 637 | if (!slow.ok) throw new Error(JSON.stringify(slow.error)); |
| @@ -717,7 +717,7 @@ describe("checks", () => { | ||
| 717 | 717 | files: [ |
| 718 | 718 | { |
| 719 | 719 | path: "forge.json", |
| 720 | content: checkJson(`sleep 2 && test -f OK.md # ${ending}`), | |
| 720 | content: checkJson(`sleep 0.5 && test -f OK.md # ${ending}`), | |
| 721 | 721 | }, |
| 722 | 722 | ], |
| 723 | 723 | }); |
| @@ -820,7 +820,7 @@ describe("checks", () => { | ||
| 820 | 820 | branch: "order-hold", |
| 821 | 821 | message: "Hold the slot", |
| 822 | 822 | files: [ |
| 823 | { path: "forge.json", content: checkJson("sleep 2 && test -f OK.md") }, | |
| 823 | { path: "forge.json", content: checkJson("sleep 0.5 && test -f OK.md") }, | |
| 824 | 824 | ], |
| 825 | 825 | }); |
| 826 | 826 | if (!held.ok) throw new Error(JSON.stringify(held.error)); |
| @@ -870,7 +870,13 @@ describe("checks", () => { | ||
| 870 | 870 | const slow = await commitToBranch(app, alice, repo, { |
| 871 | 871 | message: "A slower check", |
| 872 | 872 | files: [ |
| 873 | { path: "forge.json", content: checkJson("sleep 3 && test -f OK.md") }, | |
| 873 | { | |
| 874 | path: "forge.json", | |
| 875 | // Hangs the first time it runs, passes the second: no wait to tune. | |
| 876 | content: checkJson( | |
| 877 | `if [ -f '${dataDir}/ran-once' ]; then test -f OK.md; else touch '${dataDir}/ran-once'; sleep 60; fi`, | |
| 878 | ), | |
| 879 | }, | |
| 874 | 880 | ], |
| 875 | 881 | }); |
| 876 | 882 | if (!slow.ok) throw new Error(JSON.stringify(slow.error)); |
| @@ -926,7 +932,7 @@ describe("checks", () => { | ||
| 926 | 932 | concurrency: 1, |
| 927 | 933 | drainMs: 30_000, |
| 928 | 934 | }); |
| 929 | const id = await slowCheck("sleep 2 && test -f OK.md # drained", "A drained check"); | |
| 935 | const id = await slowCheck("sleep 0.5 && test -f OK.md # drained", "A drained check"); | |
| 930 | 936 | await checks.stop(); |
| 931 | 937 | const run = getRun(app.db, id); |
| 932 | 938 | expect(run?.state).toBe("ok"); |
| @@ -945,7 +951,7 @@ describe("checks", () => { | ||
| 945 | 951 | concurrency: 1, |
| 946 | 952 | drainMs: 30_000, |
| 947 | 953 | }); |
| 948 | const id = await slowCheck("sleep 3 && test -f OK.md # cut off", "A cut-off check"); | |
| 954 | const id = await slowCheck("sleep 0.5 && test -f OK.md # cut off", "A cut-off check"); | |
| 949 | 955 | await checks.stop({ drain: false }); |
| 950 | 956 | const run = getRun(app.db, id); |
| 951 | 957 | expect(run?.state).toBe("cancelled"); |
| @@ -960,7 +966,7 @@ describe("checks", () => { | ||
| 960 | 966 | }, 60_000); |
| 961 | 967 | |
| 962 | 968 | test("a check whose pull lands while it runs ends as superseded, not failed", async () => { |
| 963 | const id = await slowCheck("sleep 2 && false", "A check overtaken"); | |
| 969 | const id = await slowCheck("sleep 0.5 && false", "A check overtaken"); | |
| 964 | 970 | cancelRun(app.db, id, "pull landed"); |
| 965 | 971 | const deadline = Date.now() + 20_000; |
| 966 | 972 | let lines = ""; |
new above
offline
Good: hang-once removes the timing dependency. Apply the same pattern to the 0.5 s holds at the supersede/order tests so they cannot flake on a loaded machine.