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: replace flaky pummel regression tests #34530

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
39 changes: 39 additions & 0 deletions test/parallel/test-fs-write-reuse-callback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Flags: --expose-gc
'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const path = require('path');

// Regression test for https://github.com/nodejs/node-v0.x-archive/issues/814:
// Make sure that Buffers passed to fs.write() are not garbage-collected
// even when the callback is being reused.

const fs = require('fs');

tmpdir.refresh();
const filename = path.join(tmpdir.path, 'test.txt');
const fd = fs.openSync(filename, 'w');

const size = 16 * 1024;
const writes = 1000;
let done = 0;

const ondone = common.mustCall((err) => {
assert.ifError(err);
if (++done < writes) {
if (done % 25 === 0) global.gc();
setImmediate(write);
} else {
assert.strictEqual(
fs.readFileSync(filename, 'utf8'),
'x'.repeat(writes * size));
addaleax marked this conversation as resolved.
Show resolved Hide resolved
fs.closeSync(fd);
}
}, writes);

write();
function write() {
const buf = Buffer.alloc(size, 'x');
fs.write(fd, buf, 0, buf.size, -1, ondone);
gengjiawen marked this conversation as resolved.
Show resolved Hide resolved
}
90 changes: 0 additions & 90 deletions test/pummel/test-regress-GH-814.js

This file was deleted.

105 changes: 0 additions & 105 deletions test/pummel/test-regress-GH-814_2.js

This file was deleted.