summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/run_tests.rs6
-rw-r--r--cli/tests/integration/watcher_tests.rs65
-rw-r--r--cli/tests/testdata/run/flash_shutdown/main.ts23
-rw-r--r--cli/tests/unit/flash_test.ts1
4 files changed, 29 insertions, 66 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index fd60e85b7..267106913 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -3642,3 +3642,9 @@ itest!(no_lock_flag {
http_server: true,
exit_code: 0,
});
+
+// Check https://github.com/denoland/deno_std/issues/2882
+itest!(flash_shutdown {
+ args: "run --unstable --allow-net run/flash_shutdown/main.ts",
+ exit_code: 0,
+});
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs
index 6e3319b11..58f7e11fa 100644
--- a/cli/tests/integration/watcher_tests.rs
+++ b/cli/tests/integration/watcher_tests.rs
@@ -1167,68 +1167,3 @@ fn run_watch_dynamic_imports() {
check_alive_then_kill(child);
}
-
-// https://github.com/denoland/deno/issues/16267
-#[test]
-fn run_watch_flash() {
- let filename = "watch_flash.js";
- let t = TempDir::new();
- let file_to_watch = t.path().join(filename);
- write(
- &file_to_watch,
- r#"
- console.log("Starting flash server...");
- Deno.serve({
- onListen() {
- console.error("First server is listening");
- },
- handler: () => {},
- port: 4601,
- });
- "#,
- )
- .unwrap();
-
- let mut child = util::deno_cmd()
- .current_dir(t.path())
- .arg("run")
- .arg("--watch")
- .arg("--unstable")
- .arg("--allow-net")
- .arg("-L")
- .arg("debug")
- .arg(&file_to_watch)
- .env("NO_COLOR", "1")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped())
- .spawn()
- .unwrap();
- let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child);
-
- wait_contains("Starting flash server...", &mut stdout_lines);
- wait_for(
- |m| m.contains("Watching paths") && m.contains(filename),
- &mut stderr_lines,
- );
-
- write(
- &file_to_watch,
- r#"
- console.log("Restarting flash server...");
- Deno.serve({
- onListen() {
- console.error("Second server is listening");
- },
- handler: () => {},
- port: 4601,
- });
- "#,
- )
- .unwrap();
-
- wait_contains("File change detected! Restarting!", &mut stderr_lines);
- wait_contains("Restarting flash server...", &mut stdout_lines);
- wait_contains("Second server is listening", &mut stderr_lines);
-
- check_alive_then_kill(child);
-}
diff --git a/cli/tests/testdata/run/flash_shutdown/main.ts b/cli/tests/testdata/run/flash_shutdown/main.ts
new file mode 100644
index 000000000..7f6985e34
--- /dev/null
+++ b/cli/tests/testdata/run/flash_shutdown/main.ts
@@ -0,0 +1,23 @@
+// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
+
+// Deno.serve caused segfault with this example after #16383
+// refs:
+// - https://github.com/denoland/deno/pull/16383
+// - https://github.com/denoland/deno_std/issues/2882
+// - revert https://github.com/denoland/deno/pull/16610
+
+const ctl = new AbortController();
+Deno.serve(() =>
+ new Promise((resolve) => {
+ resolve(new Response(new TextEncoder().encode("ok")));
+ ctl.abort();
+ }), {
+ signal: ctl.signal,
+ async onListen({ port }) {
+ const a = await fetch(`http://localhost:${port}`, {
+ method: "POST",
+ body: "",
+ });
+ await a.text();
+ },
+});
diff --git a/cli/tests/unit/flash_test.ts b/cli/tests/unit/flash_test.ts
index c64a7fe5a..024069455 100644
--- a/cli/tests/unit/flash_test.ts
+++ b/cli/tests/unit/flash_test.ts
@@ -70,7 +70,6 @@ Deno.test(async function httpServerRejectsOnAddrInUse() {
onError: createOnErrorCb(ac),
});
- await listeningPromise;
assertRejects(
() =>
Deno.serve({