Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

test(view): stop a recorded view even after a failed check [H5,N26]

Corey Olson89ece6ad4b03
diff --git a/test/background-view.test.js b/test/background-view.test.js
index 497347e2..607d0086 100644
--- a/test/background-view.test.js
+++ b/test/background-view.test.js
@@ -19,6 +19,9 @@ after(e2e.cleanup);
async function backgroundBox(t, name) {
const box = e2e.sandbox();
const lease = await takeDefaultViewPort(box.dir, { agent: `background-view-${name}-${process.pid}` });
+ // After-hooks run in order: stop any view this home's record names first, even one a failing
+ // assertion never reached, then free the port.
+ t.after(() => stopRecordedView(box, lease.port));
t.after(() => lease.release());
box.env.PULLBOARD_VIEW_PORT = String(lease.port);
delete box.env.PULLBOARD_VIEW_BACKGROUND;
@@ -54,6 +57,14 @@ function viewProcesses(port) {
.map((line) => Number(line.trim().split(/\s+/u)[0]));
}
+/** Stop the view this private home's session record names, by that pid, when there is one. */
+async function stopRecordedView(box, port) {
+ let record;
+ try { record = sessionRecord(box, port); }
+ catch (error) { if (error.code === 'ENOENT') return; throw error; }
+ if (Number.isInteger(record.pid) && record.pid > 1 && record.pid !== process.pid) await stopView(record.pid);
+}
+
/** The private session record a background view left for this port. */
function sessionRecord(box, port) {
return JSON.parse(readFileSync(join(box.env.PULLBOARD_HOME, `view-${port}.json`), 'utf8'));