diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-06-10 00:29:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 18:29:12 +0200 |
commit | 1e0808d501cf9adea65e7cacd123ea4fea06a13a (patch) | |
tree | 5322e873b5d1f7be7c39f7e8f637c333c51a38e3 /cli/tests/unit/stdio_test.ts | |
parent | 314f666897e63ab9f982726724a7e4af1ca798a8 (diff) |
fix: Deno.readSync on stdin (#6126)
Currently sync operations on stdin are failing because tokio::Stdin
cannot be converted to a std::File.
This commit replaces tokio::stdin with a raw file descriptor
wrapped in a std::fs::File which can be converted to a
tokio::File and back again making the synchronous version
of op_read actually work.
Diffstat (limited to 'cli/tests/unit/stdio_test.ts')
-rw-r--r-- | cli/tests/unit/stdio_test.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cli/tests/unit/stdio_test.ts b/cli/tests/unit/stdio_test.ts new file mode 100644 index 000000000..244ebcd47 --- /dev/null +++ b/cli/tests/unit/stdio_test.ts @@ -0,0 +1,32 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +import { unitTest, assertEquals } from "./test_util.ts"; + +unitTest(async function stdioStdinRead() { + const nread = await Deno.stdin.read(new Uint8Array(0)); + assertEquals(nread, 0); +}); + +unitTest(function stdioStdinReadSync() { + const nread = Deno.stdin.readSync(new Uint8Array(0)); + assertEquals(nread, 0); +}); + +unitTest(async function stdioStdoutWrite() { + const nwritten = await Deno.stdout.write(new Uint8Array(0)); + assertEquals(nwritten, 0); +}); + +unitTest(function stdioStdoutWriteSync() { + const nwritten = Deno.stdout.writeSync(new Uint8Array(0)); + assertEquals(nwritten, 0); +}); + +unitTest(async function stdioStderrWrite() { + const nwritten = await Deno.stderr.write(new Uint8Array(0)); + assertEquals(nwritten, 0); +}); + +unitTest(function stdioStderrWriteSync() { + const nwritten = Deno.stderr.writeSync(new Uint8Array(0)); + assertEquals(nwritten, 0); +}); |