summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/js_exceptions.js
diff options
context:
space:
mode:
authorGabriel Russell <gabriel.russell@mongodb.com>2019-03-08 10:52:05 -0500
committerGabriel Russell <gabriel.russell@mongodb.com>2019-03-08 13:59:35 -0500
commit4cc82e953bcfcb355cccf47ba5bb696e7aa7a057 (patch)
tree19aba83f909241b266cf199d43419f187a9d1923 /jstests/noPassthrough/js_exceptions.js
parentbc276668e8d992ff833fdbfd0f4280419d11eda1 (diff)
downloadmongo-4cc82e953bcfcb355cccf47ba5bb696e7aa7a057.tar.gz
SERVER-40042 shore up the tests in js_exceptions.hs
Diffstat (limited to 'jstests/noPassthrough/js_exceptions.js')
-rw-r--r--jstests/noPassthrough/js_exceptions.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/jstests/noPassthrough/js_exceptions.js b/jstests/noPassthrough/js_exceptions.js
index 75786152c09..b94116e7b14 100644
--- a/jstests/noPassthrough/js_exceptions.js
+++ b/jstests/noPassthrough/js_exceptions.js
@@ -77,6 +77,9 @@
recurser(depth, limit, callback);
}
}
+ function assertMatch(m, l) {
+ assert(m.test(l), m + " didn't match \"" + l + "\"");
+ }
tests.forEach(function(t) {
let code = tojson(recurser);
[1, 2, 10].forEach(function(depth) {
@@ -84,30 +87,28 @@
assert.throws(startParallelShell(
code + ";\nrecurser(0," + depth + "," + tojson(t.callback) + ");", false, true));
let output = rawMongoProgramOutput();
- let lines = output.split("\n");
- assert(/MongoDB shell version/.test(lines.shift()));
- assert(/^\s*$/.test(lines.pop()));
- assert(/exiting with code/.test(lines.pop()));
-
- let m = new RegExp("\\\[js\\\] " + t.match + "$");
- assert(m.test(lines.shift()));
+ let lines = output.split(/\s*\n/);
+ assertMatch(/MongoDB shell version/, lines.shift());
+ assertMatch(/^\s*$/, lines.pop());
+ assertMatch(/exiting with code/, lines.pop());
+ assertMatch(new RegExp("\\\[js\\\] " + t.match + "$"), lines.shift());
if (t.stack == true) {
assert.eq(lines.length,
depth + 2); // plus one for the shell and one for the callback
lines.forEach(function(l) {
- assert(/\@\(shell eval\):\d+:\d+/.test(l));
+ assertMatch(/\@\(shell eval\):\d+:\d+/, l);
});
lines.pop();
lines.shift();
lines.forEach(function(l) {
- assert(/recurser\@/.test(l));
+ assertMatch(/recurser\@/, l);
});
} else if (t.stack == false) {
assert.eq(lines.length, 0);
} else if (t.stack == undefined) {
assert.eq(lines.length, 1);
- assert(/undefined/.test(lines.pop()));
+ assertMatch(/undefined/, lines.pop());
}
});
});