summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-08-06 14:40:30 -0700
committerJames M Snell <jasnell@gmail.com>2018-08-09 13:47:31 -0700
commitc7962dcba46f44b888686e6a76bcc6fef2eb7760 (patch)
tree247db2bcd4f0673adf5ccad86ed7fc58286e7c9b /test
parent2fd71f92381010724e24cd07d505f76e63b16394 (diff)
downloadandroid-node-v8-c7962dcba46f44b888686e6a76bcc6fef2eb7760.tar.gz
android-node-v8-c7962dcba46f44b888686e6a76bcc6fef2eb7760.tar.bz2
android-node-v8-c7962dcba46f44b888686e6a76bcc6fef2eb7760.zip
src: move process.binding('uv') to internalBinding
PR-URL: https://github.com/nodejs/node/pull/22163 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-dgram-cluster-bind-error.js4
-rw-r--r--test/parallel/test-dgram-send-error.js5
-rw-r--r--test/parallel/test-dgram-socket-buffer-size.js15
-rw-r--r--test/parallel/test-dns-lookup.js5
-rw-r--r--test/parallel/test-dns-memory-error.js3
-rw-r--r--test/parallel/test-fs-access.js8
-rw-r--r--test/parallel/test-fs-copyfile.js11
-rw-r--r--test/parallel/test-fs-error-messages.js92
-rw-r--r--test/parallel/test-fs-sync-fd-leak.js6
-rw-r--r--test/parallel/test-fs-watch-enoent.js15
-rw-r--r--test/parallel/test-http-client-immediate-error.js5
-rw-r--r--test/parallel/test-net-end-close.js6
-rw-r--r--test/parallel/test-tcp-wrap.js6
-rw-r--r--test/parallel/test-ttywrap-invalid-fd.js9
-rw-r--r--test/parallel/test-uv-binding-constant.js6
-rw-r--r--test/parallel/test-uv-errno.js4
16 files changed, 125 insertions, 75 deletions
diff --git a/test/parallel/test-dgram-cluster-bind-error.js b/test/parallel/test-dgram-cluster-bind-error.js
index ad33328d40..fb338da972 100644
--- a/test/parallel/test-dgram-cluster-bind-error.js
+++ b/test/parallel/test-dgram-cluster-bind-error.js
@@ -1,9 +1,11 @@
+// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');
-const { UV_UNKNOWN } = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const { UV_UNKNOWN } = internalBinding('uv');
if (cluster.isMaster) {
cluster.fork();
diff --git a/test/parallel/test-dgram-send-error.js b/test/parallel/test-dgram-send-error.js
index 7757db1e2d..f6d37f2c81 100644
--- a/test/parallel/test-dgram-send-error.js
+++ b/test/parallel/test-dgram-send-error.js
@@ -3,6 +3,8 @@
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
+const { internalBinding } = require('internal/test/binding');
+const { UV_UNKNOWN } = internalBinding('uv');
const { kStateSymbol } = require('internal/dgram');
const mockError = new Error('mock DNS error');
@@ -45,7 +47,6 @@ getSocket((socket) => {
socket.bind(common.mustCall(() => {
const port = socket.address().port;
- const errCode = process.binding('uv').UV_UNKNOWN;
const callback = common.mustCall((err) => {
socket.close();
assert.strictEqual(err.code, 'UNKNOWN');
@@ -60,7 +61,7 @@ getSocket((socket) => {
});
socket[kStateSymbol].handle.send = function() {
- return errCode;
+ return UV_UNKNOWN;
};
socket.send('foo', port, common.localhostIPv4, callback);
diff --git a/test/parallel/test-dgram-socket-buffer-size.js b/test/parallel/test-dgram-socket-buffer-size.js
index 834ca30c57..c2936ba8fd 100644
--- a/test/parallel/test-dgram-socket-buffer-size.js
+++ b/test/parallel/test-dgram-socket-buffer-size.js
@@ -1,17 +1,22 @@
-'use strict';
// Flags: --expose-internals
+'use strict';
const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');
const { SystemError } = require('internal/errors');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const {
+ UV_EBADF,
+ UV_EINVAL,
+ UV_ENOTSOCK
+} = internalBinding('uv');
function getExpectedError(type) {
const code = common.isWindows ? 'ENOTSOCK' : 'EBADF';
const message = common.isWindows ?
'socket operation on non-socket' : 'bad file descriptor';
- const errno = common.isWindows ? uv.UV_ENOTSOCK : uv.UV_EBADF;
+ const errno = common.isWindows ? UV_ENOTSOCK : UV_EBADF;
const syscall = `uv_${type}_buffer_size`;
const suffix = common.isWindows ?
'ENOTSOCK (socket operation on non-socket)' : 'EBADF (bad file descriptor)';
@@ -105,7 +110,7 @@ function getExpectedError(type) {
const info = {
code: 'EINVAL',
message: 'invalid argument',
- errno: uv.UV_EINVAL,
+ errno: UV_EINVAL,
syscall: 'uv_recv_buffer_size'
};
const errorObj = {
@@ -128,7 +133,7 @@ function getExpectedError(type) {
const info = {
code: 'EINVAL',
message: 'invalid argument',
- errno: uv.UV_EINVAL,
+ errno: UV_EINVAL,
syscall: 'uv_send_buffer_size'
};
const errorObj = {
diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js
index 3413bcffd8..99378ce01e 100644
--- a/test/parallel/test-dns-lookup.js
+++ b/test/parallel/test-dns-lookup.js
@@ -1,3 +1,4 @@
+// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
@@ -5,8 +6,10 @@ const cares = process.binding('cares_wrap');
const dns = require('dns');
const dnsPromises = dns.promises;
+const { internalBinding } = require('internal/test/binding');
+
// Stub `getaddrinfo` to *always* error.
-cares.getaddrinfo = () => process.binding('uv').UV_ENOENT;
+cares.getaddrinfo = () => internalBinding('uv').UV_ENOENT;
{
const err = {
diff --git a/test/parallel/test-dns-memory-error.js b/test/parallel/test-dns-memory-error.js
index 2048ad4c4e..29907fb1db 100644
--- a/test/parallel/test-dns-memory-error.js
+++ b/test/parallel/test-dns-memory-error.js
@@ -8,8 +8,9 @@ require('../common');
const assert = require('assert');
const errors = require('internal/errors');
+const { internalBinding } = require('internal/test/binding');
-const { UV_EAI_MEMORY } = process.binding('uv');
+const { UV_EAI_MEMORY } = internalBinding('uv');
const memoryError = errors.dnsException(UV_EAI_MEMORY, 'fhqwhgads');
assert.strictEqual(memoryError.code, 'EAI_MEMORY');
diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js
index d053b9323b..02e9356275 100644
--- a/test/parallel/test-fs-access.js
+++ b/test/parallel/test-fs-access.js
@@ -1,3 +1,4 @@
+// Flags: --expose-internals
'use strict';
// This tests that fs.access and fs.accessSync works as expected
@@ -8,7 +9,8 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const { UV_ENOENT } = internalBinding('uv');
const tmpdir = require('../common/tmpdir');
const doesNotExist = path.join(tmpdir.path, '__this_should_not_exist');
@@ -161,7 +163,7 @@ assert.throws(
);
assert.strictEqual(err.constructor, Error);
assert.strictEqual(err.syscall, 'access');
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
return true;
}
);
@@ -177,7 +179,7 @@ assert.throws(
);
assert.strictEqual(err.constructor, Error);
assert.strictEqual(err.syscall, 'access');
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
return true;
}
);
diff --git a/test/parallel/test-fs-copyfile.js b/test/parallel/test-fs-copyfile.js
index f001535598..90e7c7009d 100644
--- a/test/parallel/test-fs-copyfile.js
+++ b/test/parallel/test-fs-copyfile.js
@@ -1,10 +1,15 @@
+// Flags: --expose-internals
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const fs = require('fs');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const {
+ UV_ENOENT,
+ UV_EEXIST
+} = internalBinding('uv');
const path = require('path');
const src = fixtures.path('a.js');
const dest = path.join(tmpdir.path, 'copyfile.out');
@@ -81,14 +86,14 @@ fs.copyFile(src, dest, common.mustCall((err) => {
assert.strictEqual(err.message,
'ENOENT: no such file or directory, copyfile ' +
`'${src}' -> '${dest}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'copyfile');
} else {
assert.strictEqual(err.message,
'EEXIST: file already exists, copyfile ' +
`'${src}' -> '${dest}'`);
- assert.strictEqual(err.errno, uv.UV_EEXIST);
+ assert.strictEqual(err.errno, UV_EEXIST);
assert.strictEqual(err.code, 'EEXIST');
assert.strictEqual(err.syscall, 'copyfile');
}
diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js
index 8ef009e812..4ca9fb2ef9 100644
--- a/test/parallel/test-fs-error-messages.js
+++ b/test/parallel/test-fs-error-messages.js
@@ -1,3 +1,4 @@
+// Flags: --expose-internals
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,7 +36,16 @@ const existingFile2 = fixtures.path('create-file.js');
const existingDir = tmpdir.path;
const existingDir2 = fixtures.path('keys');
const { COPYFILE_EXCL } = fs.constants;
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const {
+ UV_EBADF,
+ UV_EEXIST,
+ UV_EINVAL,
+ UV_ENOENT,
+ UV_ENOTDIR,
+ UV_ENOTEMPTY,
+ UV_EPERM
+} = internalBinding('uv');
// Template tag function for escaping special characters in strings so that:
// new RegExp(re`${str}`).test(str) === true
@@ -56,7 +66,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, stat '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'stat');
return true;
@@ -77,7 +87,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, lstat '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'lstat');
return true;
@@ -94,7 +104,7 @@ function re(literals, ...values) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, fstat');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'fstat');
return true;
@@ -117,7 +127,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, lstat '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'lstat');
return true;
@@ -138,7 +148,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, realpath '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'realpath');
return true;
@@ -159,7 +169,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, readlink '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'readlink');
return true;
@@ -184,7 +194,7 @@ function re(literals, ...values) {
re`'${nonexistentFile}' -> ` + '\'.*foo\'');
assert.ok(regexp.test(err.message),
`Expect ${err.message} to match ${regexp}`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'link');
return true;
@@ -207,7 +217,7 @@ function re(literals, ...values) {
err.message,
`EEXIST: file already exists, link '${existingFile}' -> ` +
`'${existingFile2}'`);
- assert.strictEqual(err.errno, uv.UV_EEXIST);
+ assert.strictEqual(err.errno, UV_EEXIST);
assert.strictEqual(err.code, 'EEXIST');
assert.strictEqual(err.syscall, 'link');
return true;
@@ -230,7 +240,7 @@ function re(literals, ...values) {
err.message,
`EEXIST: file already exists, symlink '${existingFile}' -> ` +
`'${existingFile2}'`);
- assert.strictEqual(err.errno, uv.UV_EEXIST);
+ assert.strictEqual(err.errno, UV_EEXIST);
assert.strictEqual(err.code, 'EEXIST');
assert.strictEqual(err.syscall, 'symlink');
return true;
@@ -251,7 +261,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, unlink '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'unlink');
return true;
@@ -276,7 +286,7 @@ function re(literals, ...values) {
re`'${nonexistentFile}' -> ` + '\'.*foo\'');
assert.ok(regexp.test(err.message),
`Expect ${err.message} to match ${regexp}`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'rename');
return true;
@@ -302,7 +312,7 @@ function re(literals, ...values) {
err.message,
`ENOTEMPTY: directory not empty, rename '${existingDir}' -> ` +
`'${existingDir2}'`);
- assert.strictEqual(err.errno, uv.UV_ENOTEMPTY);
+ assert.strictEqual(err.errno, UV_ENOTEMPTY);
} else if (err.code === 'EXDEV') { // not on the same mounted filesystem
assert.strictEqual(
err.message,
@@ -313,13 +323,13 @@ function re(literals, ...values) {
err.message,
`EEXIST: file already exists, rename '${existingDir}' -> ` +
`'${existingDir2}'`);
- assert.strictEqual(err.errno, uv.UV_EEXIST);
+ assert.strictEqual(err.errno, UV_EEXIST);
} else { // windows
assert.strictEqual(
err.message,
`EPERM: operation not permitted, rename '${existingDir}' -> ` +
`'${existingDir2}'`);
- assert.strictEqual(err.errno, uv.UV_EPERM);
+ assert.strictEqual(err.errno, UV_EPERM);
assert.strictEqual(err.code, 'EPERM');
}
return true;
@@ -340,7 +350,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, rmdir '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'rmdir');
return true;
@@ -363,12 +373,12 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOTDIR: not a directory, rmdir '${existingFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOTDIR);
+ assert.strictEqual(err.errno, UV_ENOTDIR);
} else { // windows
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, rmdir '${existingFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
}
return true;
@@ -389,7 +399,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`EEXIST: file already exists, mkdir '${existingFile}'`);
- assert.strictEqual(err.errno, uv.UV_EEXIST);
+ assert.strictEqual(err.errno, UV_EEXIST);
assert.strictEqual(err.code, 'EEXIST');
assert.strictEqual(err.syscall, 'mkdir');
return true;
@@ -410,7 +420,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, chmod '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'chmod');
return true;
@@ -431,7 +441,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, open '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'open');
return true;
@@ -450,7 +460,7 @@ function re(literals, ...values) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, close');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'close');
return true;
@@ -473,7 +483,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, open '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'open');
return true;
@@ -494,7 +504,7 @@ function re(literals, ...values) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, scandir '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'scandir');
return true;
@@ -515,10 +525,10 @@ function re(literals, ...values) {
// Could be EBADF or EINVAL, depending on the platform
if (err.code === 'EBADF') {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, ftruncate');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
} else {
assert.strictEqual(err.message, 'EINVAL: invalid argument, ftruncate');
- assert.strictEqual(err.errno, uv.UV_EINVAL);
+ assert.strictEqual(err.errno, UV_EINVAL);
assert.strictEqual(err.code, 'EINVAL');
}
return true;
@@ -538,7 +548,7 @@ function re(literals, ...values) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, fdatasync');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'fdatasync');
return true;
@@ -558,7 +568,7 @@ function re(literals, ...values) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, fsync');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'fsync');
return true;
@@ -581,7 +591,7 @@ if (!common.isWindows) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, chown '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'chown');
return true;
@@ -604,7 +614,7 @@ if (!common.isAIX) {
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, utime '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'utime');
return true;
@@ -631,7 +641,7 @@ if (!common.isAIX) {
assert(prefix.test(err.message),
`Expect ${err.message} to match ${prefix}`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'mkdtemp');
return true;
@@ -650,7 +660,7 @@ if (!common.isAIX) {
const validateError = {
// TODO: Make sure the error message always also contains the src.
message: `EINVAL: invalid argument, copyfile -> '${nonexistentFile}'`,
- errno: uv.UV_EINVAL,
+ errno: UV_EINVAL,
code: 'EINVAL',
syscall: 'copyfile'
};
@@ -673,14 +683,14 @@ if (!common.isAIX) {
assert.strictEqual(err.message,
'ENOENT: no such file or directory, copyfile ' +
`'${existingFile}' -> '${existingFile2}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'copyfile');
} else {
assert.strictEqual(err.message,
'EEXIST: file already exists, copyfile ' +
`'${existingFile}' -> '${existingFile2}'`);
- assert.strictEqual(err.errno, uv.UV_EEXIST);
+ assert.strictEqual(err.errno, UV_EEXIST);
assert.strictEqual(err.code, 'EEXIST');
assert.strictEqual(err.syscall, 'copyfile');
}
@@ -702,7 +712,7 @@ if (!common.isAIX) {
assert.strictEqual(err.message,
'ENOENT: no such file or directory, copyfile ' +
`'${nonexistentFile}' -> '${existingFile2}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'copyfile');
return true;
@@ -721,7 +731,7 @@ if (!common.isAIX) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, read');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'read');
return true;
@@ -742,7 +752,7 @@ if (!common.isAIX) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, fchmod');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'fchmod');
return true;
@@ -762,7 +772,7 @@ if (!common.isAIX) {
if (!common.isWindows) {
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, fchown');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'fchown');
return true;
@@ -783,7 +793,7 @@ if (!common.isWindows) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, write');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'write');
return true;
@@ -804,7 +814,7 @@ if (!common.isWindows) {
{
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, write');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'write');
return true;
@@ -825,7 +835,7 @@ if (!common.isWindows) {
if (!common.isAIX) {
const validateError = (err) => {
assert.strictEqual(err.message, 'EBADF: bad file descriptor, futime');
- assert.strictEqual(err.errno, uv.UV_EBADF);
+ assert.strictEqual(err.errno, UV_EBADF);
assert.strictEqual(err.code, 'EBADF');
assert.strictEqual(err.syscall, 'futime');
return true;
diff --git a/test/parallel/test-fs-sync-fd-leak.js b/test/parallel/test-fs-sync-fd-leak.js
index 52e40eb390..ee2e0355ec 100644
--- a/test/parallel/test-fs-sync-fd-leak.js
+++ b/test/parallel/test-fs-sync-fd-leak.js
@@ -1,3 +1,4 @@
+// Flags: --expose-internals
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,7 +24,8 @@
require('../common');
const assert = require('assert');
const fs = require('fs');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const { UV_EBADF } = internalBinding('uv');
// ensure that (read|write|append)FileSync() closes the file descriptor
fs.openSync = function() {
@@ -41,7 +43,7 @@ fs.writeSync = function() {
};
process.binding('fs').fstat = function(fd, bigint, _, ctx) {
- ctx.errno = uv.UV_EBADF;
+ ctx.errno = UV_EBADF;
ctx.syscall = 'fstat';
};
diff --git a/test/parallel/test-fs-watch-enoent.js b/test/parallel/test-fs-watch-enoent.js
index e6db65993d..1ed9f2ed64 100644
--- a/test/parallel/test-fs-watch-enoent.js
+++ b/test/parallel/test-fs-watch-enoent.js
@@ -1,3 +1,4 @@
+// Flags: --expose-internals
'use strict';
// This verifies the error thrown by fs.watch.
@@ -8,7 +9,11 @@ const fs = require('fs');
const tmpdir = require('../common/tmpdir');
const path = require('path');
const nonexistentFile = path.join(tmpdir.path, 'non-existent');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const {
+ UV_ENODEV,
+ UV_ENOENT
+} = internalBinding('uv');
tmpdir.refresh();
@@ -21,13 +26,13 @@ tmpdir.refresh();
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, watch '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
} else { // AIX
assert.strictEqual(
err.message,
`ENODEV: no such device, watch '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENODEV);
+ assert.strictEqual(err.errno, UV_ENODEV);
assert.strictEqual(err.code, 'ENODEV');
}
return true;
@@ -50,7 +55,7 @@ tmpdir.refresh();
assert.strictEqual(
err.message,
`ENOENT: no such file or directory, watch '${nonexistentFile}'`);
- assert.strictEqual(err.errno, uv.UV_ENOENT);
+ assert.strictEqual(err.errno, UV_ENOENT);
assert.strictEqual(err.code, 'ENOENT');
assert.strictEqual(err.syscall, 'watch');
fs.unlinkSync(file);
@@ -60,5 +65,5 @@ tmpdir.refresh();
watcher.on('error', common.mustCall(validateError));
// Simulate the invocation from the binding
- watcher._handle.onchange(uv.UV_ENOENT, 'ENOENT', nonexistentFile);
+ watcher._handle.onchange(UV_ENOENT, 'ENOENT', nonexistentFile);
}
diff --git a/test/parallel/test-http-client-immediate-error.js b/test/parallel/test-http-client-immediate-error.js
index 1c65d07ca5..ff29ad72bd 100644
--- a/test/parallel/test-http-client-immediate-error.js
+++ b/test/parallel/test-http-client-immediate-error.js
@@ -8,7 +8,8 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');
const http = require('http');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const { UV_ENETUNREACH } = internalBinding('uv');
const {
newAsyncId,
symbols: { async_id_symbol }
@@ -21,7 +22,7 @@ agent.createConnection = common.mustCall((cfg) => {
// Fake the handle so we can enforce returning an immediate error
sock._handle = {
connect: common.mustCall((req, addr, port) => {
- return uv.UV_ENETUNREACH;
+ return UV_ENETUNREACH;
}),
readStart() {},
close() {}
diff --git a/test/parallel/test-net-end-close.js b/test/parallel/test-net-end-close.js
index 31c150e09c..c0705da9d0 100644
--- a/test/parallel/test-net-end-close.js
+++ b/test/parallel/test-net-end-close.js
@@ -1,14 +1,16 @@
+// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
const net = require('net');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const { UV_EOF } = internalBinding('uv');
const s = new net.Socket({
handle: {
readStart: function() {
- setImmediate(() => this.onread(uv.UV_EOF, null));
+ setImmediate(() => this.onread(UV_EOF, null));
},
close: (cb) => setImmediate(cb)
},
diff --git a/test/parallel/test-tcp-wrap.js b/test/parallel/test-tcp-wrap.js
index 36a45d7606..f6a54a012b 100644
--- a/test/parallel/test-tcp-wrap.js
+++ b/test/parallel/test-tcp-wrap.js
@@ -1,3 +1,4 @@
+// Flags: --expose-internals
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +25,8 @@ require('../common');
const assert = require('assert');
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const { UV_EINVAL } = internalBinding('uv');
const handle = new TCP(TCPConstants.SOCKET);
@@ -36,6 +38,6 @@ assert.strictEqual(err, 0);
const out = {};
handle.getsockname(out);
err = handle.bind('0.0.0.0', out.port);
-assert.strictEqual(err, uv.UV_EINVAL);
+assert.strictEqual(err, UV_EINVAL);
handle.close();
diff --git a/test/parallel/test-ttywrap-invalid-fd.js b/test/parallel/test-ttywrap-invalid-fd.js
index 0a0f8c5c4e..30c3cd2bc4 100644
--- a/test/parallel/test-ttywrap-invalid-fd.js
+++ b/test/parallel/test-ttywrap-invalid-fd.js
@@ -1,8 +1,13 @@
+// Flags: --expose-internals
'use strict';
const common = require('../common');
const tty = require('tty');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const {
+ UV_EBADF,
+ UV_EINVAL
+} = internalBinding('uv');
const assert = require('assert');
assert.throws(
@@ -18,7 +23,7 @@ assert.throws(
const info = {
code: common.isWindows ? 'EBADF' : 'EINVAL',
message: common.isWindows ? 'bad file descriptor' : 'invalid argument',
- errno: common.isWindows ? uv.UV_EBADF : uv.UV_EINVAL,
+ errno: common.isWindows ? UV_EBADF : UV_EINVAL,
syscall: 'uv_tty_init'
};
diff --git a/test/parallel/test-uv-binding-constant.js b/test/parallel/test-uv-binding-constant.js
index beae7672db..11d9f6aa09 100644
--- a/test/parallel/test-uv-binding-constant.js
+++ b/test/parallel/test-uv-binding-constant.js
@@ -1,10 +1,12 @@
+// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const uv = internalBinding('uv');
-// Ensures that the `UV_...` values in process.binding('uv')
+// Ensures that the `UV_...` values in internalBinding('uv')
// are constants.
const keys = Object.keys(uv);
diff --git a/test/parallel/test-uv-errno.js b/test/parallel/test-uv-errno.js
index d3b4f79db3..078db29adc 100644
--- a/test/parallel/test-uv-errno.js
+++ b/test/parallel/test-uv-errno.js
@@ -1,3 +1,4 @@
+// Flags: --expose-internals
'use strict';
const common = require('../common');
@@ -7,7 +8,8 @@ const {
_errnoException
} = require('util');
-const uv = process.binding('uv');
+const { internalBinding } = require('internal/test/binding');
+const uv = internalBinding('uv');
const keys = Object.keys(uv);
keys.forEach((key) => {