diff options
author | 2022-10-07 15:36:24 +0200 | |
---|---|---|
committer | 2022-10-07 09:36:24 -0400 | |
commit | 5bbe385b21597f240eafc989c8909768ca96a65a (patch) | |
tree | 00866d7978e0513ff2389cf85c54b82c8f6edb14 /packages/integrations/deno/test/helpers.js | |
parent | f38e5560851759323854b70c7a5277ba9bf05710 (diff) | |
download | astro-5bbe385b21597f240eafc989c8909768ca96a65a.tar.gz astro-5bbe385b21597f240eafc989c8909768ca96a65a.tar.zst astro-5bbe385b21597f240eafc989c8909768ca96a65a.zip |
Improve test infrastructure for integrations/deno (#5005)
* Improve test infrastructure for integrations/deno
* Add changeset
* Use declared type
* Remove changeset
* Upgrade deno version in -workflow
Diffstat (limited to 'packages/integrations/deno/test/helpers.js')
-rw-r--r-- | packages/integrations/deno/test/helpers.js | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/packages/integrations/deno/test/helpers.js b/packages/integrations/deno/test/helpers.js deleted file mode 100644 index d33267848..000000000 --- a/packages/integrations/deno/test/helpers.js +++ /dev/null @@ -1,60 +0,0 @@ -import { readableStreamFromReader, fromFileUrl } from './deps.js'; -const dir = new URL('./', import.meta.url); - -export async function runBuild(fixturePath) { - let proc = Deno.run({ - cmd: ['node', '../../../../../astro/astro.js', 'build', '--silent'], - cwd: fromFileUrl(new URL(fixturePath, dir)), - }); - await proc.status(); - return async () => await proc.close(); -} - -export async function startModFromImport(baseUrl) { - const entryUrl = new URL('./dist/server/entry.mjs', baseUrl); - const mod = await import(entryUrl); - - if (!mod.running()) { - mod.start(); - } - - return () => mod.stop(); -} - -export async function startModFromSubprocess(baseUrl) { - const entryUrl = new URL('./dist/server/entry.mjs', baseUrl); - let proc = Deno.run({ - cmd: ['deno', 'run', '--allow-env', '--allow-net', fromFileUrl(entryUrl)], - cwd: fromFileUrl(baseUrl), - stderr: 'piped', - }); - const stderr = readableStreamFromReader(proc.stderr); - const dec = new TextDecoder(); - for await (let bytes of stderr) { - let msg = dec.decode(bytes); - if (msg.includes(`Server running`)) { - break; - } - } - return () => proc.close(); -} - -export async function runBuildAndStartApp(fixturePath, cb) { - const url = new URL(fixturePath, dir); - const close = await runBuild(fixturePath); - const stop = await startModFromImport(url); - - await cb(); - await stop(); - await close(); -} - -export async function runBuildAndStartAppFromSubprocess(fixturePath, cb) { - const url = new URL(fixturePath, dir); - const close = await runBuild(fixturePath); - const stop = await startModFromSubprocess(url); - - await cb(); - await stop(); - await close(); -} |