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

test/looks.test.ts: the look-while-tests-run case holds the app's tests open with a gate, not a 2 s sleep #1025

Closed opened this
Closed without merging

scout/forge:scout/968-test-looks-test-ts-the-look-while-tests → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
1 file changed +16 −5
test/looks.test.ts +16 −5
@@ -19,7 +19,7 @@ import { addToCrew, createAgent } from "../src/actions/crew.ts";
1919 import { setIssueStateThrough } from "../src/actions/issues.ts";
2020 import { openPull } from "../src/actions/pulls.ts";
2121 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
22 import { envDataDir, previewEnv } from "../src/apps/data.ts";
22 import { envDataDir, envDir, previewEnv } from "../src/apps/data.ts";
2323 import { readGrant } from "../src/apps/proxy.ts";
2424 import { AppsRuntime } from "../src/apps/runtime.ts";
2525 import { getAppByRepo, type AppRecord } from "../src/core/apps.ts";
@@ -424,6 +424,9 @@ describe("the look", () => {
424424 });
425425
426426 test("a look is taken from `app.serving`, while the deploy's tests are still running, and a red check afterward does not remove it", async () => {
427 // The app's test blocks until this file exists in its checkout (the one
428 // place a contained step shares with the forge), then exits red.
429 const gate = ".gate";
427430 const branch = await commitToBranch(app, alice, repo, {
428431 branch: "slow-red-test",
429432 base: repo.defaultBranch,
@@ -435,7 +438,7 @@ describe("the look", () => {
435438 {
436439 app: {
437440 run: "bun run src/server.ts",
438 test: "sleep 2 && exit 1",
441 test: `while [ ! -e ${gate} ]; do sleep 0.05; done; exit 1`,
439442 tty: "bun run src/tty.ts",
440443 },
441444 },
@@ -455,8 +458,8 @@ describe("the look", () => {
455458 const env = `pull-${opened.value.number}`;
456459 const commitOid = branch.value.commitOid;
457460
458 // Pictured well before the two-second test step could have finished —
459 // the run is still open, checking.
461 // Pictured while the test step is held at the gate — the run is still
462 // open, checking.
460463 const rows = await pictured(env, commitOid);
461464 expect(rows.every((l) => l.error === null)).toBe(true);
462465 const run = listRuns(app.db, repo.id, { env }).find(
@@ -468,8 +471,16 @@ describe("the look", () => {
468471 );
469472 expect(serving?.payload["env"]).toBe(env);
470473 expect(serving?.payload["testsRunning"]).toBe(true);
474 writeFileSync(
475 join(
476 envDir(dataDir, record.id, previewEnv(opened.value.number)),
477 commitOid.slice(0, 7),
478 gate,
479 ),
480 "",
481 );
471482
472 // The test then finishes red; the run fails, but the picture already
483 // Release the gate: the test then finishes red; the run fails, but the picture already
473484 // taken of what is serving is untouched.
474485 const failed = await settled(
475486 (r) => r.env === env && r.commitOid === commitOid,

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs