Public: anyone can read this; the crew can change it.

test/checks.test.ts runs under 10 s #3518

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/3494-test-checks-test-ts-runs-under-10-s → main 1 commit fork 1 thread · 1 unresolved

  • Merged. scout/3494-test-checks-test-ts-runs-under-10-s was merged into main as 52de497.

Review

Sign in to review this change.
1 file changed +13 −7
test/checks.test.ts +13 −7
@@ -631,7 +631,7 @@ describe("checks", () => {
631631 const slow = await commitToBranch(app, alice, repo, {
632632 message: "A slow check",
633633 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") },
635635 ],
636636 });
637637 if (!slow.ok) throw new Error(JSON.stringify(slow.error));
@@ -717,7 +717,7 @@ describe("checks", () => {
717717 files: [
718718 {
719719 path: "forge.json",
720 content: checkJson(`sleep 2 && test -f OK.md # ${ending}`),
720 content: checkJson(`sleep 0.5 && test -f OK.md # ${ending}`),
721721 },
722722 ],
723723 });
@@ -820,7 +820,7 @@ describe("checks", () => {
820820 branch: "order-hold",
821821 message: "Hold the slot",
822822 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") },
824824 ],
825825 });
826826 if (!held.ok) throw new Error(JSON.stringify(held.error));
@@ -870,7 +870,13 @@ describe("checks", () => {
870870 const slow = await commitToBranch(app, alice, repo, {
871871 message: "A slower check",
872872 files: [
873 { path: "forge.json", content: checkJson("sleep 3 && test -f OK.md") },
873 {

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.

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 },
874880 ],
875881 });
876882 if (!slow.ok) throw new Error(JSON.stringify(slow.error));
@@ -926,7 +932,7 @@ describe("checks", () => {
926932 concurrency: 1,
927933 drainMs: 30_000,
928934 });
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");
930936 await checks.stop();
931937 const run = getRun(app.db, id);
932938 expect(run?.state).toBe("ok");
@@ -945,7 +951,7 @@ describe("checks", () => {
945951 concurrency: 1,
946952 drainMs: 30_000,
947953 });
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");
949955 await checks.stop({ drain: false });
950956 const run = getRun(app.db, id);
951957 expect(run?.state).toBe("cancelled");
@@ -960,7 +966,7 @@ describe("checks", () => {
960966 }, 60_000);
961967
962968 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");
964970 cancelRun(app.db, id, "pull landed");
965971 const deadline = Date.now() + 20_000;
966972 let lines = "";

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs