Skip to content

Commit d99e4b5

Browse files
Trottdanielleadams
authored andcommittedJan 4, 2023
test: skip test-fs-largefile if not enough disk space
Fixes: nodejs/build#3071 PR-URL: #45339 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
1 parent 0871b24 commit d99e4b5

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed
 

‎test/pummel/test-fs-largefile.js

+24-16
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,29 @@ const path = require('path');
2929
const tmpdir = require('../common/tmpdir');
3030
tmpdir.refresh();
3131

32-
const filepath = path.join(tmpdir.path, 'large.txt');
33-
const fd = fs.openSync(filepath, 'w+');
34-
const offset = 5 * 1024 * 1024 * 1024; // 5GB
35-
const message = 'Large File';
32+
try {
3633

37-
fs.ftruncateSync(fd, offset);
38-
assert.strictEqual(fs.statSync(filepath).size, offset);
39-
const writeBuf = Buffer.from(message);
40-
fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset);
41-
const readBuf = Buffer.allocUnsafe(writeBuf.length);
42-
fs.readSync(fd, readBuf, 0, readBuf.length, offset);
43-
assert.strictEqual(readBuf.toString(), message);
44-
fs.readSync(fd, readBuf, 0, 1, 0);
45-
assert.strictEqual(readBuf[0], 0);
34+
const filepath = path.join(tmpdir.path, 'large.txt');
35+
const fd = fs.openSync(filepath, 'w+');
36+
const offset = 5 * 1024 * 1024 * 1024; // 5GB
37+
const message = 'Large File';
4638

47-
// Verify that floating point positions do not throw.
48-
fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001);
49-
fs.close(fd, common.mustCall());
39+
fs.ftruncateSync(fd, offset);
40+
assert.strictEqual(fs.statSync(filepath).size, offset);
41+
const writeBuf = Buffer.from(message);
42+
fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset);
43+
const readBuf = Buffer.allocUnsafe(writeBuf.length);
44+
fs.readSync(fd, readBuf, 0, readBuf.length, offset);
45+
assert.strictEqual(readBuf.toString(), message);
46+
fs.readSync(fd, readBuf, 0, 1, 0);
47+
assert.strictEqual(readBuf[0], 0);
48+
49+
// Verify that floating point positions do not throw.
50+
fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001);
51+
fs.close(fd, common.mustCall());
52+
} catch (e) {
53+
if (e.code !== 'ENOSPC') {
54+
throw e;
55+
}
56+
common.skip('insufficient disk space');
57+
}

0 commit comments

Comments
 (0)