From 55dc467b419b8e5897b1c832b04d63e383253d84 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Thu, 17 Dec 2020 22:01:47 +0800 Subject: test(cli): ensure await all on stdout does not deadlock (#8802) --- cli/tests/integration_tests.rs | 5 +++++ cli/tests/stdout_write_all.out | 3 +++ cli/tests/stdout_write_all.ts | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 cli/tests/stdout_write_all.out create mode 100644 cli/tests/stdout_write_all.ts diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 2f23e2dee..302e808fa 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2105,6 +2105,11 @@ fn deno_test_no_color() { assert!(out.contains("test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out")); } +itest!(stdout_write_all { + args: "run --quiet stdout_write_all.ts", + output: "stdout_write_all.out", +}); + itest!(_001_hello { args: "run --reload 001_hello.js", output: "001_hello.js.out", diff --git a/cli/tests/stdout_write_all.out b/cli/tests/stdout_write_all.out new file mode 100644 index 000000000..49a6d64e9 --- /dev/null +++ b/cli/tests/stdout_write_all.out @@ -0,0 +1,3 @@ +done +done +complete diff --git a/cli/tests/stdout_write_all.ts b/cli/tests/stdout_write_all.ts new file mode 100644 index 000000000..c82a0ca7d --- /dev/null +++ b/cli/tests/stdout_write_all.ts @@ -0,0 +1,8 @@ +const encoder = new TextEncoder(); +const pending = [ + Deno.stdout.write(encoder.encode("done\n")), + Deno.stdout.write(encoder.encode("done\n")), +]; + +await Promise.all(pending); +await Deno.stdout.write(encoder.encode("complete\n")); -- cgit v1.2.3