Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor: fix for shell exit code on bad hostname, plus update tests

  • Loading branch information...
commit 2fedd80c4dda59cf2779a947f033cf730ba41901 1 parent e815aac
Mike Dirolf authored
Showing with 7 additions and 7 deletions.
  1. +3 −4 buildscripts/test_shell.py
  2. +4 −3 shell/dbshell.cpp
View
7 buildscripts/test_shell.py
@@ -28,7 +28,6 @@
"""Exit codes for MongoDB."""
BADOPTS = 2
-BADHOST = 14
NOCONNECT = 255
"""Path to the mongo shell executable to be tested."""
@@ -53,7 +52,7 @@ def test_help(self):
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 @@ def test_positionals(self):
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 @@ def test_positionals(self):
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__)
View
7 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;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.