mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 13:00:17 +00:00

In preparation for a lint rule that will enforce assert.deepStrictEqual() over assert.deepEqual(), change tests and benchmarks accordingly. For tests and benchmarks that are testing or benchmarking assert.deepEqual() itself, apply a comment to ignore the upcoming rule. PR-URL: https://github.com/nodejs/node/pull/6213 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
'use strict';
|
|
var assert = require('assert');
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
var common = require('../common');
|
|
var msg = {test: 'this'};
|
|
var nodePath = process.execPath;
|
|
var copyPath = path.join(common.tmpDir, 'node-copy.exe');
|
|
|
|
if (process.env.FORK) {
|
|
assert(process.send);
|
|
assert.equal(process.argv[0], copyPath);
|
|
process.send(msg);
|
|
process.exit();
|
|
}
|
|
else {
|
|
common.refreshTmpDir();
|
|
try {
|
|
fs.unlinkSync(copyPath);
|
|
}
|
|
catch (e) {
|
|
if (e.code !== 'ENOENT') throw e;
|
|
}
|
|
fs.writeFileSync(copyPath, fs.readFileSync(nodePath));
|
|
fs.chmodSync(copyPath, '0755');
|
|
|
|
// slow but simple
|
|
var envCopy = JSON.parse(JSON.stringify(process.env));
|
|
envCopy.FORK = 'true';
|
|
var child = require('child_process').fork(__filename, {
|
|
execPath: copyPath,
|
|
env: envCopy
|
|
});
|
|
child.on('message', common.mustCall(function(recv) {
|
|
assert.deepStrictEqual(msg, recv);
|
|
}));
|
|
child.on('exit', common.mustCall(function(code) {
|
|
fs.unlinkSync(copyPath);
|
|
assert.equal(code, 0);
|
|
}));
|
|
}
|