From 0a9fa79c63ae63758081a4cc3202030b54041607 Mon Sep 17 00:00:00 2001 From: Kyle Farnung Date: Sat, 21 Apr 2018 12:05:43 -0700 Subject: [PATCH] src,test: fix V8 engine issues * Remove gyp include that no longer exists upstream * Conditionally include `v8-debug.h` * Fix test failures for V8 engine * Remove status entries for missing tests PR-URL: https://github.com/nodejs/node-chakracore/pull/519 Reviewed-By: Seth Brenith Reviewed-By: Jimmy Thomson --- node.gyp | 7 ------ src/node.cc | 2 ++ test/common/index.js | 35 +++++++++++++++++++++++------- test/es-module/es-module.status | 1 - test/parallel/parallel.status | 1 - test/parallel/test-assert.js | 6 ++--- test/parallel/test-util-inspect.js | 6 +---- 7 files changed, 32 insertions(+), 26 deletions(-) diff --git a/node.gyp b/node.gyp index a55fc36a7f1..7a20ae9964b 100644 --- a/node.gyp +++ b/node.gyp @@ -1030,13 +1030,6 @@ 'include_dirs': [ 'deps/v8/include' ], - 'conditions' : [ - ['node_use_v8_platform=="true"', { - 'dependencies': [ - 'deps/v8/src/v8.gyp:v8_libplatform', - ], - }], - ] }], ['node_engine=="chakracore"', { 'include_dirs': [ diff --git a/src/node.cc b/src/node.cc index ddac7aab43c..90016f09a5e 100644 --- a/src/node.cc +++ b/src/node.cc @@ -64,7 +64,9 @@ #if NODE_USE_V8_PLATFORM #include "libplatform/libplatform.h" #endif // NODE_USE_V8_PLATFORM +#ifdef NODE_ENGINE_CHAKRACORE #include "v8-debug.h" +#endif #include "v8-profiler.h" #include "zlib.h" diff --git a/test/common/index.js b/test/common/index.js index d6cb69c3678..347fc82d382 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -605,16 +605,22 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) { }; function areAllValuesStringEqual(obj) { - let exemplar; - for (const key of Object.keys(obj)) { - if (exemplar === undefined) { - exemplar = obj[key].toString(); - } else if (exemplar !== obj[key].toString()) { - return false; + try { + let exemplar; + for (const key of Object.keys(obj)) { + if (exemplar === undefined) { + exemplar = obj[key].toString(); + } else if (exemplar !== obj[key].toString()) { + return false; + } } - } - return true; + return true; + } catch (e) { + // If any exceptions are thrown just return false. They are likely due to + // symbols being used in the message object. + return false; + } } exports.engineSpecificMessage = function(messageObject) { @@ -635,6 +641,19 @@ exports.engineSpecificMessage = function(messageObject) { return undefined; }; +exports.requireInternalV8 = function() { + if (exports.isChakraEngine) { + return { + previewMapIterator: function() { return []; }, + previewSetIterator: function() { return []; }, + previewWeakMap: function() { return []; }, + previewWeakSet: function() { return []; } + }; + } else { + return require('internal/v8'); + } +}; + exports.busyLoop = function busyLoop(time) { const startTime = Timer.now(); const stopTime = startTime + time; diff --git a/test/es-module/es-module.status b/test/es-module/es-module.status index 055157d9012..b6e797652df 100644 --- a/test/es-module/es-module.status +++ b/test/es-module/es-module.status @@ -23,7 +23,6 @@ test-esm-loader-modulemap : SKIP test-esm-main-lookup : SKIP test-esm-named-exports : SKIP test-esm-namespace : SKIP -test-esm-ok : SKIP test-esm-preserve-symlinks : SKIP test-esm-preserve-symlinks-not-found : SKIP test-esm-preserve-symlinks-not-found-plain : SKIP diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 93d97337f5e..766da600fff 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -88,7 +88,6 @@ test-util : SKIP test-util-format-shared-arraybuffer : SKIP test-util-inspect-proxy : SKIP test-v8-serdes : SKIP -test-v8-serdes-sharedarraybuffer : SKIP test-vm-attributes-property-not-on-sandbox : SKIP test-vm-cached-data : SKIP test-vm-codegen : SKIP diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 10aa9412e83..a01bb0b884d 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -636,8 +636,7 @@ common.expectsError( type: assert.AssertionError, generatedMessage: !common.isChakraEngine, message: engineSpecificAssert( - `The expression evaluated to a falsy value:${EOL}${EOL} ` + - `assert.ok(null)${EOL}`, + `assert.ok(null)${EOL}`, 'null == true') } ); @@ -648,8 +647,7 @@ common.expectsError( type: assert.AssertionError, generatedMessage: !common.isChakraEngine, message: engineSpecificAssert( - `The expression evaluated to a falsy value:${EOL}${EOL} ` + - `assert(typeof 123 === 'string')${EOL}`, + `assert(typeof 123 === 'string')${EOL}`, 'false == true') } ); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 04fcbdc2760..b2bab8b7fea 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -26,10 +26,7 @@ const assert = require('assert'); const JSStream = process.binding('js_stream').JSStream; const util = require('util'); const vm = require('vm'); -if (!common.isChakraEngine) { - // eslint-disable-next-line no-unused-vars - const { previewMapIterator } = require('internal/v8'); -} +const { previewMapIterator } = common.requireInternalV8(); assert.strictEqual(util.inspect(1), '1'); assert.strictEqual(util.inspect(false), 'false'); @@ -460,7 +457,6 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324'); if (!common.isChakraEngine) { const map = new Map(); map.set(1, 2); - // eslint-disable-next-line no-undef const vals = previewMapIterator(map.entries()); const valsOutput = []; for (const o of vals) {