Skip to content

Commit bd49bd6

Browse files
authored
Attribute retained mount, Git, and local test journals (#1381)
1 parent 6c4a5ea commit bd49bd6

3 files changed

Lines changed: 43 additions & 13 deletions

File tree

‎packages/cli/tests/retained-mount-files.test.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import { scanSegments } from "../../core/src/scanner.ts";
22
import { registerComponents } from "../../core/src/components/registration.ts";
3-
import { describe, it } from "@executablemd/test-support/bdd";
3+
import { beforeEach, describe, it } from "@executablemd/test-support/bdd";
4+
import { journalBeforeEach, useJournalStream } from "@executablemd/test-support/failure-journal";
45
import { expect } from "@executablemd/test-support/expect";
56
import { InMemoryStream } from "@executablemd/durable-streams";
67
import { mountedRun, trace } from "./support/mount-run.ts";
78
import { MOUNT_FILE, parseMountRecord } from "../src/repl/mount-records.ts";
89
import { parseReplLocalRecord, REPL_REPOSITORY_LOCAL } from "../src/repl/repositories/records.ts";
910
import { parseFilesFailure, useHostFiles } from "@executablemd/runtime";
10-
import { collect, inlineSource } from "@executablemd/core";
11+
import { collect, inlineSource, INLINE_SOURCE_PATH } from "@executablemd/core";
1112
import { executeInstalled } from "@executablemd/core/host";
1213
import { workspaceMountInstallation } from "../src/repl/workspace-mount-installation.ts";
1314
import type { FilePathInput } from "@executablemd/runtime";
1415

1516
const question = '<Elicit schema={{ type: "object" }} as="answer">Continue?</Elicit>';
17+
const OWNER = "packages/cli/tests/retained-mount-files.test.ts";
18+
1619
describe("retained mount files", () => {
20+
beforeEach(journalBeforeEach(OWNER));
21+
1722
it("985: Content carries mounted placement through retained read continuation", function* () {
1823
const wrapper = {
1924
*before() {
@@ -161,7 +166,13 @@ describe("retained mount files", () => {
161166
});
162167
},
163168
};
164-
const ordinary = yield* mountedRun(source, new InMemoryStream(), [], trace(), refusal);
169+
const ordinary = yield* mountedRun(
170+
source,
171+
yield* useJournalStream(INLINE_SOURCE_PATH),
172+
[],
173+
trace(),
174+
refusal,
175+
);
165176
expect(ordinary).toContain('"../outside.md" resolves outside the working directory.');
166177
for (const coverageRoot of [undefined, "/external"]) {
167178
const stream = new InMemoryStream();
@@ -250,7 +261,7 @@ describe("retained mount files", () => {
250261
const fresh = trace();
251262
yield* mountedRun(
252263
'<Dir path="/reference"><File path="old.md" /></Dir>',
253-
new InMemoryStream(),
264+
yield* useJournalStream(INLINE_SOURCE_PATH),
254265
mounts,
255266
fresh,
256267
);

‎packages/cli/tests/retained-repository-git.test.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import { Permissions } from "@executablemd/runtime";
2828
* therefore resolved nothing and selected nothing.
2929
*/
3030

31-
import { describe, it } from "@executablemd/test-support/bdd";
31+
import { beforeEach, describe, it } from "@executablemd/test-support/bdd";
32+
import { journalBeforeEach, useJournalStream } from "@executablemd/test-support/failure-journal";
3233
import { expect } from "@executablemd/test-support/expect";
3334
import {
3435
ensure,
@@ -532,8 +533,11 @@ function* admitted(events: readonly DurableEvent[]): Operation<string | undefine
532533

533534
/** The question an entry is left at, never answered. */
534535
const QUESTION = '<Elicit schema={{ type: "object" }} as="answer">Continue?</Elicit>';
536+
const OWNER = "packages/cli/tests/retained-repository-git.test.ts";
535537

536538
describe("one entry's local Add, Switch and Commit", () => {
539+
beforeEach(journalBeforeEach(OWNER));
540+
537541
it("E2: replays acknowledged Switch, Add and Commit with no Git work", function* () {
538542
const fixture = yield* useFixture();
539543
const live = counters();
@@ -667,7 +671,7 @@ describe("one entry's local Add, Switch and Commit", () => {
667671
const performed = yield* run(
668672
fixture,
669673
'<Git.Switch branch="ready" base="nothing-resolves-this" />',
670-
new InMemoryStream(),
674+
yield* useJournalStream(join(fixture.root, "entry.md")),
671675
counted,
672676
);
673677

@@ -694,7 +698,7 @@ describe("one entry's local Add, Switch and Commit", () => {
694698
const performed = yield* run(
695699
fixture,
696700
'<Git.Switch branch="fresh" />',
697-
new InMemoryStream(),
701+
yield* useJournalStream(join(fixture.root, "entry.md")),
698702
counted,
699703
);
700704

@@ -770,7 +774,7 @@ describe("one entry's local Add, Switch and Commit", () => {
770774
const performed = yield* run(
771775
fixture,
772776
['<Git.Commit message="Record the index" as="commit" />', "Commit: {commit}"].join("\n"),
773-
new InMemoryStream(),
777+
yield* useJournalStream(join(fixture.root, "entry.md")),
774778
counted,
775779
);
776780

@@ -1228,9 +1232,19 @@ describe("one entry's local Add, Switch and Commit", () => {
12281232
const source = '<Git.Add paths="note.md" />';
12291233

12301234
const first = counters();
1231-
const one = yield* run(fixture, source, new InMemoryStream(), first);
1235+
const one = yield* run(
1236+
fixture,
1237+
source,
1238+
yield* useJournalStream(join(fixture.root, "entry.md")),
1239+
first,
1240+
);
12321241
const second = counters();
1233-
const two = yield* run(fixture, source, new InMemoryStream(), second);
1242+
const two = yield* run(
1243+
fixture,
1244+
source,
1245+
yield* useJournalStream(join(fixture.root, "entry.md")),
1246+
second,
1247+
);
12341248

12351249
expect(one.refusal).toBe(undefined);
12361250
expect(two.refusal).toBe(undefined);

‎packages/cli/tests/retained-repository-local.test.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import { beforeEach, describe, it } from "@executablemd/test-support/bdd";
21-
import { journalBeforeEach } from "@executablemd/test-support/failure-journal";
21+
import { journalBeforeEach, useJournalStream } from "@executablemd/test-support/failure-journal";
2222
import { expect } from "@executablemd/test-support/expect";
2323
import {
2424
allSettled,
@@ -59,6 +59,7 @@ import {
5959
collect,
6060
Elicitation,
6161
inlineSource,
62+
INLINE_SOURCE_PATH,
6263
registerComponents,
6364
useNormalizedOutput,
6465
} from "@executablemd/core";
@@ -348,6 +349,8 @@ function localRecords(events: readonly DurableEvent[]) {
348349
}
349350

350351
describe("one entry's local file work", () => {
352+
beforeEach(journalBeforeEach(OWNER));
353+
351354
it("1075: live absolute refusal precedes routing, ownership, target I/O and a new file record", function* () {
352355
const fixture = yield* useFixture();
353356
for (const admitted of [false, true]) {
@@ -402,7 +405,7 @@ describe("one entry's local file work", () => {
402405
[],
403406
fixture.checkout,
404407
);
405-
const stream = new InMemoryStream();
408+
const stream = yield* useJournalStream(INLINE_SOURCE_PATH);
406409
const source = `<PrintErrors><Dir path=${JSON.stringify(fixture.checkout)}><File path="seed.md" /></Dir></PrintErrors><PrintErrors><Dir path=${JSON.stringify(join(fixture.root, "missing"))}>made</Dir></PrintErrors>`;
407410
const output = String(
408411
yield* collect(
@@ -1447,6 +1450,8 @@ describe("975 — workspace recording crosses the process boundary", () => {
14471450
});
14481451

14491452
describe("marked workspace mount initialization", () => {
1453+
beforeEach(journalBeforeEach(OWNER));
1454+
14501455
it("seeds the frame from entry cwd while project discovery stays captured", function* () {
14511456
yield* Permissions.around(
14521457
{ files: ([operation], next) => (operation === "absolute" ? true : next(operation)) },
@@ -1504,7 +1509,7 @@ describe("marked workspace mount initialization", () => {
15041509
{
15051510
...inlineSource('<Dir path="/reference"><File path="one.md" /></Dir>'),
15061511
includes: [],
1507-
stream: new InMemoryStream(),
1512+
stream: yield* useJournalStream(INLINE_SOURCE_PATH),
15081513
},
15091514
[installation],
15101515
),

0 commit comments

Comments
 (0)