mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
* Make some things sync on windows * WIP * WIP * remove uses to uv_default_loop * remove a compiler warning on windows * edfghjk * Windows build fixes * Fixup * bundows * Add quotes * Fix --cwd arg on Windows * comment * move this up * Fix some tests * `mv` tests pass * spawn.test passes again * Allow .sh file extension for Windows * Unmark failing tests * env test pass * windows * Fix some tests * Update ProcessBindingTTYWrap.cpp * Update CMakeLists.txt * Set tmpdir * Make it 5s on windows * Fixup * Fixup * Update ProcessBindingTTYWrap.cpp --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: dave caruso <me@paperdave.net>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { test, expect } from "bun:test";
|
|
import { isatty } from "node:tty";
|
|
|
|
test("process.binding('tty_wrap')", () => {
|
|
// @ts-expect-error
|
|
const tty_wrap = process.binding("tty_wrap");
|
|
|
|
expect(tty_wrap).toBeDefined();
|
|
expect(tty_wrap).toHaveProperty("TTY");
|
|
expect(tty_wrap).toHaveProperty("isTTY");
|
|
|
|
const tty = tty_wrap.TTY;
|
|
|
|
expect(tty).toHaveProperty("prototype");
|
|
|
|
const tty_prototype = tty.prototype;
|
|
|
|
expect(tty_prototype).toHaveProperty("getWindowSize");
|
|
expect(tty_prototype).toHaveProperty("setRawMode");
|
|
|
|
const tty_isTTY = tty_wrap.isTTY;
|
|
|
|
expect(tty_isTTY(0)).toBe(isatty(0));
|
|
expect(tty_isTTY(1)).toBe(isatty(1));
|
|
expect(tty_isTTY(2)).toBe(isatty(2));
|
|
|
|
expect(tty_isTTY(9999999)).toBe(false);
|
|
|
|
expect(() => tty()).toThrow(TypeError);
|
|
|
|
if (isatty(0)) {
|
|
expect(() => new tty(0)).not.toThrow();
|
|
|
|
const array = [-1, -1];
|
|
|
|
expect(() => tty_prototype.getWindowSize.call(array, 0)).toThrow(TypeError);
|
|
const ttywrapper = new tty(0);
|
|
|
|
expect(ttywrapper.getWindowSize(array)).toBeBoolean();
|
|
|
|
if (ttywrapper.getWindowSize(array)) {
|
|
expect(array[0]).toBeNumber();
|
|
expect(array[0]).toBeGreaterThanOrEqual(0);
|
|
expect(array[1]).toBeNumber();
|
|
expect(array[1]).toBeGreaterThanOrEqual(0);
|
|
} else {
|
|
expect(array[0]).toBe(-1);
|
|
expect(array[1]).toBe(-1);
|
|
}
|
|
} else {
|
|
expect(() => new tty(0)).toThrow();
|
|
console.warn("warn: Skipping tty tests because stdin is not a tty");
|
|
}
|
|
});
|