-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a work in progress, I just want to test the CI. This change-set also updates the formatting of several files as the rules have changed with Deno 2.
- Loading branch information
Showing
3 changed files
with
33 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,6 @@ Deno.test({ | |
assert(div, "div exists"); | ||
}); | ||
|
||
app.stop(); | ||
await app.stop(); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { fromFileUrl } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { readableStreamFromReader } from "https://deno.land/[email protected]/streams/conversion.ts"; | ||
import { fromFileUrl } from "jsr:@std/[email protected]"; | ||
import { assert } from "jsr:@std/[email protected]"; | ||
|
||
const dir = new URL("./", import.meta.url); | ||
const defaultURL = new URL("http://localhost:8085/"); | ||
|
@@ -12,18 +11,19 @@ export const defaultTestPermissions: Deno.PermissionOptions = { | |
env: true, | ||
}; | ||
|
||
declare type ExitCallback = () => void; | ||
declare type ExitCallback = () => Promise<void>; | ||
|
||
export async function runBuild(fixturePath: string) { | ||
const proc = Deno.run({ | ||
cmd: ["node_modules/.bin/astro", "build", "--silent"], | ||
const command = new Deno.Command("node_modules/.bin/astro", { | ||
args: ["build", "--silent"], | ||
cwd: fromFileUrl(new URL(fixturePath, dir)), | ||
}); | ||
const process = command.spawn(); | ||
try { | ||
const status = await proc.status(); | ||
const status = await process.status; | ||
assert(status.success); | ||
} finally { | ||
proc.close(); | ||
safeKill(process); | ||
} | ||
} | ||
|
||
|
@@ -42,22 +42,36 @@ export async function startModFromSubprocess( | |
baseUrl: URL, | ||
): Promise<ExitCallback> { | ||
const entryUrl = new URL("./dist/server/entry.mjs", baseUrl); | ||
const proc = Deno.run({ | ||
cmd: ["deno", "run", "--allow-env", "--allow-net", fromFileUrl(entryUrl)], | ||
const command = new Deno.Command("deno", { | ||
args: ["run", "--allow-env", "--allow-net", fromFileUrl(entryUrl)], | ||
cwd: fromFileUrl(baseUrl), | ||
stderr: "piped", | ||
}); | ||
|
||
const stderr = readableStreamFromReader(proc.stderr); | ||
const process = command.spawn(); | ||
const reader = process.stderr.getReader(); | ||
const dec = new TextDecoder(); | ||
for await (const bytes of stderr) { | ||
const msg = dec.decode(bytes); | ||
|
||
while (true) { | ||
const { value } = await reader.read(); | ||
const msg = dec.decode(value); | ||
if (msg.includes(`Server running`)) { | ||
break; | ||
} | ||
} | ||
await reader.cancel(); | ||
|
||
return async () => { | ||
safeKill(process); | ||
await process.status; | ||
}; | ||
} | ||
|
||
return () => proc.close(); | ||
function safeKill(process: Deno.ChildProcess) { | ||
try { | ||
process.kill("SIGKILL"); | ||
} catch { | ||
// ignore | ||
} | ||
} | ||
|
||
export async function runBuildAndStartApp(fixturePath: string) { | ||
|