diff --git a/packages/cli/tests/repl-execution.test.ts b/packages/cli/tests/repl-execution.test.ts index 79aba34dc..a38170d42 100644 --- a/packages/cli/tests/repl-execution.test.ts +++ b/packages/cli/tests/repl-execution.test.ts @@ -1215,30 +1215,32 @@ describe(SELECTION_SUITE, () => { }); }); - it("X1: a host's defined empty selection refuses the entry before its body", function* () { - const holder = execution(); - const entry = opened( - yield* submitReplEntry({ - ...options(holder), - source: DESCRIBING, - installations: [selecting({})], - }), - ); + const emptySelection = "X1: a host's defined empty selection refuses the entry before its body"; + it(emptySelection, () => + captureEntry(SELECTION_SUITE, emptySelection, INLINE_SOURCE_PATH, function* (holder) { + const entry = opened( + yield* submitReplEntry({ + ...options(holder), + source: DESCRIBING, + installations: [selecting({})], + }), + ); - // Defined and empty is a host statement, not an absence: core refuses the - // setup rather than this session answering over it with its default. - const settled = yield* entry.join(); - expect(settled.ok).toBe(false); - expect(settled.ok ? "" : settled.error.message).toContain("selected no component"); - // Refused before the entry body: the document rendered nothing and the - // fragment was never admitted. - expect(entry.model.terminal?.output ?? "").toBe(""); - expect( - (yield* readAll(holder)).filter( - (event) => event.type === "yield" && event.description.type === "generated_xmd", - ), - ).toEqual([]); - }); + // Defined and empty is a host statement, not an absence: core refuses the + // setup rather than this session answering over it with its default. + const settled = yield* entry.join(); + expect(settled.ok).toBe(false); + expect(settled.ok ? "" : settled.error.message).toContain("selected no component"); + // Refused before the entry body: the document rendered nothing and the + // fragment was never admitted. + expect(entry.model.terminal?.output ?? "").toBe(""); + expect( + (yield* readAll(holder)).filter( + (event) => event.type === "yield" && event.description.type === "generated_xmd", + ), + ).toEqual([]); + }), + ); }); describe("execution initialization in REPL entries", () => { diff --git a/packages/core/tests/code-block-component.test.ts b/packages/core/tests/code-block-component.test.ts index 8ef3c8b44..8e018ea1d 100644 --- a/packages/core/tests/code-block-component.test.ts +++ b/packages/core/tests/code-block-component.test.ts @@ -34,7 +34,11 @@ import { collect } from "../src/collect.ts"; import { execute } from "../src/execute.ts"; import { registerComponents } from "../src/components/registration.ts"; import type { Json } from "../src/types.ts"; -import { journalBeforeEach, useJournalStream } from "@executablemd/test-support/failure-journal"; +import { + captureTestJournal, + journalBeforeEach, + useJournalStream, +} from "@executablemd/test-support/failure-journal"; const OWNER = "packages/core/tests/code-block-component.test.ts"; @@ -151,20 +155,30 @@ function* captured( describe("Tier CB — the envelope", () => { beforeEach(journalBeforeEach(OWNER)); - it("CB1: an empty value is three backticks, two line feeds and nothing else", function* () { - const result = yield* directly(undefined, ""); - - expect(result.failure).toBe(""); - expect(result.output).toBe("```\n\n```"); - expect(yield* captured(undefined, "")).toBe("```\n\n```"); + const emptyValue = "CB1: an empty value is three backticks, two line feeds and nothing else"; + it(emptyValue, function* () { + const label = { owner: OWNER, name: emptyValue }; + yield* captureTestJournal(label, "doc.md", function* (stream) { + yield* captureTestJournal(label, "doc.md", function* (compared) { + const result = yield* directly(stream, ""); + expect(result.failure).toBe(""); + expect(result.output).toBe("```\n\n```"); + expect(yield* captured(compared, "")).toBe("```\n\n```"); + }); + }); }); - it("CB1: ordinary Markdown keeps its own lines, and gains no final line feed", function* () { - const value = "# Title\n\n- one\n- two"; - const result = yield* directly(undefined, value); - - expect(result.output).toBe("```\n# Title\n\n- one\n- two\n```"); - expect(yield* captured(undefined, value)).toBe("```\n# Title\n\n- one\n- two\n```"); + const markdownValue = "CB1: ordinary Markdown keeps its own lines, and gains no final line feed"; + it(markdownValue, function* () { + const label = { owner: OWNER, name: markdownValue }; + yield* captureTestJournal(label, "doc.md", function* (stream) { + yield* captureTestJournal(label, "doc.md", function* (compared) { + const value = "# Title\n\n- one\n- two"; + const result = yield* directly(stream, value); + expect(result.output).toBe("```\n# Title\n\n- one\n- two\n```"); + expect(yield* captured(compared, value)).toBe("```\n# Title\n\n- one\n- two\n```"); + }); + }); }); it("CB1: the block lands where the element was written", function* () { @@ -183,7 +197,8 @@ describe("Tier CB — the envelope", () => { describe("Tier CB — the fence the value cannot close", () => { beforeEach(journalBeforeEach(OWNER)); - it("CB2: the fence is the longest backtick run plus one, never fewer than three", function* () { + const fenceCase = "CB2: the fence is the longest backtick run plus one, never fewer than three"; + it(fenceCase, function* () { const cases: ReadonlyArray = [ ["no backticks at all", 3], ["one ` here", 3], @@ -198,25 +213,34 @@ describe("Tier CB — the fence the value cannot close", () => { ]; for (const [value, length] of cases) { - const block = yield* captured(undefined, value); - const fence = "`".repeat(length); - - expect(block).toBe(`${fence}\n${value}\n${fence}`); - // Stated twice on purpose: the complete string pins the layout, and this - // pins the count the layout was built from. - expect(block.split("\n")[0]?.length).toBe(length); + yield* captureTestJournal({ owner: OWNER, name: fenceCase }, "doc.md", function* (stream) { + const block = yield* captured(stream, value); + const fence = "`".repeat(length); + + expect(block).toBe(`${fence}\n${value}\n${fence}`); + // Stated twice on purpose: the complete string pins the layout, and this + // pins the count the layout was built from. + expect(block.split("\n")[0]?.length).toBe(length); + }); } }); - it("CB2: a run broken by any other character is two runs, not one", function* () { - // Counting backticks without resetting would read five here and open a - // six-backtick fence. - expect(yield* captured(undefined, "```\n``")).toBe("````\n```\n``\n````"); - expect(yield* captured(undefined, "``x``x``")).toBe("```\n``x``x``\n```"); + const brokenRun = "CB2: a run broken by any other character is two runs, not one"; + it(brokenRun, function* () { + const label = { owner: OWNER, name: brokenRun }; + yield* captureTestJournal(label, "doc.md", function* (stream) { + yield* captureTestJournal(label, "doc.md", function* (compared) { + // Counting backticks without resetting would read five here and open a + // six-backtick fence. + expect(yield* captured(stream, "```\n``")).toBe("````\n```\n``\n````"); + expect(yield* captured(compared, "``x``x``")).toBe("```\n``x``x``\n```"); + }); + }); }); }); describe("Tier CB — the value is not read for anything else", () => { + beforeEach(journalBeforeEach(OWNER)); it("CB3: removing the envelope recovers the source code units exactly", function* () { const value = [ " leading spaces", @@ -248,18 +272,25 @@ describe("Tier CB — the language token", () => { expect((yield* captured(undefined, "plain")).split("\n")[0]).toBe("```"); }); - it("CB4: every accepted token renders on the opening fence, unchanged", function* () { + const acceptedLanguage = "CB4: every accepted token renders on the opening fence, unchanged"; + it(acceptedLanguage, function* () { const accepted = ["markdown", "md", "json", "shell-session", "c++", "c#", "F", "x1._+#-"]; for (const language of accepted) { - const result = yield* directly(undefined, "body", ` language="${language}"`); - - expect(result.failure).toBe(""); - expect(result.output).toBe("```" + language + "\nbody\n```"); + yield* captureTestJournal( + { owner: OWNER, name: acceptedLanguage }, + "doc.md", + function* (stream) { + const result = yield* directly(stream, "body", ` language="${language}"`); + expect(result.failure).toBe(""); + expect(result.output).toBe("```" + language + "\nbody\n```"); + }, + ); } }); - it("CB4: a refused token fails validation and renders no fence", function* () { + const refusedLanguage = "CB4: a refused token fails validation and renders no fence"; + it(refusedLanguage, function* () { const refused = [ "", " ", @@ -285,16 +316,22 @@ describe("Tier CB — the language token", () => { ]; for (const language of refused) { - const result = yield* run( - undefined, - '', - { v: "body", lang: language }, + yield* captureTestJournal( + { owner: OWNER, name: refusedLanguage }, + "doc.md", + function* (stream) { + const result = yield* run( + stream, + '', + { v: "body", lang: language }, + ); + + expect(reported(result)).toContain("Prop validation failed for "); + expect(reported(result)).toContain("language"); + expect(result.output).not.toContain("```"); + expect(result.output).not.toContain("body"); + }, ); - - expect(reported(result)).toContain("Prop validation failed for "); - expect(reported(result)).toContain("language"); - expect(result.output).not.toContain("```"); - expect(result.output).not.toContain("body"); } }); }); @@ -309,12 +346,14 @@ describe("Tier CB — the invocation is refused before the body", () => { expect(result.output).not.toContain("```"); }); - it("CB5: a non-string value is refused rather than coerced", function* () { + const nonString = "CB5: a non-string value is refused rather than coerced"; + it(nonString, function* () { for (const value of ["42", "true", "null", "{ text: 'x' }", "['x']"]) { - const result = yield* run(undefined, ``); - - expect(reported(result)).toContain("Prop validation failed for "); - expect(result.output).not.toContain("```"); + yield* captureTestJournal({ owner: OWNER, name: nonString }, "doc.md", function* (stream) { + const result = yield* run(stream, ``); + expect(reported(result)).toContain("Prop validation failed for "); + expect(result.output).not.toContain("```"); + }); } }); diff --git a/packages/core/tests/component-module-loader.test.ts b/packages/core/tests/component-module-loader.test.ts index 6eac39456..a166688d5 100644 --- a/packages/core/tests/component-module-loader.test.ts +++ b/packages/core/tests/component-module-loader.test.ts @@ -1,9 +1,16 @@ +import { captureTestJournal } from "@executablemd/test-support/failure-journal"; +import { API } from "@executablemd/runtime"; +import { + checkSubprocessJournals, + parseSubprocessJournal, + readSubprocessSnapshot, +} from "../../test-support/subprocess-journal.ts"; import { describe, it } from "@executablemd/test-support/bdd"; import { expect } from "@executablemd/test-support/expect"; import { useTempDirectory } from "@executablemd/test-support/temp"; import { useComponentModuleLoader } from "@executablemd/test-support/host"; import { cliRuntime } from "@executablemd/test-support/launch"; -import { readTextFile, readdir, writeTextFile } from "@effectionx/fs"; +import { exists, readTextFile, readdir, writeTextFile } from "@effectionx/fs"; import { exec } from "@effectionx/process"; import { createContext, ensure, scoped, spawn, suspend, until, withResolvers } from "effection"; import type { Operation } from "effection"; @@ -11,7 +18,7 @@ import * as moduleApi from "node:module"; import { join } from "node:path"; import { execPath } from "node:process"; import { fileURLToPath, pathToFileURL } from "node:url"; -import { InMemoryStream } from "@executablemd/durable-streams"; +import type { InMemoryStream } from "@executablemd/durable-streams"; import { collect, Component, execute, registerComponents, useNormalizedOutput } from "../mod.ts"; import { ComponentModuleLoader, Execution } from "../api.ts"; import { useComponentModules } from "../src/typescript-module.ts"; @@ -25,7 +32,11 @@ const SOURCE = 'export const generated = { "self-closing": { identity: "https://executable.md/tests/module/typed", effect: "read" } };\nexport default function*() { const answer: string = "typed-module"; return answer; }'; const ROOT = fileURLToPath(new URL("../../../", import.meta.url)); -function render(directory: string, source = ""): Operation { +function render( + directory: string, + stream: InMemoryStream, + source = "", +): Operation { return scoped(function* () { yield* useNormalizedOutput(); return yield* collect( @@ -33,14 +44,22 @@ function render(directory: string, source = ""): Operation { source, path: "", includes: [directory], - stream: new InMemoryStream(), + stream, }), ); }); } +const OWNER = "packages/core/tests/component-module-loader.test.ts"; + +function captureLoad(name: string, body: (stream: InMemoryStream) => Operation) { + return captureTestJournal({ owner: OWNER, name }, "", body); +} + describe("ComponentModuleLoader", () => { - it("L1: requires explicit installation independently of eval, Markdown and registrations", function* () { + const requiresLoader = + "L1: requires explicit installation independently of eval, Markdown and registrations"; + it(requiresLoader, function* () { const directory = yield* useTempDirectory("component-loader-install-"); const entered = `loader-absent-${directory}`; yield* writeTextFile( @@ -49,13 +68,13 @@ describe("ComponentModuleLoader", () => { ); yield* ComponentModuleLoader.set(undefined); for (const evalCompiler of [false, true]) { - yield* scoped(function* () { + yield* captureLoad(requiresLoader, function* (stream) { if (evalCompiler) { yield* useTempFileCompiler(); } let diagnostic = ""; try { - yield* render(directory); + yield* render(directory, stream); } catch (error) { diagnostic = error instanceof Error ? error.message : String(error); } @@ -64,7 +83,9 @@ describe("ComponentModuleLoader", () => { expect((yield* readdir(directory)).sort()).toEqual(["Typed.ts"]); }); } - expect(yield* render(directory, "Markdown alone")).toContain("Markdown alone"); + yield* captureLoad(requiresLoader, function* (stream) { + expect(yield* render(directory, stream, "Markdown alone")).toContain("Markdown alone"); + }); yield* registerComponents([ { name: "Registered", @@ -75,16 +96,22 @@ describe("ComponentModuleLoader", () => { }, }, ]); - expect(yield* render(directory, "")).toContain("registered"); + yield* captureLoad(requiresLoader, function* (stream) { + expect(yield* render(directory, stream, "")).toContain("registered"); + }); yield* ensure(function* () { Reflect.deleteProperty(globalThis, entered); }); yield* useComponentModuleLoader(); - expect(yield* render(directory)).toContain("typed-module"); - expect(Reflect.get(globalThis, entered)).toBe(true); + yield* captureLoad(requiresLoader, function* (stream) { + expect(yield* render(directory, stream)).toContain("typed-module"); + expect(Reflect.get(globalThis, entered)).toBe(true); + }); }); - it("L2: captures one bound selection for profile and durable loading across later rebinding", function* () { + const fixedSelection = + "L2: captures one bound selection for profile and durable loading across later rebinding"; + it(fixedSelection, function* () { yield* useComponentModuleLoader(); const native = yield* ComponentModuleLoader.expect(); if (native === undefined) { @@ -115,28 +142,32 @@ describe("ComponentModuleLoader", () => { ); yield* copy.set(A); expect(yield* ComponentModuleLoader.get()).toBe(A); - yield* scoped(function* () { - yield* Component.around({ generated: () => ({ Typed: ["self-closing"] }) }); - yield* Execution.around({ - *execute([request], next) { - yield* ComponentModuleLoader.set(B); - yield* next(request); - }, + yield* captureLoad(fixedSelection, function* (stream) { + yield* scoped(function* () { + yield* Component.around({ generated: () => ({ Typed: ["self-closing"] }) }); + yield* Execution.around({ + *execute([request], next) { + yield* ComponentModuleLoader.set(B); + yield* next(request); + }, + }); + expect( + yield* render(directory, stream, '\n'), + ).toContain("typed-module"); + }); + expect(calls.length).toBeGreaterThanOrEqual(2); + expect( + calls.every( + (call) => call.provider === "A" && call.source === SOURCE && call.origin === origin, + ), + ).toBe(true); + calls.length = 0; + yield* copy.set(B); + yield* captureLoad(fixedSelection, function* (secondStream) { + expect(yield* render(directory, secondStream)).toContain("typed-module"); + expect(calls).toEqual([{ provider: "B", source: SOURCE, origin }]); }); - expect(yield* render(directory, '\n')).toContain( - "typed-module", - ); }); - expect(calls.length).toBeGreaterThanOrEqual(2); - expect( - calls.every( - (call) => call.provider === "A" && call.source === SOURCE && call.origin === origin, - ), - ).toBe(true); - calls.length = 0; - yield* copy.set(B); - expect(yield* render(directory)).toContain("typed-module"); - expect(calls).toEqual([{ provider: "B", source: SOURCE, origin }]); }); it("L3: joins native loading before releasing its owned hook or Blob", function* () { @@ -342,45 +373,154 @@ describe("ComponentModuleLoader", () => { }); if (cliRuntime() === "deno") { - it("P1: Deno loads under the preserved read-only envelope and retains authored write denial", function* () { + const readOnlyCase = + "P1: Deno loads under the preserved read-only envelope and retains authored write denial"; + const expected = "ordinary-read-only-component"; + + function runFixture(directory: string, mode: "read" | "write", capture = false) { + return exec(execPath, { + arguments: [ + "run", + "--config", + join(ROOT, "deno.json"), + "--node-modules-dir=manual", + "--allow-read", + "--allow-env", + "--allow-import", + "--deny-write", + "--no-prompt", + "--cached-only", + "--frozen", + join(ROOT, "packages/core/tests/fixtures/component-module-readonly.ts"), + directory, + mode, + ...(capture ? ["--capture-journal"] : []), + ], + }).join(); + } + + function* useReadOnlyFixture() { const directory = yield* useTempDirectory("component-loader-readonly-"); const direct = join(directory, "ReadOnly.ts"); yield* writeTextFile( direct, 'export default function*() { const value: string = "ordinary-read-only-component"; return value; }', ); - const before = yield* readTextFile(direct); - const fixture = join(ROOT, "packages/core/tests/fixtures/component-module-readonly.ts"); - for (const mode of ["read", "write"]) { - const result = yield* exec(execPath, { - arguments: [ - "run", - "--config", - join(ROOT, "deno.json"), - "--node-modules-dir=manual", - "--allow-read", - "--allow-env", - "--allow-import", - "--deny-write", - "--no-prompt", - "--cached-only", - "--frozen", - fixture, - directory, - mode, - ], - }).join(); + return { directory, direct, before: yield* readTextFile(direct) }; + } + + function* checkCapturedRead( + directory: string, + name: string, + check: ( + output: string, + snapshot: ReturnType, + ) => Operation, + ) { + const result = yield* runFixture(directory, "read", true); + let data: unknown; + try { + data = JSON.parse(result.stdout); + } catch { + data = undefined; + } + const snapshot = readSubprocessSnapshot( + data && typeof data === "object" && "journals" in data ? data.journals : undefined, + 0, + ); + yield* checkSubprocessJournals( + { owner: OWNER, name }, + [{ source: "", snapshot }], + function* () { + expect({ mode: "read", code: result.code, stderr: result.stderr }).toEqual({ + mode: "read", + code: 0, + stderr: "", + }); + const output = + data && typeof data === "object" && "output" in data && typeof data.output === "string" + ? data.output.trim() + : ""; + yield* check(output, snapshot); + }, + ); + } + + it(readOnlyCase, function* () { + const { directory, direct, before } = yield* useReadOnlyFixture(); + yield* checkCapturedRead(directory, readOnlyCase, function* (output) { + expect(output).toBe(expected); + const mode = "write"; + const result = yield* runFixture(directory, mode); expect({ mode, code: result.code, stderr: result.stderr }).toEqual({ mode, code: 0, stderr: "", }); - expect(result.stdout.trim()).toBe( - mode === "read" ? "ordinary-read-only-component" : "authored-write-denied", - ); + expect(result.stdout.trim()).toBe("authored-write-denied"); + expect(yield* readTextFile(direct)).toBe(before); + expect((yield* readdir(directory)).sort()).toEqual(["ReadOnly.ts"]); + }); + }); + + const witness = + "P1: attributes a read-only child journal when the joined parent's assertion fails"; + it(witness, function* () { + const { directory } = yield* useReadOnlyFixture(); + const raw = yield* runFixture(directory, "read"); + expect({ code: raw.code, stderr: raw.stderr, stdout: raw.stdout.trim() }).toEqual({ + code: 0, + stderr: "", + stdout: expected, + }); + const artifacts = join(yield* useTempDirectory("readonly-journal-"), "test-artifacts"); + yield* API.Env.around({ + *env([name], next) { + return name === "XMD_TEST_ARTIFACTS" ? artifacts : yield* next(name); + }, + }); + // deno-lint-ignore require-yield + yield* checkCapturedRead(directory, witness, function* (output, snapshot) { + expect(output).toBe(expected); + expect(snapshot).toBeInstanceOf(Array); + }); + expect(yield* exists(artifacts)).toBe(false); + + let assertion: unknown; + let caught: unknown; + let received: ReturnType = "snapshot absent"; + try { + // deno-lint-ignore require-yield + yield* checkCapturedRead(directory, witness, function* (output, snapshot) { + received = snapshot; + try { + expect(output).toBe("missing result"); + } catch (error) { + assertion = error; + throw error; + } + }); + } catch (error) { + caught = error; } - expect(yield* readTextFile(direct)).toBe(before); - expect((yield* readdir(directory)).sort()).toEqual(["ReadOnly.ts"]); + expect(assertion).toBeInstanceOf(Error); + expect(caught).toBe(assertion); + + const invocations = yield* readdir(artifacts); + expect(invocations).toHaveLength(1); + const saved = join(artifacts, invocations[0]!); + expect((yield* readdir(saved)).sort()).toEqual(["child-1.case.json", "child-1.jsonl"]); + expect(JSON.parse(yield* readTextFile(join(saved, "child-1.case.json")))).toEqual({ + owner: OWNER, + name: witness, + kind: "child", + ordinal: 1, + source: "", + }); + const lines = (yield* readTextFile(join(saved, "child-1.jsonl"))).trimEnd().split("\n"); + const replay = parseSubprocessJournal(lines); + expect(replay).toEqual(received); + expect(replay.at(-1)).toMatchObject({ type: "close", coroutineId: "root" }); }); } }); diff --git a/packages/core/tests/execute.test.ts b/packages/core/tests/execute.test.ts index 19649d447..ea80bfe86 100644 --- a/packages/core/tests/execute.test.ts +++ b/packages/core/tests/execute.test.ts @@ -119,7 +119,7 @@ describe("Tier B — durable import", () => { beforeEach(journalBeforeEach(OWNER)); // B1: durableImportComponent golden run — journal shape it("B1: import golden run — journal has import_component with path and content", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": "Hello world\n" }); yield* useStubExec(); @@ -226,7 +226,7 @@ describe("Tier B — durable import", () => { // B12: root document as component — __root__ import, same journal shape it("B12: root document imported as __root__", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("doc.md"); yield* useStubFs({ "doc.md": "Root content\n" }); yield* useStubExec(); @@ -252,7 +252,7 @@ describe("Tier B — durable import", () => { // B13: dotted name resolution — Ns.Sub → components/Ns/Sub.md it("B13: dotted component name resolves to nested path", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": "\n", "components/Ui/Button.md": "Click me\n", @@ -313,7 +313,7 @@ describe("Tier D — code execution and modifiers", () => { beforeEach(journalBeforeEach(OWNER)); // D1: bash exec golden run it("D1: bash exec golden run — stdout displayed, exec in journal", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": ["```bash exec", "echo hello", "```"].join("\n"), }); @@ -409,7 +409,7 @@ describe("Tier D — code execution and modifiers", () => { // D4: multi-line command — full script passed to -c it("D4: multi-line command — full script in journal", function* () { const multiLineScript = "echo line1\necho line2"; - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": ["```bash exec", multiLineScript, "```"].join("\n"), }); @@ -440,7 +440,7 @@ describe("Tier D — code execution and modifiers", () => { "README.md": ["```python exec", "print('hello')", "```"].join("\n"), }; - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs(files); // Custom exec middleware that handles python -c yield* API.Process.around({ @@ -473,7 +473,7 @@ describe("Tier D — code execution and modifiers", () => { // D6: bash silent exec — chain: silent wraps exec, exec journals, silent returns empty it("D6: bash silent exec — exec journals, output suppressed", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": ["```bash silent exec", "echo secret", "```"].join("\n"), }); @@ -533,7 +533,7 @@ describe("Tier D — code execution and modifiers", () => { // success (#307). The command's exit code and stderr are the chain's, so a // silenced failure is still a failure — with nothing of what it printed. it("D6b: failing silent exec — output suppressed, failure still reported", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": ["```bash silent exec", "echo secret", "```"].join("\n"), }); @@ -551,7 +551,7 @@ describe("Tier D — code execution and modifiers", () => { }); it("D6c: a failing silent exec in documentation aborts before the next block", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": [ "```bash silent exec", @@ -712,7 +712,7 @@ describe("execute", () => { beforeEach(journalBeforeEach(OWNER)); // E1: Full document golden run it("E1: full document golden run — root + component + exec", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": [ "---", @@ -854,7 +854,7 @@ describe("execute", () => { // E8: Silent exec in full document it("E8: silent exec — command runs, result journaled, output omitted", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": ["before", "", "```bash silent exec", "echo hidden", "```", "", "after"].join( "\n", @@ -1138,7 +1138,7 @@ describe("execute", () => { // Multiple components — verify all are imported and expanded it("multiple components — all imported and expanded", function* () { - const stream = new InMemoryStream(); + const stream = yield* useJournalStream("README.md"); yield* useStubFs({ "README.md": "
\n