From 8e33c359baab5e7b46fda9fbd2c3eda789d9d706 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 4 Jun 2018 13:10:09 +0000 Subject: [PATCH 1/2] test: make url-parse-invalid-input engine agnostic test-url-parse-invalid-input checks the message of an error that is generated by the JavaScript engine. Error messages that change in the underlying JavaScript engine should not be breaking changes in Node.js and therefore should not cause tests to fail. Remove the message check and replace it with a check of the type of the Error object along with the absence of a `code` property. (If a `code` property were present, it would indicate that the error was coming from Node.js rather than the JavaScript engine.) This also makes this test usable without modification in the ChakraCore fork of Node.js. --- test/parallel/test-url-parse-invalid-input.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js index 0f113862c7b3c4..4f08ff3d9f2cac 100644 --- a/test/parallel/test-url-parse-invalid-input.js +++ b/test/parallel/test-url-parse-invalid-input.js @@ -26,4 +26,15 @@ const url = require('url'); }); assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, - /^URIError: URI malformed$/); + (e) => { + // The error should be a URIError. + if (!(e instanceof URIError)) + return false; + + // The error should be from the JS engine and not from Node.js. + // JS engine errors do not have the `code` property. + if (e.code !== undefined) + return false; + + return true; + }); From 5e4165252f1203b607187586e6a236b1f6749097 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 6 Jun 2018 21:18:07 -0700 Subject: [PATCH 2/2] squash! --- test/parallel/test-url-parse-invalid-input.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js index 4f08ff3d9f2cac..aad8462bfc2633 100644 --- a/test/parallel/test-url-parse-invalid-input.js +++ b/test/parallel/test-url-parse-invalid-input.js @@ -33,8 +33,5 @@ assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, // The error should be from the JS engine and not from Node.js. // JS engine errors do not have the `code` property. - if (e.code !== undefined) - return false; - - return true; + return e.code === undefined; });