Skip to content

Commit 3c7da8f

Browse files
committed
fix(init): hang on macOS
1 parent cea7a2a commit 3c7da8f

4 files changed

Lines changed: 120 additions & 45 deletions

File tree

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@std/semver": "jsr:@std/semver@1",
6666
"@std/streams": "jsr:@std/streams@1",
6767

68-
"@astral/astral": "jsr:@astral/astral@^0.4.6",
68+
"@astral/astral": "jsr:@astral/astral@^0.5.2",
6969
"@marvinh-test/fresh-island": "jsr:@marvinh-test/fresh-island@^0.0.1",
7070
"linkedom": "npm:linkedom@^0.16.11",
7171
"@std/async": "jsr:@std/async@1",

deno.lock

Lines changed: 90 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

init/src/init_test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Deno.test("init - can start dev server", async () => {
176176
await patchProject(dir);
177177
await withChildProcessServer(
178178
dir,
179-
path.join(dir, "dev.ts"),
179+
"dev",
180180
async (address) => {
181181
await withBrowser(async (page) => {
182182
await page.goto(address);
@@ -201,7 +201,7 @@ Deno.test("init - can start built project", async () => {
201201

202202
// Build
203203
await new Deno.Command(Deno.execPath(), {
204-
args: ["run", "-A", path.join(dir, "dev.ts"), "build"],
204+
args: ["task", "build"],
205205
stdin: "null",
206206
stdout: "piped",
207207
stderr: "piped",
@@ -210,7 +210,7 @@ Deno.test("init - can start built project", async () => {
210210

211211
await withChildProcessServer(
212212
dir,
213-
path.join(dir, "main.ts"),
213+
"start",
214214
async (address) => {
215215
await withBrowser(async (page) => {
216216
await page.goto(address);
@@ -234,7 +234,7 @@ Deno.test("init - errors on missing build cache in prod", async () => {
234234
await patchProject(dir);
235235

236236
const cp = await new Deno.Command(Deno.execPath(), {
237-
args: ["run", "-A", "main.ts"],
237+
args: ["task", "start"],
238238
stdin: "null",
239239
stdout: "piped",
240240
stderr: "piped",

tests/test_utils.tsx

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -115,50 +115,44 @@ export async function withBrowserApp(
115115
}
116116

117117
export async function withBrowser(fn: (page: Page) => void | Promise<void>) {
118-
const aborter = new AbortController();
118+
const browser = await launch({
119+
args: [
120+
"--window-size=1280,7201",
121+
...((Deno.env.get("CI") && Deno.build.os === "linux")
122+
? ["--no-sandbox"]
123+
: []),
124+
],
125+
headless: !Deno.args.includes("--headful"),
126+
});
127+
const page = await browser.newPage();
128+
// page.setDefaultTimeout(1000000);
119129
try {
120-
const browser = await launch({
121-
args: [
122-
"--window-size=1280,7201",
123-
...((Deno.env.get("CI") && Deno.build.os === "linux")
124-
? ["--no-sandbox"]
125-
: []),
126-
],
127-
headless: !Deno.args.includes("--headful"),
128-
});
129-
130-
const page = await browser.newPage();
131-
// page.setDefaultTimeout(1000000);
130+
await fn(page);
131+
} catch (err) {
132132
try {
133-
await fn(page);
134-
} catch (err) {
135-
try {
136-
const raw = await page.content();
137-
const doc = parseHtml(raw);
138-
const html = prettyDom(doc);
139-
// deno-lint-ignore no-console
140-
console.log(html);
141-
} catch {
142-
// Ignore
143-
}
144-
throw err;
145-
} finally {
146-
await page.close();
147-
await browser.close();
133+
const raw = await page.content();
134+
const doc = parseHtml(raw);
135+
const html = prettyDom(doc);
136+
// deno-lint-ignore no-console
137+
console.log(html);
138+
} catch {
139+
// Ignore
148140
}
141+
throw err;
149142
} finally {
150-
aborter.abort();
143+
await page.close();
144+
await browser.close();
151145
}
152146
}
153147

154148
export async function withChildProcessServer(
155149
dir: string,
156-
entry: string,
150+
task: string,
157151
fn: (address: string) => void | Promise<void>,
158152
) {
159153
const aborter = new AbortController();
160154
const cp = await new Deno.Command(Deno.execPath(), {
161-
args: ["run", "-A", entry],
155+
args: ["task", task],
162156
stdin: "null",
163157
stdout: "piped",
164158
stderr: "inherit",

0 commit comments

Comments
 (0)