node/test/parallel/test-repl-syntax-error-stack.js
Bryan English cc2a88a2f3 test: use common.fixturesDir almost everywhere
Updating tests to use `common.fixturesDir` whenever possible/reasonable.
Left out things like tests for `path` and `require.resolve`.

PR-URL: https://github.com/nodejs/node/pull/6997
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-06-06 15:28:52 -07:00

27 lines
596 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const repl = require('repl');
let found = false;
process.on('exit', () => {
assert.strictEqual(found, true);
});
common.ArrayStream.prototype.write = function(output) {
if (/var foo bar;/.test(output))
found = true;
};
const putIn = new common.ArrayStream();
repl.start('', putIn);
let file = path.join(common.fixturesDir, 'syntax', 'bad_syntax');
if (common.isWindows)
file = file.replace(/\\/g, '\\\\');
putIn.run(['.clear']);
putIn.run([`require('${file}');`]);