node/test/parallel/test-repl-syntax-error-stack.js
Rich Trott c68e35258c test: make test-repl-syntax-error-stack agnostic
Revise test so that it does not depend on behavior specific to V8.

PR-URL: https://github.com/nodejs/node/pull/16272
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-11-11 17:40:58 -08:00

32 lines
921 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const repl = require('repl');
let found = false;
process.on('exit', () => {
assert.strictEqual(found, true);
});
common.ArrayStream.prototype.write = function(output) {
// Matching only on a minimal piece of the stack because the string will vary
// greatly depending on the JavaScript engine. V8 includes `;` because it
// displays the line of code (`var foo bar;`) that is causing a problem.
// ChakraCore does not display the line of code but includes `;` in the phrase
// `Expected ';' `.
if (/;/.test(output))
found = true;
};
const putIn = new common.ArrayStream();
repl.start('', putIn);
let file = fixtures.path('syntax', 'bad_syntax');
if (common.isWindows)
file = file.replace(/\\/g, '\\\\');
putIn.run(['.clear']);
putIn.run([`require('${file}');`]);