2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-06-04 19:09:29 -04:00
|
|
|
|
|
|
|
// deno-lint-ignore-file no-deprecated-deno-api
|
|
|
|
|
2022-10-25 18:23:21 -04:00
|
|
|
import { assert } from "./test_util.ts";
|
2020-02-26 01:01:24 -05:00
|
|
|
|
2022-09-28 09:03:56 -04:00
|
|
|
// Note tests for Deno.stdin.setRaw is in integration tests.
|
2020-02-26 01:01:24 -05:00
|
|
|
|
2022-10-25 18:23:21 -04:00
|
|
|
Deno.test(function consoleSize() {
|
2024-01-23 18:01:56 -05:00
|
|
|
if (!Deno.stdout.isTerminal()) {
|
2022-10-25 18:23:21 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
const result = Deno.consoleSize();
|
|
|
|
assert(typeof result.columns !== "undefined");
|
|
|
|
assert(typeof result.rows !== "undefined");
|
2020-07-10 10:07:12 -04:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test({ permissions: { read: true } }, function isatty() {
|
2020-02-26 01:01:24 -05:00
|
|
|
// CI not under TTY, so cannot test stdin/stdout/stderr.
|
chore: move cli/tests/ -> tests/ (#22369)
This looks like a massive PR, but it's only a move from cli/tests ->
tests, and updates of relative paths for files.
This is the first step towards aggregate all of the integration test
files under tests/, which will lead to a set of integration tests that
can run without the CLI binary being built.
While we could leave these tests under `cli`, it would require us to
keep a more complex directory structure for the various test runners. In
addition, we have a lot of complexity to ignore various test files in
the `cli` project itself (cargo publish exclusion rules, autotests =
false, etc).
And finally, the `tests/` folder will eventually house the `test_ffi`,
`test_napi` and other testing code, reducing the size of the root repo
directory.
For easier review, the extremely large and noisy "move" is in the first
commit (with no changes -- just a move), while the remainder of the
changes to actual files is in the second commit.
2024-02-10 15:22:13 -05:00
|
|
|
const f = Deno.openSync("tests/testdata/assets/hello.txt");
|
2020-02-26 01:01:24 -05:00
|
|
|
assert(!Deno.isatty(f.rid));
|
2020-02-29 12:45:47 -05:00
|
|
|
f.close();
|
2020-02-26 01:01:24 -05:00
|
|
|
});
|
|
|
|
|
2021-11-23 11:45:18 -05:00
|
|
|
Deno.test(function isattyError() {
|
2020-02-26 01:01:24 -05:00
|
|
|
let caught = false;
|
|
|
|
try {
|
|
|
|
// Absurdly large rid.
|
|
|
|
Deno.isatty(0x7fffffff);
|
|
|
|
} catch (e) {
|
|
|
|
caught = true;
|
|
|
|
assert(e instanceof Deno.errors.BadResource);
|
|
|
|
}
|
|
|
|
assert(caught);
|
|
|
|
});
|