diff options
author | 2023-09-04 08:30:30 +0800 | |
---|---|---|
committer | 2023-09-03 17:30:30 -0700 | |
commit | f1b109d5ddb554d1dd71b186045930a4c7a18f79 (patch) | |
tree | 6d654214175a6d1900e09dc4d9047f24a6b16a9d /test/js/node/fs/fs.test.ts | |
parent | 5c43744bce358f132a63d5002baffd7647d47a76 (diff) | |
download | bun-f1b109d5ddb554d1dd71b186045930a4c7a18f79.tar.gz bun-f1b109d5ddb554d1dd71b186045930a4c7a18f79.tar.zst bun-f1b109d5ddb554d1dd71b186045930a4c7a18f79.zip |
fix(syscall): fix handling syscall errno (#4461)
* fix(syscall): fix handling syscall errno
Close: #4198
* remove unused code
* add more tests
* remove unused code
Diffstat (limited to 'test/js/node/fs/fs.test.ts')
-rw-r--r-- | test/js/node/fs/fs.test.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index cdd14bb01..2f898a2ea 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -18,6 +18,7 @@ import fs, { rmSync, rmdir, rmdirSync, + renameSync, createReadStream, createWriteStream, promises, @@ -2020,3 +2021,23 @@ it("BigIntStats", () => { expect(withBigInt.ctime.getTime()).toEqual(withoutBigInt.ctime.getTime()); expect(withBigInt.birthtime.getTime()).toEqual(withoutBigInt.birthtime.getTime()); }); + +it("test syscall errno, issue#4198", () => { + const path = `${tmpdir()}/non-existent-${Date.now()}.txt`; + expect(() => openSync(path, "r")).toThrow("No such file or directory"); + expect(() => readSync(2147483640, Buffer.alloc(0))).toThrow("Bad file number"); + expect(() => readlinkSync(path)).toThrow("No such file or directory"); + expect(() => realpathSync(path)).toThrow("No such file or directory"); + expect(() => readFileSync(path)).toThrow("No such file or directory"); + expect(() => renameSync(path, `${path}.2`)).toThrow("No such file or directory"); + expect(() => statSync(path)).toThrow("No such file or directory"); + expect(() => unlinkSync(path)).toThrow("No such file or directory"); + expect(() => rmSync(path)).toThrow("No such file or directory"); + expect(() => rmdirSync(path)).toThrow("No such file or directory"); + expect(() => closeSync(2147483640)).toThrow("Bad file number"); + + mkdirSync(path); + expect(() => mkdirSync(path)).toThrow("File or folder exists"); + expect(() => unlinkSync(path)).toThrow("Is a directory"); + rmdirSync(path); +}); |