mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Stat largefile test (#3870)
* Add test for stat on a large file * Update fs.test.ts --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { dirname } from "node:path";
|
||||
import { gc } from "harness";
|
||||
import fs, {
|
||||
closeSync,
|
||||
@@ -31,6 +32,7 @@ import fs, {
|
||||
symlinkSync,
|
||||
writevSync,
|
||||
readvSync,
|
||||
fstatSync,
|
||||
} from "node:fs";
|
||||
|
||||
import _promises from "node:fs/promises";
|
||||
@@ -1432,6 +1434,26 @@ describe("fs/promises", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("stat on a large file", () => {
|
||||
var dest: string = "",
|
||||
fd;
|
||||
try {
|
||||
dest = `${tmpdir()}/fs.test.js/${Math.trunc(Math.random() * 10000000000).toString(32)}.stat.txt`;
|
||||
mkdirSync(dirname(dest), { recursive: true });
|
||||
const bigBuffer = new Uint8Array(1024 * 1024 * 1024);
|
||||
fd = openSync(dest, "w");
|
||||
let offset = 0;
|
||||
while (offset < 5 * 1024 * 1024 * 1024) {
|
||||
offset += writeSync(fd, bigBuffer, 0, bigBuffer.length, offset);
|
||||
}
|
||||
|
||||
expect(fstatSync(fd).size).toEqual(offset);
|
||||
} finally {
|
||||
if (fd) closeSync(fd);
|
||||
unlinkSync(dest);
|
||||
}
|
||||
});
|
||||
|
||||
it("fs.constants", () => {
|
||||
expect(constants).toBeDefined();
|
||||
expect(constants.F_OK).toBeDefined();
|
||||
|
||||
Reference in New Issue
Block a user