mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 08:33:43 -05:00
parent
c474d38354
commit
676be6632c
1 changed files with 13 additions and 6 deletions
|
@ -28,9 +28,16 @@ async function startFileServer(): Promise<void> {
|
||||||
assert(s !== null && s.includes("server listening"));
|
assert(s !== null && s.includes("server listening"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function killFileServer(): void {
|
async function killFileServer(): Promise<void> {
|
||||||
fileServer.close();
|
fileServer.close();
|
||||||
fileServer.stdout?.close();
|
// Process.close() kills the file server process. However this termination
|
||||||
|
// happens asynchronously, and since we've just closed the process resource,
|
||||||
|
// we can't use `await fileServer.status()` to wait for the process to have
|
||||||
|
// exited. As a workaround, wait for its stdout to close instead.
|
||||||
|
// TODO(piscisaureus): when `Process.kill()` is stable and works on Windows,
|
||||||
|
// switch to calling `kill()` followed by `await fileServer.status()`.
|
||||||
|
await Deno.readAll(fileServer.stdout!);
|
||||||
|
fileServer.stdout!.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
test("file_server serveFile", async (): Promise<void> => {
|
test("file_server serveFile", async (): Promise<void> => {
|
||||||
|
@ -46,7 +53,7 @@ test("file_server serveFile", async (): Promise<void> => {
|
||||||
);
|
);
|
||||||
assertEquals(downloadedFile, localFile);
|
assertEquals(downloadedFile, localFile);
|
||||||
} finally {
|
} finally {
|
||||||
killFileServer();
|
await killFileServer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -68,7 +75,7 @@ test("serveDirectory", async function (): Promise<void> {
|
||||||
assert(/<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/.test(page));
|
assert(/<td class="mode">(\s)*\(unknown mode\)(\s)*<\/td>/.test(page));
|
||||||
assert(page.includes(`<a href="/README.md">README.md</a>`));
|
assert(page.includes(`<a href="/README.md">README.md</a>`));
|
||||||
} finally {
|
} finally {
|
||||||
killFileServer();
|
await killFileServer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -81,7 +88,7 @@ test("serveFallback", async function (): Promise<void> {
|
||||||
assertEquals(res.status, 404);
|
assertEquals(res.status, 404);
|
||||||
const _ = await res.text();
|
const _ = await res.text();
|
||||||
} finally {
|
} finally {
|
||||||
killFileServer();
|
await killFileServer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,7 +106,7 @@ test("serveWithUnorthodoxFilename", async function (): Promise<void> {
|
||||||
assertEquals(res.status, 200);
|
assertEquals(res.status, 200);
|
||||||
_ = await res.text();
|
_ = await res.text();
|
||||||
} finally {
|
} finally {
|
||||||
killFileServer();
|
await killFileServer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue