chore(vendor): import pi 0.85.1
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
1 parent
5ebc7018c3
commit
4def357d09
1669 files changed
+397627
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import assert from "node:assert";
|
||||
import { after, describe, it } from "node:test";
|
||||
import { refreshTerminalDimensions } from "../src/terminal.ts";
|
||||
|
||||
describe("refreshTerminalDimensions", () => {
|
||||
const originalKill = process.kill;
|
||||
const originalPlatform = process.platform;
|
||||
|
||||
it("does not throw when kill(2) returns EACCES for self-signal", () => {
|
||||
Object.defineProperty(process, "platform", { value: "linux" });
|
||||
process.kill = ((): typeof process.kill => {
|
||||
return (pid, _signal) => {
|
||||
if (pid === process.pid) {
|
||||
const err = new Error("kill EACCES") as NodeJS.ErrnoException;
|
||||
err.code = "EACCES";
|
||||
throw err;
|
||||
}
|
||||
return originalKill.call(process, pid, _signal);
|
||||
};
|
||||
})();
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
refreshTerminalDimensions();
|
||||
});
|
||||
});
|
||||
|
||||
it("does not call kill on win32", () => {
|
||||
Object.defineProperty(process, "platform", { value: "win32" });
|
||||
let killCalled = false;
|
||||
process.kill = ((): typeof process.kill => {
|
||||
return () => {
|
||||
killCalled = true;
|
||||
return true;
|
||||
};
|
||||
})();
|
||||
|
||||
refreshTerminalDimensions();
|
||||
|
||||
assert.strictEqual(killCalled, false, "kill should not be called on win32");
|
||||
});
|
||||
|
||||
it("preserves other error codes", () => {
|
||||
Object.defineProperty(process, "platform", { value: "linux" });
|
||||
process.kill = ((): typeof process.kill => {
|
||||
return () => {
|
||||
const err = new Error("kill EPERM") as NodeJS.ErrnoException;
|
||||
err.code = "EPERM";
|
||||
throw err;
|
||||
};
|
||||
})();
|
||||
|
||||
// EPERM is also ignored - the refresh is best-effort
|
||||
assert.doesNotThrow(() => {
|
||||
refreshTerminalDimensions();
|
||||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
process.kill = originalKill;
|
||||
Object.defineProperty(process, "platform", { value: originalPlatform });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user