node/test/abort/test-zlib-invalid-internals-usage.js
Anna Henningsen aec34473a7
test: remove usage of process.binding()
Prefer `internalBinding` or other equivalents over `process.binding()`
(except in tests checking `process.binding()` itself).

PR-URL: https://github.com/nodejs/node/pull/26304
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-03-07 17:43:21 +01:00

23 lines
883 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const os = require('os');
const cp = require('child_process');
if (process.argv[2] === 'child') {
const { internalBinding } = require('internal/test/binding');
// This is the heart of the test.
new (internalBinding('zlib').Zlib)(0).init(1, 2, 3, 4, 5);
} else {
const child = cp.spawnSync(
`${process.execPath}`, ['--expose-internals', `${__filename}`, 'child']);
assert.strictEqual(child.stdout.toString(), '');
assert.ok(child.stderr.includes(
'WARNING: You are likely using a version of node-tar or npm that ' +
`is incompatible with this version of Node.js.${os.EOL}` +
'Please use either the version of npm that is bundled with Node.js, or ' +
'a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is ' +
`compatible with Node.js 9 and above.${os.EOL}`));
}