summaryrefslogtreecommitdiff
path: root/test/abort/test-abort-backtrace.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-08-24 23:18:58 -0700
committerRich Trott <rtrott@gmail.com>2017-08-26 16:30:31 -0700
commitdf57d8bdccdc94e4d8327fc769d93dbadf8772c7 (patch)
tree47f8fcb390ef73fe625f5ebc447b33ae41201ecc /test/abort/test-abort-backtrace.js
parentacdf5585510c4d6ec3f7ef9c44965ae068fd0b72 (diff)
downloadandroid-node-v8-df57d8bdccdc94e4d8327fc769d93dbadf8772c7.tar.gz
android-node-v8-df57d8bdccdc94e4d8327fc769d93dbadf8772c7.tar.bz2
android-node-v8-df57d8bdccdc94e4d8327fc769d93dbadf8772c7.zip
test: improve test-abort-backtrace
Improve error message by showing output when frames output does not meet expectations. Since we can't tell at runtime if we have the correct libc for backtraces, allow an empty backtrace and run the test on all platforms. PR-URL: https://github.com/nodejs/node/pull/14013 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'test/abort/test-abort-backtrace.js')
-rw-r--r--test/abort/test-abort-backtrace.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/test/abort/test-abort-backtrace.js b/test/abort/test-abort-backtrace.js
index dd10817168..6d3121e538 100644
--- a/test/abort/test-abort-backtrace.js
+++ b/test/abort/test-abort-backtrace.js
@@ -10,13 +10,19 @@ if (process.argv[2] === 'child') {
process.abort();
} else {
const child = cp.spawnSync(`${process.execPath}`, [`${__filename}`, 'child']);
- const frames =
- child.stderr.toString().trimRight().split('\n').map((s) => s.trim());
+ const stderr = child.stderr.toString();
assert.strictEqual(child.stdout.toString(), '');
- assert.ok(frames.length > 0);
- // All frames should start with a frame number.
- assert.ok(frames.every((frame, index) => frame.startsWith(`${index + 1}:`)));
- // At least some of the frames should include the binary name.
- assert.ok(frames.some((frame) => frame.includes(`[${process.execPath}]`)));
+ // stderr will be empty for systems that don't support backtraces.
+ if (stderr !== '') {
+ const frames = stderr.trimRight().split('\n').map((s) => s.trim());
+
+ if (!frames.every((frame, index) => frame.startsWith(`${index + 1}:`))) {
+ assert.fail(`Each frame should start with a frame number:\n${stderr}`);
+ }
+
+ if (!frames.some((frame) => frame.includes(`[${process.execPath}]`))) {
+ assert.fail(`Some frames should include the binary name:\n${stderr}`);
+ }
+ }
}