summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dirolf <mike@10gen.com>2009-09-25 15:51:11 -0400
committerMike Dirolf <mike@10gen.com>2009-09-25 15:51:11 -0400
commit2fedd80c4dda59cf2779a947f033cf730ba41901 (patch)
tree014abd6c743658b81ca96d1fb4183aa7898ef4d8
parente815aac1acf8bd7d34b317e86c84cbd0aa711f70 (diff)
downloadmongo-2fedd80c4dda59cf2779a947f033cf730ba41901.tar.gz
minor: fix for shell exit code on bad hostname, plus update tests
-rw-r--r--buildscripts/test_shell.py7
-rw-r--r--shell/dbshell.cpp7
2 files changed, 7 insertions, 7 deletions
diff --git a/buildscripts/test_shell.py b/buildscripts/test_shell.py
index 2d25c3d111a..eb6a032a9e4 100644
--- a/buildscripts/test_shell.py
+++ b/buildscripts/test_shell.py
@@ -28,7 +28,6 @@ import os
"""Exit codes for MongoDB."""
BADOPTS = 2
-BADHOST = 14
NOCONNECT = 255
"""Path to the mongo shell executable to be tested."""
@@ -53,7 +52,7 @@ class TestShell(unittest.TestCase):
out = mongo_h.communicate()
self.assertEqual(out, mongo_help.communicate())
- self.assert_(out[0].startswith("usage:"))
+ self.assert_("usage:" in out[0])
self.assertEqual(0, mongo_h.returncode)
self.assertEqual(0, mongo_help.returncode)
@@ -164,7 +163,7 @@ class TestShell(unittest.TestCase):
out = mongo.communicate()
self.assert_("url: " + test in out[0])
self.assert_("connecting to: " + test in out[0])
- self.assertEqual(BADHOST, mongo.returncode)
+ self.assertEqual(NOCONNECT, mongo.returncode)
mongo = self.open_mongo([non_exist_js, test, test_txt])
out = mongo.communicate()
@@ -176,7 +175,7 @@ class TestShell(unittest.TestCase):
out = mongo.communicate()
self.assert_("url: " + non_exist_txt in out[0])
self.assert_("connecting to: " + non_exist_txt in out[0])
- self.assertEqual(BADHOST, mongo.returncode)
+ self.assertEqual(NOCONNECT, mongo.returncode)
def test_multiple_files(self):
dirname = os.path.dirname(__file__)
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp
index 633ffcd23d8..cb94310af9a 100644
--- a/shell/dbshell.cpp
+++ b/shell/dbshell.cpp
@@ -123,13 +123,13 @@ inline void setupSignals() {}
string fixHost( string url , string host , string port ){
//cout << "fixHost url: " << url << " host: " << host << " port: " << port << endl;
-
+
if ( host.size() == 0 && port.size() == 0 ){
if ( url.find( "/" ) == string::npos ){
// check for ips
if ( url.find( "." ) != string::npos )
return url + "/test";
-
+
if ( url.find( ":" ) != string::npos &&
isdigit( url[url.find(":")+1] ) )
return url + "/test";
@@ -441,7 +441,7 @@ int _main(int argc, char* argv[]) {
string cmd = line;
if ( cmd.find( " " ) > 0 )
cmd = cmd.substr( 0 , cmd.find( " " ) );
-
+
if ( cmd.find( "\"" ) == string::npos ){
scope->exec( (string)"__iscmd__ = shellHelper[\"" + cmd + "\"];" , "(shellhelp1)" , false , true , true );
if ( scope->getBoolean( "__iscmd__" ) ){
@@ -478,6 +478,7 @@ int main(int argc, char* argv[]) {
}
catch ( mongo::DBException& e ){
cerr << "exception: " << e.what() << endl;
+ return -1;
}
}