Commit 3d7d940a authored by Jérémy Lal's avatar Jérémy Lal

Properly fix test failures by upstream patches

parent 9a515fc7
Description: Skip tests if eslint is missing
Origin: https://github.com/nodejs/node/pull/20372
Last-Update: 2018-04-28
Reviewed-by: Jérémy Lal <kapouer@melix.org>
--- a/test/common/index.js
+++ b/test/common/index.js
@@ -495,7 +495,7 @@
exports.skipIfEslintMissing = function() {
if (!exports.fileExists(
- path.join('..', '..', 'tools', 'node_modules', 'eslint')
+ path.join(__dirname, '..', '..', 'tools', 'node_modules', 'eslint')
)) {
exports.skip('missing ESLint');
}
--- a/test/parallel/test-eslint-alphabetize-errors.js
+++ b/test/parallel/test-eslint-alphabetize-errors.js
@@ -1,6 +1,7 @@
'use strict';
-require('../common');
+const common = require('../common');
+common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/alphabetize-errors');
--- a/test/parallel/test-eslint-buffer-constructor.js
+++ b/test/parallel/test-eslint-buffer-constructor.js
@@ -1,6 +1,7 @@
'use strict';
-require('../common');
+const common = require('../common');
+common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/buffer-constructor');
--- a/test/parallel/test-eslint-documented-errors.js
+++ b/test/parallel/test-eslint-documented-errors.js
@@ -1,6 +1,7 @@
'use strict';
-require('../common');
+const common = require('../common');
+common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/documented-errors');
--- /dev/null
+++ b/test/parallel/test-eslint-eslint-check.js
@@ -0,0 +1,31 @@
+'use strict';
+
+const common = require('../common');
+
+common.skipIfEslintMissing();
+
+const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
+const rule = require('../../tools/eslint-rules/eslint-check');
+
+const message = 'Please add a skipIfEslintMissing() call to allow this ' +
+ 'test to be skipped when Node.js is built ' +
+ 'from a source tarball.';
+
+new RuleTester().run('eslint-check', rule, {
+ valid: [
+ 'foo;',
+ 'require("common")\n' +
+ 'common.skipIfEslintMissing();\n' +
+ 'require("../../tools/node_modules/eslint")'
+ ],
+ invalid: [
+ {
+ code: 'require("common")\n' +
+ 'require("../../tools/node_modules/eslint").RuleTester',
+ errors: [{ message }],
+ output: 'require("common")\n' +
+ 'common.skipIfEslintMissing();\n' +
+ 'require("../../tools/node_modules/eslint").RuleTester'
+ }
+ ]
+});
--- a/test/parallel/test-eslint-inspector-check.js
+++ b/test/parallel/test-eslint-inspector-check.js
@@ -1,12 +1,13 @@
'use strict';
-require('../common');
+const common = require('../common');
+common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/inspector-check');
const message = 'Please add a skipIfInspectorDisabled() call to allow this ' +
- 'test to be skippped when Node is built ' +
+ 'test to be skipped when Node is built ' +
'\'--without-inspector\'.';
new RuleTester().run('inspector-check', rule, {
--- a/test/parallel/test-eslint-require-buffer.js
+++ b/test/parallel/test-eslint-require-buffer.js
@@ -11,7 +11,7 @@
env: { node: true }
});
-const message = "Use const Buffer = require('buffer').Buffer; " +
+const message = "Use const { Buffer } = require('buffer'); " +
'at the beginning of this file';
const useStrict = '\'use strict\';\n\n';
--- /dev/null
+++ b/tools/eslint-rules/eslint-check.js
@@ -0,0 +1,60 @@
+/**
+ * @fileoverview Check that common.skipIfEslintMissing is used if
+ * the eslint module is required.
+ */
+'use strict';
+
+const utils = require('./rules-utils.js');
+
+//------------------------------------------------------------------------------
+// Rule Definition
+//------------------------------------------------------------------------------
+const msg = 'Please add a skipIfEslintMissing() call to allow this test to ' +
+ 'be skipped when Node.js is built from a source tarball.';
+
+module.exports = function(context) {
+ const missingCheckNodes = [];
+ var commonModuleNode = null;
+ var hasEslintCheck = false;
+
+ function testEslintUsage(context, node) {
+ if (utils.isRequired(node, ['../../tools/node_modules/eslint'])) {
+ missingCheckNodes.push(node);
+ }
+
+ if (utils.isCommonModule(node)) {
+ commonModuleNode = node;
+ }
+ }
+
+ function checkMemberExpression(context, node) {
+ if (utils.usesCommonProperty(node, ['skipIfEslintMissing'])) {
+ hasEslintCheck = true;
+ }
+ }
+
+ function reportIfMissing(context) {
+ if (!hasEslintCheck) {
+ missingCheckNodes.forEach((node) => {
+ context.report({
+ node,
+ message: msg,
+ fix: (fixer) => {
+ if (commonModuleNode) {
+ return fixer.insertTextAfter(
+ commonModuleNode,
+ '\ncommon.skipIfEslintMissing();'
+ );
+ }
+ }
+ });
+ });
+ }
+ }
+
+ return {
+ 'CallExpression': (node) => testEslintUsage(context, node),
+ 'MemberExpression': (node) => checkMemberExpression(context, node),
+ 'Program:exit': (node) => reportIfMissing(context, node)
+ };
+};
Description: Fix mips* test failures
Origin: https://github.com/nodejs/node/pull/20377
Last-Update: 2018-04-28
Reviewed-by: Jérémy Lal <kapouer@melix.org>
diff --git a/test/parallel/test-buffer-writedouble.js b/test/parallel/test-buffer-writedouble.js
index 0dc26dbd3b2..8a17d536909 100644
--- a/test/parallel/test-buffer-writedouble.js
+++ b/test/parallel/test-buffer-writedouble.js
@@ -67,10 +67,19 @@ assert.strictEqual(buffer.readDoubleLE(8), -Infinity);
buffer.writeDoubleBE(NaN, 0);
buffer.writeDoubleLE(NaN, 8);
-assert.ok(buffer.equals(new Uint8Array([
- 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7F
-])));
+// JS only knows a single NaN but there exist two platform specific
+// implementations. Therefore, allow both quiet and signalling NaNs.
+if (buffer[1] === 0xF7) {
+ assert.ok(buffer.equals(new Uint8Array([
+ 0x7F, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x7F
+ ])));
+} else {
+ assert.ok(buffer.equals(new Uint8Array([
+ 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7F
+ ])));
+}
assert.ok(Number.isNaN(buffer.readDoubleBE(0)));
assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
diff --git a/test/parallel/test-buffer-writefloat.js b/test/parallel/test-buffer-writefloat.js
index 77dd4793e5e..4c2c7539eaa 100644
--- a/test/parallel/test-buffer-writefloat.js
+++ b/test/parallel/test-buffer-writefloat.js
@@ -50,8 +50,18 @@ assert.strictEqual(buffer.readFloatLE(4), -Infinity);
buffer.writeFloatBE(NaN, 0);
buffer.writeFloatLE(NaN, 4);
-assert.ok(buffer.equals(
- new Uint8Array([ 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7F ])));
+
+// JS only knows a single NaN but there exist two platform specific
+// implementations. Therefore, allow both quiet and signalling NaNs.
+if (buffer[1] === 0xBF) {
+ assert.ok(
+ buffer.equals(new Uint8Array(
+ [ 0x7F, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0x7F ])));
+} else {
+ assert.ok(
+ buffer.equals(new Uint8Array(
+ [ 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7F ])));
+}
assert.ok(Number.isNaN(buffer.readFloatBE(0)));
assert.ok(Number.isNaN(buffer.readFloatLE(4)));
diff --git a/test/parallel/test-cli-node-options.js b/test/parallel/test-cli-node-options.js
index 8eae27b1a2a..2383935f4bb 100644
--- a/test/parallel/test-cli-node-options.js
+++ b/test/parallel/test-cli-node-options.js
@@ -32,7 +32,7 @@ if (!common.isWindows) {
expect('--perf-basic-prof', 'B\n');
}
-if (common.isLinux && ['arm', 'x64', 'mips'].includes(process.arch)) {
+if (common.isLinux && ['arm', 'x64'].includes(process.arch)) {
// PerfJitLogger is only implemented in Linux.
expect('--perf-prof', 'B\n');
}
......@@ -9,4 +9,5 @@ build-doc-using-js-yaml.patch
test_ci_buildd.patch
fix_disable_cctest.patch
benchmark_without_alice.patch
5f2d257e3dbdb9dd6a5ff2552409ff5043c8dbdc.patch
20377.diff
20372.diff
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment