[njs] Tests: improved fs test262 tests robustness with different environment.
Dmitry Volyntsev
xeioex at nginx.com
Sat Aug 20 04:40:26 UTC 2022
details: https://hg.nginx.org/njs/rev/ae971e65f638
branches:
changeset: 1928:ae971e65f638
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Fri Aug 19 21:38:55 2022 -0700
description:
Tests: improved fs test262 tests robustness with different environment.
diffstat:
test/fs/methods.t.js | 12 +++---
test/fs/promises_01.t.js | 12 +++++-
test/fs/promises_02.t.js | 75 ++++++++++++++++++++++++----------------
test/fs/promises_03.t.js | 37 ++++++++++---------
test/fs/promises_04.t.js | 60 +++++++++++++++-----------------
test/fs/promises_05.t.js | 37 ++++++++++---------
test/fs/promises_06.t.js | 69 ++++++++++++++++++-------------------
test/fs/promises_07.t.js | 35 +++++++++---------
test/fs/promises_08.t.js | 23 ++++++------
test/fs/promises_09.t.js | 19 +++++----
test/harness/compatFs.js | 32 ++++++++++++++++-
test/harness/compatPrint.js | 2 +-
test/harness/compatWebcrypto.js | 2 +-
13 files changed, 232 insertions(+), 183 deletions(-)
diffs (822 lines):
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/methods.t.js
--- a/test/fs/methods.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/methods.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -535,7 +535,7 @@ let stat_tests = () => [
let stat_tsuite = {
name: "fs stat",
- skip: () => (!has_fs() || !has_buffer()),
+ skip: () => (!has_fs() || !has_fs_symbolic_link() || !has_buffer()),
T: stat_test,
prepare_args: p,
opts: { type: "callback", method: "stat" },
@@ -544,7 +544,7 @@ let stat_tsuite = {
let statSync_tsuite = {
name: "fs statSync",
- skip: () => (!has_fs() || !has_buffer()),
+ skip: () => (!has_fs() || !has_fs_symbolic_link() || !has_buffer()),
T: stat_test,
prepare_args: p,
opts: { type: "sync", method: "stat" },
@@ -553,7 +553,7 @@ let statSync_tsuite = {
let statP_tsuite = {
name: "fsp stat",
- skip: () => (!has_fs() || !has_buffer()),
+ skip: () => (!has_fs() || !has_fs_symbolic_link() || !has_buffer()),
T: stat_test,
prepare_args: p,
opts: { type: "promise", method: "stat" },
@@ -562,7 +562,7 @@ let statP_tsuite = {
let lstat_tsuite = {
name: "fs lstat",
- skip: () => (!has_fs() || !has_buffer()),
+ skip: () => (!has_fs() || !has_fs_symbolic_link() || !has_buffer()),
T: stat_test,
prepare_args: p,
opts: { type: "callback", method: "lstat" },
@@ -571,7 +571,7 @@ let lstat_tsuite = {
let lstatSync_tsuite = {
name: "fs lstatSync",
- skip: () => (!has_fs() || !has_buffer()),
+ skip: () => (!has_fs() || !has_fs_symbolic_link() || !has_buffer()),
T: stat_test,
prepare_args: p,
opts: { type: "sync", method: "lstat" },
@@ -580,7 +580,7 @@ let lstatSync_tsuite = {
let lstatP_tsuite = {
name: "fsp lstat",
- skip: () => (!has_fs() || !has_buffer()),
+ skip: () => (!has_fs() || !has_fs_symbolic_link() || !has_buffer()),
T: stat_test,
prepare_args: p,
opts: { type: "promise", method: "lstat" },
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_01.t.js
--- a/test/fs/promises_01.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_01.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -7,7 +7,7 @@ var fname = `${test_dir}/fs_promises_01`
let stages = [];
-Promise.resolve()
+let test = () => Promise.resolve()
.then(() => {
return fsp.writeFile(fname, fname);
})
@@ -39,4 +39,12 @@ Promise.resolve()
.then(() => {
assert.compareArray(stages, ["init", "short circut", "chain", "errors ok"]);
})
-.then($DONE, $DONE);
+
+let p = Promise.resolve()
+if (has_fs()) {
+ p = p
+ .then(test)
+ .then(() => assert.compareArray(stages, ["init", "short circut", "chain", "errors ok"]))
+}
+
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_02.t.js
--- a/test/fs/promises_02.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_02.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -5,8 +5,9 @@ flags: [async]
var fname = `${test_dir}/fs_promises_02`;
-var testSync = new Promise((resolve, reject) => {
- var failed = false;
+let stages = [];
+
+var testSync = () => new Promise((resolve, reject) => {
try {
fs.writeFileSync(fname, fname);
@@ -15,47 +16,52 @@ var testSync = new Promise((resolve, rej
try {
fs.accessSync(fname + '___');
- failed = true;
- } catch(e) {
- failed = (e.syscall != 'access') || e.code != 'ENOENT';
+ reject(new Error('fs.accessSync error 1'));
+ } catch (e) {
+ if (e.syscall != 'access' || e.code != 'ENOENT') {
+ reject(new Error('fs.accessSync error 2'));
+ }
}
- resolve(Boolean(failed));
+
+ stages.push('testSync');
+
+ resolve();
+
} catch (e) {
reject(e);
}
});
-var testCallback = new Promise((resolve, reject) => {
- var failed = false;
-
+var testCallback = () => new Promise((resolve, reject) => {
fs.writeFileSync(fname, fname);
fs.access(fname, (err) => {
- failed = (err !== undefined);
+ if (err) {
+ reject(new Error('fs.access error 1'));
+ }
+
fs.access(fname, fs.constants.R_OK | fs.constants.W_OK, (err) => {
- failed |= (err !== undefined);
+ if (err) {
+ reject(err);
+ }
+
fs.access(fname + '___', (err) => {
- failed |= ((err === undefined) || (err.syscall != 'access')
- || err.code != 'ENOENT');
- resolve(Boolean(failed));
+ if (!err
+ || err.syscall != 'access'
+ || err.code != 'ENOENT')
+ {
+ reject(new Error('fs.access error 2'));
+ }
+
+ stages.push('testCallback');
+
+ resolve();
});
});
});
});
-let stages = [];
-
-Promise.resolve()
-.then(() => testSync)
-.then(failed => {
- stages.push('testSync');
- assert.sameValue(failed, false, 'testSync');
-})
-.then(() => testCallback)
-.then(failed => {
- stages.push('testCallback');
- assert.sameValue(failed, false, 'testCallback');
-})
+let testFsp = () => Promise.resolve()
.then(() => {
fs.writeFileSync(fname, fname);
@@ -72,7 +78,14 @@ Promise.resolve()
assert.sameValue(e.path, fname + '___', 'testPromise');
assert.sameValue(e.code, 'ENOENT', 'testPromise');
})
-.then(() => {
- assert.compareArray(stages, ["testSync", "testCallback", "testPromise"]);
-})
-.then($DONE, $DONE);
+
+let p = Promise.resolve()
+if (has_fs()) {
+ p = p
+ .then(testSync)
+ .then(testCallback)
+ .then(testFsp)
+ .then(() => assert.compareArray(stages, ["testSync", "testCallback", "testPromise"]))
+}
+
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_03.t.js
--- a/test/fs/promises_03.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_03.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -5,6 +5,8 @@ flags: [async]
var fname = `${test_dir}/fs_promises_03`;
+let stages = [];
+
var testSync = () => new Promise((resolve, reject) => {
try {
try {
@@ -32,13 +34,14 @@ var testSync = () => new Promise((resolv
void e;
}
+ stages.push("unlinkSync");
+
resolve();
} catch (e) {
reject(e);
}
});
-
var testCallback = () => new Promise((resolve, reject) => {
fs.unlink(fname, () => {
fs.unlink(fname, (err) => {
@@ -64,31 +67,21 @@ var testCallback = () => new Promise((re
} catch (e) {
void e;
}
+
+ stages.push("unlink");
+
resolve();
});
});
});
});
-let stages = [];
-
-Promise.resolve()
-.then(testSync)
-.then(() => {
- stages.push("unlinkSync");
-})
-
-.then(testCallback)
-.then(() => {
- stages.push("unlink");
-})
-
+let testFsp = () => Promise.resolve()
.then(() => fsp.unlink(fname)
.catch(() => {}))
.then(() => fsp.unlink(fname))
.then(() => { throw new Error('fsp.unlink error 1'); })
.catch((e) => { if (e.syscall != 'unlink') { throw e; } })
-
.then(() => {
fs.writeFileSync(fname, fname);
return fsp.unlink(fname);
@@ -96,9 +89,17 @@ Promise.resolve()
.then(() => fsp.access(fname))
.then(() => { throw new Error('fsp.unlink error 2'); })
.catch((e) => { if (e.syscall != 'access') { throw e; } })
-
.then(() => {
stages.push("fsp.unlink");
})
-.then(() => assert.compareArray(stages, ['unlinkSync', 'unlink', 'fsp.unlink']))
-.then($DONE, $DONE);
+
+let p = Promise.resolve()
+if (has_fs()) {
+ p = p
+ .then(testSync)
+ .then(testCallback)
+ .then(testFsp)
+ .then(() => assert.compareArray(stages, ['unlinkSync', 'unlink', 'fsp.unlink']))
+}
+
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_04.t.js
--- a/test/fs/promises_04.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_04.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -7,25 +7,21 @@ var fname = `${test_dir}/fs_promises_04`
var fname_utf8 = `${test_dir}/fs_promises_αβγ_04`;
var lname = `${test_dir}/fs_promises_lnk_04`;
+let stages = [];
+
var testSync = () => new Promise((resolve, reject) => {
try {
- try {
- fs.unlinkSync(fname);
- } catch (e) {
- void e;
- }
- try {
- fs.unlinkSync(lname);
- } catch (e) {
- void e;
- }
+ try { fs.unlinkSync(fname); } catch (e) {}
+ try { fs.unlinkSync(lname); } catch (e) {}
try {
fs.realpathSync(fname);
+
throw new Error('fs.realpathSync error 1');
+
} catch (e) {
- if (e.syscall != 'realpath' || e.code != 'ENOENT') {
- throw e;
+ if (e.code != 'ENOENT') {
+ throw new Error('fs.realpathSync error 2');
}
}
@@ -46,7 +42,7 @@ var testSync = () => new Promise((resolv
var rname_utf8 = fs.realpathSync(fname_utf8);
if (rname_utf8.slice(-6,-3) != 'αβγ') {
- throw new Error('fs.realpathSync error 2');
+ throw new Error('fs.realpathSync error 3');
}
fs.unlinkSync(lname);
@@ -54,6 +50,8 @@ var testSync = () => new Promise((resolv
fs.unlinkSync(fname);
fs.unlinkSync(fname_utf8);
+ stages.push("symlinkSync");
+
resolve();
} catch (e) {
@@ -80,7 +78,8 @@ var testCallback = () => new Promise((re
reject(new Error('fs.realpath error 1'));
return;
}
- if (err.syscall != 'realpath' || err.code != 'ENOENT') {
+
+ if (err.code != 'ENOENT') {
reject(err);
return;
}
@@ -130,6 +129,8 @@ var testCallback = () => new Promise((re
return;
}
+ stages.push("symlink");
+
resolve();
});
});
@@ -141,19 +142,7 @@ var testCallback = () => new Promise((re
}
});
-let stages = [];
-
-Promise.resolve()
-.then(testSync)
-.then(() => {
- stages.push("symlinkSync");
-})
-
-.then(testCallback)
-.then(() => {
- stages.push("symlink");
-})
-
+let testFsp = () => Promise.resolve()
.then(() => fsp.unlink(fname)
.catch(() => {}))
.then(() => fsp.unlink(lname)
@@ -186,10 +175,17 @@ Promise.resolve()
fs.unlinkSync(lname);
fs.accessSync(fname);
fs.unlinkSync(fname);
+
+ stages.push("fsp.symlink");
})
-.then(() => {
- stages.push("fsp.symlink");
-})
-.then(() => assert.compareArray(stages, ['symlinkSync', 'symlink', 'fsp.symlink']))
-.then($DONE, $DONE);
+let p = Promise.resolve()
+if (has_fs() && has_fs_symbolic_link()) {
+ p = p
+ .then(testSync)
+ .then(testCallback)
+ .then(testFsp)
+ .then(() => assert.compareArray(stages, ['symlinkSync', 'symlink', 'fsp.symlink']))
+}
+
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_05.t.js
--- a/test/fs/promises_05.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_05.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -7,6 +7,8 @@ var dname = `${test_dir}/fs_promises_05`
var dname_utf8 = `${test_dir}/fs_promises_αβγ_05`;
var fname = (d) => d + '/fs_promises_05_file';
+let stages = [];
+
var testSync = () => new Promise((resolve, reject) => {
try {
try { fs.unlinkSync(fname(dname)); } catch (e) {}
@@ -47,6 +49,8 @@ var testSync = () => new Promise((resolv
try {
fs.writeFileSync(fname(dname_utf8), fname(dname_utf8));
+ throw new Error('fs.mkdirSync error 1');
+
} catch (e) {
if (e.syscall != 'open' || e.code != 'EACCES') {
throw e;
@@ -64,6 +68,8 @@ var testSync = () => new Promise((resolv
fs.rmdirSync(dname_utf8);
+ stages.push("mkdirSync");
+
resolve();
} catch (e) {
@@ -94,6 +100,8 @@ var testCallback = () => new Promise((re
reject(err);
}
+ stages.push("mkdir");
+
resolve();
});
});
@@ -104,21 +112,7 @@ var testCallback = () => new Promise((re
}
});
-
-let stages = [];
-
-Promise.resolve()
-.then(testSync)
-.then(() => {
- stages.push("mkdirSync");
-})
-
-
-.then(testCallback)
-.then(() => {
- stages.push("mkdir");
-})
-
+let testFsp = () => Promise.resolve()
.then(() => {
try { fs.unlinkSync(fname(dname)); } catch (e) {}
try { fs.unlinkSync(fname(dname_utf8)); } catch (e) {}
@@ -136,5 +130,14 @@ Promise.resolve()
.then(() => {
stages.push("fsp.mkdir");
})
-.then(() => assert.compareArray(stages, ['mkdirSync', 'mkdir', 'fsp.mkdir']))
-.then($DONE, $DONE);
+
+let p = Promise.resolve()
+if (has_fs()) {
+ p = p
+ .then(testSync)
+ .then(testCallback)
+ .then(testFsp)
+ .then(() => assert.compareArray(stages, ['mkdirSync', 'mkdir', 'fsp.mkdir']))
+}
+
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_06.t.js
--- a/test/fs/promises_06.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_06.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -7,7 +7,9 @@ var dname = `${test_dir}/`;
var fname = (d) => d + '/fs_promises_06_file';
var fname_utf8 = (d) => d + '/fs_promises_αβγ_06';
-var testSync = new Promise((resolve, reject) => {
+let stages = [];
+
+var testSync = () => new Promise((resolve, reject) => {
try {
try { fs.unlinkSync(fname(dname)); } catch (e) {}
try { fs.unlinkSync(fname_utf8(dname)); } catch (e) {}
@@ -25,10 +27,12 @@ var testSync = new Promise((resolve, rej
if (e.syscall != 'rename'
|| (e.code != 'ENOTDIR' && e.code != 'EISDIR'))
{
- throw e;
+ reject(new Error('fs.unlinkSync error 1'));
}
}
+ stages.push("renameSync");
+
resolve();
} catch (e) {
@@ -36,7 +40,7 @@ var testSync = new Promise((resolve, rej
}
});
-var testCallback = new Promise((resolve, reject) => {
+var testCallback = () => new Promise((resolve, reject) => {
try {
try { fs.unlinkSync(fname(dname)); } catch (e) {}
try { fs.unlinkSync(fname_utf8(dname)); } catch (e) {}
@@ -45,46 +49,30 @@ var testCallback = new Promise((resolve,
fs.rename(fname(dname), fname_utf8(dname), err => {
if (err) {
- throw err;
+ reject(new Error('fs.unlink error 1'));
}
- });
- fs.accessSync(fname_utf8(dname));
+ fs.accessSync(fname_utf8(dname));
- fs.rename(fname_utf8(dname), dname, err => {
- if (err.syscall != 'rename'
- || (err.code != 'ENOTDIR' && err.code != 'EISDIR'))
- {
- throw err;
- }
+ fs.rename(fname_utf8(dname), dname, err => {
+ if (err.syscall != 'rename'
+ || (err.code != 'ENOTDIR' && err.code != 'EISDIR'))
+ {
+ reject(new Error('fs.unlink error 2'));
+ }
+ });
+
+ stages.push("rename");
+
+ resolve();
});
- resolve();
-
} catch (e) {
reject(e);
}
});
-let stages = [];
-
-Promise.resolve()
-.then(() => testSync)
-.then(() => {
- stages.push("renameSync");
-})
-.catch((e) => {
- console.log('test fs.renameSync failed', JSON.stringify(e));
-})
-
-.then(testCallback)
-.then(() => {
- stages.push("rename");
-})
-.catch((e) => {
- console.log('test fs.rename failed', JSON.stringify(e));
-})
-
+let testFsp = () => Promise.resolve()
.then(() => {
try { fs.unlinkSync(fname(dname)); } catch (e) {}
try { fs.unlinkSync(fname_utf8(dname)); } catch (e) {}
@@ -98,11 +86,20 @@ Promise.resolve()
if (e.syscall != 'rename'
|| (e.code != 'ENOTDIR' && e.code != 'EISDIR'))
{
- throw e;
+ throw new Error('fsp.rename error 1');
}
})
.then(() => {
stages.push("fsp.rename");
})
-.then(() => assert.compareArray(stages, ["renameSync", "rename", "fsp.rename"]))
-.then($DONE, $DONE);
+
+let p = Promise.resolve()
+if (has_fs()) {
+ p = p
+ .then(testSync)
+ .then(testCallback)
+ .then(testFsp)
+ .then(() => assert.compareArray(stages, ["renameSync", "rename", "fsp.rename"]))
+}
+
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_07.t.js
--- a/test/fs/promises_07.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_07.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -15,7 +15,7 @@ var match = (entry) => {
var idx = dir_test.indexOf(entry.name);
try {
- switch(idx) {
+ switch (idx) {
case 0:
return entry.isDirectory();
case 1:
@@ -34,6 +34,7 @@ var match = (entry) => {
}
};
+let stages = [];
var testSync = () => new Promise((resolve, reject) => {
try {
@@ -109,6 +110,8 @@ var testSync = () => new Promise((resolv
throw new Error('fs.readdirSync - error 8');
}
+ stages.push("readdirSync");
+
resolve();
} catch (e) {
@@ -167,6 +170,8 @@ var testCallback = () => new Promise((re
reject(new Error('fs.readdir - error 5'));
}
+ stages.push("readdir");
+
resolve();
});
});
@@ -177,20 +182,7 @@ var testCallback = () => new Promise((re
}
});
-
-let stages = [];
-
-Promise.resolve()
-.then(testSync)
-.then(() => {
- stages.push("readdirSync");
-})
-
-.then(testCallback)
-.then(() => {
- stages.push("readdir");
-})
-
+let testFsp = () => Promise.resolve()
.then(() => {
try { fs.rmdirSync(cname(dname)); } catch (e) {}
try { fs.unlinkSync(lname(dname)); } catch (e) {}
@@ -235,5 +227,14 @@ Promise.resolve()
.then(() => {
stages.push("fsp.readdir");
})
-.then(() => assert.compareArray(stages, ["readdirSync", "readdir", "fsp.readdir"]))
-.then($DONE, $DONE);
+
+let p = Promise.resolve()
+if (has_fs() && has_fs_symbolic_link()) {
+ p = p
+ .then(testSync)
+ .then(testCallback)
+ .then(testFsp)
+ .then(() => assert.compareArray(stages, ['readdirSync', 'readdir', 'fsp.readdir']))
+}
+
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_08.t.js
--- a/test/fs/promises_08.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_08.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -24,6 +24,8 @@ var wipePath = (root, path, nofail) => {
});
};
+let stages = [];
+
var testSync = () => new Promise((resolve, reject) => {
try {
wipePath(dname, path + '/' + path, true);
@@ -66,21 +68,20 @@ var testSync = () => new Promise((resolv
wipePath(dname, path);
fs.rmdirSync(dname);
+
+ stages.push("mkdirSync")
+
resolve();
} catch (e) {
reject(e);
}
});
-let stages = [];
+let p = Promise.resolve()
+if (has_fs()) {
+ p = p
+ .then(testSync)
+ .then(() => assert.compareArray(stages, ["mkdirSync"]))
+}
-Promise.resolve()
-.then(testSync)
-.then(() => {
- stages.push("mkdirSync");
-})
-.catch((e) => {
- $DONOTEVALUATE();
-})
-.then(() => assert.compareArray(stages, ["mkdirSync"]))
-.then($DONE, $DONE);
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/fs/promises_09.t.js
--- a/test/fs/promises_09.t.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/fs/promises_09.t.js Fri Aug 19 21:38:55 2022 -0700
@@ -23,6 +23,7 @@ var setContent = (root, path) => {
var isNode = () => process.argv[0].includes('node');
+let stages = [];
var testSync = () => new Promise((resolve, reject) => {
try {
@@ -90,6 +91,8 @@ var testSync = () => new Promise((resolv
}
}
+ stages.push("rmdirSync");
+
resolve();
} catch (e) {
@@ -97,13 +100,11 @@ var testSync = () => new Promise((resolv
}
});
-
-let stages = [];
+let p = Promise.resolve()
+if (has_fs() && has_fs_symbolic_link()) {
+ p = p
+ .then(testSync)
+ .then(() => assert.compareArray(stages, ['rmdirSync']))
+}
-Promise.resolve()
-.then(testSync)
-.then(() => {
- stages.push("rmdirSync");
-})
-.then(() => assert.compareArray(stages, ["rmdirSync"]))
-.then($DONE, $DONE);
+p.then($DONE, $DONE);
diff -r 446a1cb64a6a -r ae971e65f638 test/harness/compatFs.js
--- a/test/harness/compatFs.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/harness/compatFs.js Fri Aug 19 21:38:55 2022 -0700
@@ -6,9 +6,37 @@ if (typeof require == 'function') {
fsp = fs.promises;
}
+if (typeof process == 'undefined') {
+ globalThis.process = {};
+}
+
+let test_dir = process.env && process.env['NJS_TEST_DIR'] || 'build';
+test_dir = `${test_dir}/test`;
+
function has_fs() {
return fs;
}
-let test_dir = process.env && process.env['NJS_TEST_DIR'] || 'build';
-test_dir = `${test_dir}/test`;
+function has_fs_symbolic_link() {
+ if (!fs) {
+ return false;
+ }
+
+ let fname = test_dir + '/a';
+ let lname = test_dir + '/b';
+
+ try { fs.unlinkSync(fname); fs.unlinkSync(lname); } catch (e) {}
+
+ fs.writeFileSync(fname, fname);
+
+ fname = fs.realpathSync(fname);
+
+ try {
+ fs.symlinkSync(fname, lname);
+ } catch (e) {
+ return false;
+ }
+
+ return true;
+}
+
diff -r 446a1cb64a6a -r ae971e65f638 test/harness/compatPrint.js
--- a/test/harness/compatPrint.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/harness/compatPrint.js Fri Aug 19 21:38:55 2022 -0700
@@ -1,3 +1,3 @@
if (typeof print !== 'function') {
- print = console.log;
+ globalThis.print = console.log;
}
diff -r 446a1cb64a6a -r ae971e65f638 test/harness/compatWebcrypto.js
--- a/test/harness/compatWebcrypto.js Wed Aug 10 20:04:40 2022 -0700
+++ b/test/harness/compatWebcrypto.js Fri Aug 19 21:38:55 2022 -0700
@@ -1,5 +1,5 @@
if (typeof crypto == 'undefined' && typeof require == 'function') {
- crypto = require('crypto').webcrypto;
+ globalThis.crypto = require('crypto').webcrypto;
}
function has_webcrypto() {
More information about the nginx-devel
mailing list