Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix disabled test-fs-largefile #13147

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions test/disabled/test-fs-largefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@

'use strict';
const common = require('../common');

const assert = require('assert');
const path = require('path'),
fs = require('fs'),
filepath = path.join(common.tmpDir, 'large.txt'),
fd = fs.openSync(filepath, 'w+'),
offset = 5 * 1024 * 1024 * 1024, // 5GB
message = 'Large File';
const fs = require('fs');
const path = require('path');

common.refreshTmpDir();

const filepath = path.join(common.tmpDir, 'large.txt');
const fd = fs.openSync(filepath, 'w+');
const offset = 5 * 1024 * 1024 * 1024; // 5GB
const message = 'Large File';

fs.truncateSync(fd, offset);
assert.strictEqual(fs.statSync(filepath).size, offset);
Expand All @@ -39,17 +43,13 @@ assert.strictEqual(readBuf.toString(), message);
fs.readSync(fd, readBuf, 0, 1, 0);
assert.strictEqual(readBuf[0], 0);

var exceptionRaised = false;
try {
fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001);
} catch (err) {
console.log(err);
exceptionRaised = true;
assert.strictEqual(err.message, 'Not an integer');
}
assert.ok(exceptionRaised);
assert.doesNotThrow(
() => { fs.writeSync(fd, writeBuf, 0, writeBuf.length, 42.000001); }
);
fs.close(fd);

// Normally, we don't clean up tmp files at the end of a test, but we'll make an
// exception for a 5 GB file.
process.on('exit', function() {
fs.unlinkSync(filepath);
});