From 928317904b1d84ca5ff667c17626aa72fd74f475 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 26 Sep 2024 11:07:02 -0600 Subject: [PATCH] Remove conditions for untested versions --- test/lib/fs.link-symlink.spec.js | 3 +- test/lib/fs.open-close.spec.js | 25 -------- test/lib/fs.rmdir.spec.js | 103 +++++++++++++++---------------- test/lib/readfilecontext.spec.js | 3 +- 4 files changed, 51 insertions(+), 83 deletions(-) diff --git a/test/lib/fs.link-symlink.spec.js b/test/lib/fs.link-symlink.spec.js index 53d6c4c..0a1cce8 100644 --- a/test/lib/fs.link-symlink.spec.js +++ b/test/lib/fs.link-symlink.spec.js @@ -5,7 +5,6 @@ const fs = require('fs'); const mock = require('../../lib/index.js'); const assert = helper.assert; -const inVersion = helper.inVersion; describe('fs.link(srcpath, dstpath, callback)', function () { beforeEach(function () { @@ -198,7 +197,7 @@ describe('fs.symlink(srcpath, dstpath, [type], callback)', function () { // https://github.com/nodejs/node/issues/34514 if (process.platform === 'win32') { - inVersion('>=15.0.0').it('supports Buffer input', function (done) { + it('supports Buffer input', function (done) { fs.symlink( Buffer.from('../file.txt'), Buffer.from('dir/link.txt'), diff --git a/test/lib/fs.open-close.spec.js b/test/lib/fs.open-close.spec.js index 8505cf2..6ee982e 100644 --- a/test/lib/fs.open-close.spec.js +++ b/test/lib/fs.open-close.spec.js @@ -5,7 +5,6 @@ const fs = require('fs'); const mock = require('../../lib/index.js'); const assert = helper.assert; -const inVersion = helper.inVersion; describe('fs.open(path, flags, [mode], callback)', function () { beforeEach(function () { @@ -220,30 +219,6 @@ describe('fs.close(fd, callback)', function () { }); }); }); - - inVersion('<14.0.0').it( - 'promise fails for closed file descriptors', - function (done) { - fs.promises - .open('dir/file.txt', 'w') - .then(function (fd) { - return fd.close().then(function () { - // in Nodejs v14+, closing on closed file descriptor is silently ignored. - return fd.close(); - }); - }) - .then( - function () { - done(new Error('should not succeed.')); - }, - function (err) { - assert.instanceOf(err, Error); - assert.equal(err.code, 'EBADF'); - done(); - } - ); - } - ); }); describe('fs.closeSync(fd)', function () { diff --git a/test/lib/fs.rmdir.spec.js b/test/lib/fs.rmdir.spec.js index 2eaf8c7..c882f23 100644 --- a/test/lib/fs.rmdir.spec.js +++ b/test/lib/fs.rmdir.spec.js @@ -5,7 +5,6 @@ const fs = require('fs'); const mock = require('../../lib/index.js'); const assert = helper.assert; -const inVersion = helper.inVersion; const testParentPerms = process.getuid && process.getgid; @@ -116,58 +115,56 @@ describe('fs.rmdir(path, callback)', function () { ); }); - inVersion('>=12.10').run(function () { - it('recursively remove empty directory', function (done) { - assert.equal(fs.statSync('path2/to').nlink, 4); + it('recursively remove empty directory', function (done) { + assert.equal(fs.statSync('path2/to').nlink, 4); - fs.rmdir('path2/to/empty', {recursive: true}, function (err) { - if (err) { - return done(err); - } + fs.rmdir('path2/to/empty', {recursive: true}, function (err) { + if (err) { + return done(err); + } + assert.isFalse(fs.existsSync('path2/to/empty')); + assert.equal(fs.statSync('path2/to').nlink, 3); + done(); + }); + }); + + it('promise recursively remove empty directory', function (done) { + assert.equal(fs.statSync('path2/to').nlink, 4); + + fs.promises + .rmdir('path2/to/empty', {recursive: true}) + .then(function () { assert.isFalse(fs.existsSync('path2/to/empty')); assert.equal(fs.statSync('path2/to').nlink, 3); done(); - }); - }); + }) + .catch(done); + }); - it('promise recursively remove empty directory', function (done) { - assert.equal(fs.statSync('path2/to').nlink, 4); + it('recursively remove non-empty directory', function (done) { + assert.equal(fs.statSync('path2/to').nlink, 4); - fs.promises - .rmdir('path2/to/empty', {recursive: true}) - .then(function () { - assert.isFalse(fs.existsSync('path2/to/empty')); - assert.equal(fs.statSync('path2/to').nlink, 3); - done(); - }) - .catch(done); + fs.rmdir('path2/to/non-empty', {recursive: true}, function (err) { + if (err) { + return done(err); + } + assert.isFalse(fs.existsSync('path2/to/non-empty')); + assert.equal(fs.statSync('path2/to').nlink, 3); + done(); }); + }); - it('recursively remove non-empty directory', function (done) { - assert.equal(fs.statSync('path2/to').nlink, 4); + it('promise recursively remove non-empty directory', function (done) { + assert.equal(fs.statSync('path2/to').nlink, 4); - fs.rmdir('path2/to/non-empty', {recursive: true}, function (err) { - if (err) { - return done(err); - } + fs.promises + .rmdir('path2/to/non-empty', {recursive: true}) + .then(function () { assert.isFalse(fs.existsSync('path2/to/non-empty')); assert.equal(fs.statSync('path2/to').nlink, 3); done(); - }); - }); - - it('promise recursively remove non-empty directory', function (done) { - assert.equal(fs.statSync('path2/to').nlink, 4); - - fs.promises - .rmdir('path2/to/non-empty', {recursive: true}) - .then(function () { - assert.isFalse(fs.existsSync('path2/to/non-empty')); - assert.equal(fs.statSync('path2/to').nlink, 3); - done(); - }) - .catch(done); - }); + }) + .catch(done); }); if (testParentPerms) { @@ -221,20 +218,18 @@ describe('fs.rmdirSync(path)', function () { }); }); - inVersion('>=12.10').run(function () { - it('recursively remove empty directory', function () { - assert.equal(fs.statSync('path2/to').nlink, 4); - fs.rmdirSync('path2/to/empty', {recursive: true}); - assert.isFalse(fs.existsSync('path2/to/empty')); - assert.equal(fs.statSync('path2/to').nlink, 3); - }); + it('recursively remove empty directory', function () { + assert.equal(fs.statSync('path2/to').nlink, 4); + fs.rmdirSync('path2/to/empty', {recursive: true}); + assert.isFalse(fs.existsSync('path2/to/empty')); + assert.equal(fs.statSync('path2/to').nlink, 3); + }); - it('recursively remove non-empty directory', function () { - assert.equal(fs.statSync('path2/to').nlink, 4); - fs.rmdirSync('path2/to/non-empty', {recursive: true}); - assert.isFalse(fs.existsSync('path2/to/non-empty')); - assert.equal(fs.statSync('path2/to').nlink, 3); - }); + it('recursively remove non-empty directory', function () { + assert.equal(fs.statSync('path2/to').nlink, 4); + fs.rmdirSync('path2/to/non-empty', {recursive: true}); + assert.isFalse(fs.existsSync('path2/to/non-empty')); + assert.equal(fs.statSync('path2/to').nlink, 3); }); if (testParentPerms) { diff --git a/test/lib/readfilecontext.spec.js b/test/lib/readfilecontext.spec.js index 11c7718..34efc22 100644 --- a/test/lib/readfilecontext.spec.js +++ b/test/lib/readfilecontext.spec.js @@ -10,7 +10,6 @@ const { } = require('../../lib/readfilecontext.js'); const assert = helper.assert; -const inVersion = helper.inVersion; describe('getReadFileContextPrototype', function () { it('provides access to the internal ReadFileContext', function () { @@ -122,7 +121,7 @@ describe('fs.readFile() with ReadFileContext', function () { }); afterEach(mock.restore); - inVersion('>=15.0.0').it('allows file reads to be aborted', function (done) { + it('allows file reads to be aborted', function (done) { const controller = new AbortController(); const {signal} = controller;