summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2015-06-23 22:22:52 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2015-06-23 22:22:52 -0400
commitdd0c8d73aad862770866a65f5494e51620edfc7e (patch)
tree316ecff8aa38cf478ebf53a38097d73035ad32a9 /src/mongo/shell
parentcb23019011883f3c5f0ce0876248e80f05de4581 (diff)
downloadmongo-dd0c8d73aad862770866a65f5494e51620edfc7e.tar.gz
SERVER-18868 Check the exit code of the parallel shell.
By default the await function returned by startParallelShell() asserts that the exit code is zero.
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/servers_misc.js24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/mongo/shell/servers_misc.js b/src/mongo/shell/servers_misc.js
index 46df568dc28..778d1d2ab75 100644
--- a/src/mongo/shell/servers_misc.js
+++ b/src/mongo/shell/servers_misc.js
@@ -217,8 +217,6 @@ SyncCCTest.prototype.tempStart = function( num ){
function startParallelShell( jsCode, port, noConnect ){
- var x;
-
var args = ["mongo"];
if (typeof db == "object") {
@@ -256,9 +254,25 @@ function startParallelShell( jsCode, port, noConnect ){
args.push("--eval", jsCode);
- x = startMongoProgramNoConnect.apply(null, args);
- return function(){
- return waitProgram( x );
+ var pid = startMongoProgramNoConnect.apply(null, args);
+
+ // Returns a function that when called waits for the parallel shell to exit and returns the exit
+ // code of the process. By default an error is thrown if the parallel shell exits with a nonzero
+ // exit code.
+ return function(options) {
+ if (arguments.length > 0) {
+ if (typeof options !== "object") {
+ throw new Error("options must be an object");
+ }
+ if (options === null) {
+ throw new Error("options cannot be null");
+ }
+ }
+ var exitCode = waitProgram(pid);
+ if (arguments.length === 0 || options.checkExitSuccess) {
+ assert.eq(0, exitCode, "encountered an error in the parallel shell");
+ }
+ return exitCode;
};
}