diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-05-18 20:39:20 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-05-18 21:25:37 -0400 |
commit | 8886e1b55f3495b3b798825274a910e5f231a74b (patch) | |
tree | 1b1be7a8819cd24e9a1da9cc1914ff1db34a0b9b /test.js | |
parent | 39da69f051c48f15dd4af5e8a4cbe17ff4f349e5 (diff) |
Initial support for remote imports
Diffstat (limited to 'test.js')
-rwxr-xr-x | test.js | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -4,7 +4,22 @@ const fs = require("fs"); const path = require("path"); -const { execFileSync } = require("child_process"); +const { spawn, execFileSync } = require("child_process"); + +// Some tests require an HTTP server. We start one here. +// Because we process tests synchronously in this program we must run +// the server as a subprocess. +// Note that "localhost:4545" is hardcoded into the tests at the moment, +// so if the server runs on a different port, it will fail. +const httpServerArgs = ["node_modules/.bin/http-server", __dirname, "-p 4545"]; +const server = spawn(process.execPath, httpServerArgs, { + cwd: __dirname, + stdio: "inherit" +}); +// TODO: For some reason the http-server doesn't exit properly +// when this program dies. So we force it with the exit handler here. +server.unref(); +process.on("exit", () => server.kill("SIGINT")); const testdataDir = path.join(__dirname, "testdata"); const denoFn = path.join(__dirname, "deno"); @@ -33,3 +48,5 @@ ${outFileBuffer.toString()} `); } } + +console.log("Tests done"); |