Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
test: fix test-cli-syntax
Browse files Browse the repository at this point in the history
* Removed Chakra-specific messages, they aren't generally necessary
* Updated the shared regex to allow for a single-quote before the word
  boundary.
  • Loading branch information
kfarnung committed Apr 7, 2018
1 parent 2206891 commit 27685b5
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions test/parallel/test-cli-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const syntaxArgs = [
];

// Match on the name of the `Error` but not the message as it is different
// depending on the JavaScript engine.
const syntaxErrorRE = /^SyntaxError: \b/m;
// depending on the JavaScript engine. Some ChakraCore messages start with a
// single quote character so add that as an optional character.
const syntaxErrorRE = /^SyntaxError: '?\b/m;
const notFoundRE = /^Error: Cannot find module/m;

// test good syntax with and without shebang
Expand Down Expand Up @@ -62,10 +63,7 @@ const notFoundRE = /^Error: Cannot find module/m;
assert.strictEqual(stdout, '');

// stderr should have a syntax error message
assert(common.engineSpecificMessage({
v8: syntaxErrorRE,
chakracore: /^SyntaxError: Expected ';'$/m
}).test(stderr), `${syntaxErrorRE} === ${stderr}`);
assert(syntaxErrorRE.test(stderr), `${syntaxErrorRE} === ${stderr}`);

// stderr should include the filename
assert(stderr.startsWith(file), `${stderr} starts with ${file}`);
Expand Down Expand Up @@ -124,10 +122,7 @@ syntaxArgs.forEach(function(args) {
assert.strictEqual(c.stdout, '');

// stderr should have a syntax error message
assert(common.engineSpecificMessage({
v8: syntaxErrorRE,
chakracore: /^SyntaxError: Expected ';'$/m
}).test(c.stderr), `${syntaxErrorRE} === ${c.stderr}`);
assert(syntaxErrorRE.test(c.stderr), `${syntaxErrorRE} === ${c.stderr}`);

assert.strictEqual(c.status, 1);
});
Expand Down

0 comments on commit 27685b5

Please sign in to comment.