summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-07-09 13:40:01 +0200
committerRich Trott <rtrott@gmail.com>2019-07-17 20:57:43 -0700
commitf9388580bd4169a7e3e3d049ca86a7b1e614ee55 (patch)
tree47931c5b5b0d397651a49bdfc1acfb7f22d1d040
parent195239a5f697214a86ca8b8eeefa1947ce409385 (diff)
downloadandroid-node-v8-f9388580bd4169a7e3e3d049ca86a7b1e614ee55.tar.gz
android-node-v8-f9388580bd4169a7e3e3d049ca86a7b1e614ee55.tar.bz2
android-node-v8-f9388580bd4169a7e3e3d049ca86a7b1e614ee55.zip
test: make repl tests more resilient
This refactors two tests to ignore line numbers in stack traces. That way changed line numbers do not have any impact on the test outcome anymore. PR-URL: https://github.com/nodejs/node/pull/28608 Fixes: https://github.com/nodejs/node/issues/28546 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
-rw-r--r--test/parallel/test-repl-pretty-custom-stack.js12
-rw-r--r--test/parallel/test-repl-pretty-stack.js18
2 files changed, 19 insertions, 11 deletions
diff --git a/test/parallel/test-repl-pretty-custom-stack.js b/test/parallel/test-repl-pretty-custom-stack.js
index b65287c5f5..0d2ada134f 100644
--- a/test/parallel/test-repl-pretty-custom-stack.js
+++ b/test/parallel/test-repl-pretty-custom-stack.js
@@ -5,6 +5,7 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const repl = require('repl');
+const stackRegExp = /repl:[0-9]+:[0-9]+/g;
function run({ command, expected }) {
let accum = '';
@@ -23,7 +24,10 @@ function run({ command, expected }) {
});
r.write(`${command}\n`);
- assert.strictEqual(accum, expected);
+ assert.strictEqual(
+ accum.replace(stackRegExp, 'repl:*:*'),
+ expected.replace(stackRegExp, 'repl:*:*')
+ );
r.close();
}
@@ -44,8 +48,8 @@ const tests = [
{
// test .load for a file that throws
command: `.load ${fixtures.path('repl-pretty-stack.js')}`,
- expected: 'Thrown:\nError: Whoops!--->\nrepl:9:24--->\nd (repl:12:3)' +
- '--->\nc (repl:9:3)--->\nb (repl:6:3)--->\na (repl:3:3)\n'
+ expected: 'Thrown:\nError: Whoops!--->\nrepl:*:*--->\nd (repl:*:*)' +
+ '--->\nc (repl:*:*)--->\nb (repl:*:*)--->\na (repl:*:*)\n'
},
{
command: 'let x y;',
@@ -63,7 +67,7 @@ const tests = [
// test anonymous IIFE
{
command: '(function() { throw new Error(\'Whoops!\'); })()',
- expected: 'Thrown:\nError: Whoops!--->\nrepl:1:21\n'
+ expected: 'Thrown:\nError: Whoops!--->\nrepl:*:*\n'
}
];
diff --git a/test/parallel/test-repl-pretty-stack.js b/test/parallel/test-repl-pretty-stack.js
index 8beb48fd68..9f307c4f43 100644
--- a/test/parallel/test-repl-pretty-stack.js
+++ b/test/parallel/test-repl-pretty-stack.js
@@ -5,6 +5,7 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const repl = require('repl');
+const stackRegExp = /(at .*repl:)[0-9]+:[0-9]+/g;
function run({ command, expected, ...extraREPLOptions }) {
let accum = '';
@@ -24,7 +25,10 @@ function run({ command, expected, ...extraREPLOptions }) {
});
r.write(`${command}\n`);
- assert.strictEqual(accum, expected);
+ assert.strictEqual(
+ accum.replace(stackRegExp, '$1*:*'),
+ expected.replace(stackRegExp, '$1*:*')
+ );
r.close();
}
@@ -32,9 +36,9 @@ const tests = [
{
// Test .load for a file that throws.
command: `.load ${fixtures.path('repl-pretty-stack.js')}`,
- expected: 'Thrown:\nError: Whoops!\n at repl:9:24\n' +
- ' at d (repl:12:3)\n at c (repl:9:3)\n' +
- ' at b (repl:6:3)\n at a (repl:3:3)\n'
+ expected: 'Thrown:\nError: Whoops!\n at repl:*:*\n' +
+ ' at d (repl:*:*)\n at c (repl:*:*)\n' +
+ ' at b (repl:*:*)\n at a (repl:*:*)\n'
},
{
command: 'let x y;',
@@ -48,12 +52,12 @@ const tests = [
{
command: '(() => { const err = Error(\'Whoops!\'); ' +
'err.foo = \'bar\'; throw err; })()',
- expected: "Thrown:\nError: Whoops!\n at repl:1:22 {\n foo: 'bar'\n}\n",
+ expected: "Thrown:\nError: Whoops!\n at repl:*:* {\n foo: 'bar'\n}\n",
},
{
command: '(() => { const err = Error(\'Whoops!\'); ' +
'err.foo = \'bar\'; throw err; })()',
- expected: 'Thrown:\nError: Whoops!\n at repl:1:22 {\n foo: ' +
+ expected: 'Thrown:\nError: Whoops!\n at repl:*:* {\n foo: ' +
"\u001b[32m'bar'\u001b[39m\n}\n",
useColors: true
},
@@ -64,7 +68,7 @@ const tests = [
// Test anonymous IIFE.
{
command: '(function() { throw new Error(\'Whoops!\'); })()',
- expected: 'Thrown:\nError: Whoops!\n at repl:1:21\n'
+ expected: 'Thrown:\nError: Whoops!\n at repl:*:*\n'
}
];