Skip to content

Commit e85ba35

Browse files
committed
ci: debug
1 parent 6ef105d commit e85ba35

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

src/fixtures/process.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,36 @@ export class ProcessWrap {
2929
this._webcontainerProcess = webcontainerProcess;
3030
this._writer = webcontainerProcess.input.getWriter();
3131

32-
webcontainerProcess.exit.then(() => setDone());
33-
34-
this._webcontainerProcess.output.pipeTo(
35-
new WritableStream({
36-
write: (data) => {
37-
this._output += data;
38-
this._listeners.forEach((fn) => fn());
39-
},
40-
}),
41-
);
32+
const reader = this._webcontainerProcess.output.getReader();
33+
34+
let isExitted = false;
35+
36+
const read = async () => {
37+
while (true) {
38+
const { done, value } = await reader.read();
39+
40+
if (isExitted && !done) {
41+
const error = `Process keeps writing even though it exitted already. Received: "${value}"`;
42+
43+
console.error(error);
44+
throw new Error(error);
45+
}
46+
47+
if (done) {
48+
break;
49+
}
50+
51+
this._output += value;
52+
this._listeners.forEach((fn) => fn());
53+
}
54+
};
55+
56+
void read();
57+
58+
webcontainerProcess.exit.then(() => {
59+
isExitted = true;
60+
setDone();
61+
});
4262
});
4363
}
4464

test/mount.test.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,6 @@ test("user can mount directories from file-system to webcontainer", async ({
66
}) => {
77
await webcontainer.mount("test/fixtures/mount-example");
88

9-
const ls = await webcontainer.runCommand("ls");
10-
expect(ls).toMatchInlineSnapshot(`"file-1.ts image.png nested"`);
11-
12-
const lsNested = await webcontainer.runCommand("ls", ["nested"]);
13-
expect(lsNested).toMatchInlineSnapshot(`"file-2.ts"`);
14-
15-
const catFile = await webcontainer.runCommand("cat", ["file-1.ts"]);
16-
expect(catFile).toMatchInlineSnapshot(`"export default "Hello world";"`);
17-
18-
const catNestedFile = await webcontainer.runCommand("cat", [
19-
"nested/file-2.ts",
20-
]);
21-
expect(catNestedFile).toMatchInlineSnapshot(
22-
`"export default "Hello from nested file";"`,
23-
);
24-
259
const pngFile = await webcontainer.runCommand("xxd", ["image.png"]);
2610
expect(pngFile).toMatchInlineSnapshot(`
2711
"00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
@@ -35,7 +19,7 @@ test("user can mount directories from file-system to webcontainer", async ({
3519
`);
3620
});
3721

38-
test("user can mount inlined FileSystemTree to webcontainer", async ({
22+
test.skip("user can mount inlined FileSystemTree to webcontainer", async ({
3923
webcontainer,
4024
}) => {
4125
await webcontainer.mount({
@@ -68,7 +52,7 @@ test("user can mount inlined FileSystemTree to webcontainer", async ({
6852
);
6953
});
7054

71-
test("user should see error when attemping to mount files outside project root", async ({
55+
test.skip("user should see error when attemping to mount files outside project root", async ({
7256
webcontainer,
7357
}) => {
7458
await expect(() => webcontainer.mount("/home/non-existing")).rejects

vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default defineConfig({
55
plugins: [vitestWebcontainers()],
66

77
test: {
8+
include: ["test/mount.test.ts"],
89
browser: {
910
enabled: true,
1011
provider: "playwright",

0 commit comments

Comments
 (0)