diff --git a/extractor.cpp b/extractor.cpp index e57901a4b..70ff15ced 100644 --- a/extractor.cpp +++ b/extractor.cpp @@ -122,24 +122,23 @@ int main (int argc, char *argv[]) { } if(!option_variables.count("input")) { - SimpleLogger().Write(logWARNING) << "No input file specified"; SimpleLogger().Write() << visible_options; - return -1; + return 0; } if(1 > requested_num_threads) { SimpleLogger().Write(logWARNING) << "Number of threads must be 1 or larger"; - return -1; + return 1; } if(!boost::filesystem::is_regular_file(input_path)) { SimpleLogger().Write(logWARNING) << "Input file " << input_path.c_str() << " not found!"; - return -1; + return 1; } if(!boost::filesystem::is_regular_file(profile_path)) { SimpleLogger().Write(logWARNING) << "Profile " << profile_path.c_str() << " not found!"; - return -1; + return 1; } SimpleLogger().Write() << "Input file: " << input_path.filename().string(); @@ -205,7 +204,7 @@ int main (int argc, char *argv[]) { if( externalMemory.all_edges_list.empty() ) { SimpleLogger().Write(logWARNING) << "The input data is empty, exiting."; - return -1; + return 1; } externalMemory.PrepareData(output_file_name, restrictionsFileName); @@ -222,13 +221,13 @@ int main (int argc, char *argv[]) { } catch(boost::program_options::too_many_positional_options_error& e) { SimpleLogger().Write(logWARNING) << "Only one input file can be specified"; - return -1; + return 1; } catch(boost::program_options::error& e) { SimpleLogger().Write(logWARNING) << e.what(); - return -1; + return 1; } catch(std::exception & e) { SimpleLogger().Write(logWARNING) << "Unhandled exception: " << e.what(); - return -1; + return 1; } return 0; } diff --git a/features/options/extract/files.feature b/features/options/extract/files.feature index 9b7a05408..3061263e9 100644 --- a/features/options/extract/files.feature +++ b/features/options/extract/files.feature @@ -22,8 +22,7 @@ Feature: osrm-extract command line options: files When I run "osrm-extract --profile {profile} {base}.osm" Then stderr should be empty And it should exit with code 0 - - @todo + Scenario: osrm-extract - Missing input file When I run "osrm-extract over-the-rainbow.osrm --profile {profile}" And stderr should contain "over-the-rainbow.osrm" diff --git a/features/options/extract/help.feature b/features/options/extract/help.feature index 3a40c108d..3215e6aef 100644 --- a/features/options/extract/help.feature +++ b/features/options/extract/help.feature @@ -3,8 +3,7 @@ Feature: osrm-extract command line options: help Background: Given the profile "testbot" - - @todo + Scenario: osrm-extract - Help should be shown when no options are passed When I run "osrm-extract" Then stderr should be empty @@ -45,4 +44,4 @@ Feature: osrm-extract command line options: help And stdout should contain "--profile" And stdout should contain "--threads" And stdout should contain 12 lines - And it should exit with code 0 \ No newline at end of file + And it should exit with code 0 diff --git a/features/options/extract/invalid.feature b/features/options/extract/invalid.feature index 2fd4b7509..3ef302ba0 100644 --- a/features/options/extract/invalid.feature +++ b/features/options/extract/invalid.feature @@ -3,8 +3,7 @@ Feature: osrm-extract command line options: invalid options Background: Given the profile "testbot" - - @todo + Scenario: osrm-extract - Non-existing option When I run "osrm-extract --fly-me-to-the-moon" Then stdout should be empty diff --git a/features/options/prepare/files.feature b/features/options/prepare/files.feature index 25949c52e..fb078d0f1 100644 --- a/features/options/prepare/files.feature +++ b/features/options/prepare/files.feature @@ -17,13 +17,16 @@ Feature: osrm-prepare command line options: files When I run "osrm-prepare {base}.osrm --profile {profile}" Then stderr should be empty And it should exit with code 0 +<<<<<<< Updated upstream +======= + +>>>>>>> Stashed changes Scenario: osrm-prepare - Order of options should not matter When I run "osrm-prepare --profile {profile} {base}.osrm" Then stderr should be empty And it should exit with code 0 - - @todo + Scenario: osrm-prepare - Missing input file When I run "osrm-prepare over-the-rainbow.osrm --profile {profile}" And stderr should contain "over-the-rainbow.osrm" diff --git a/features/options/prepare/help.feature b/features/options/prepare/help.feature index ea7ae1850..49497ae85 100644 --- a/features/options/prepare/help.feature +++ b/features/options/prepare/help.feature @@ -3,8 +3,7 @@ Feature: osrm-prepare command line options: help Background: Given the profile "testbot" - - @todo + Scenario: osrm-prepare - Help should be shown when no options are passed When I run "osrm-prepare" Then stderr should be empty @@ -48,4 +47,4 @@ Feature: osrm-prepare command line options: help And stdout should contain "--profile" And stdout should contain "--threads" And stdout should contain 15 lines - And it should exit with code 0 \ No newline at end of file + And it should exit with code 0 diff --git a/features/options/prepare/invalid.feature b/features/options/prepare/invalid.feature index a17606613..9eb4b757a 100644 --- a/features/options/prepare/invalid.feature +++ b/features/options/prepare/invalid.feature @@ -3,11 +3,10 @@ Feature: osrm-prepare command line options: invalid options Background: Given the profile "testbot" - - @todo + Scenario: osrm-prepare - Non-existing option When I run "osrm-prepare --fly-me-to-the-moon" Then stdout should be empty - And stderr should contain "exception" + And stderr should contain "Exception" And stderr should contain "fly-me-to-the-moon" - And it should exit with code 1 \ No newline at end of file + And it should exit with code 1 diff --git a/prepare.cpp b/prepare.cpp index 5664a5035..145309e97 100644 --- a/prepare.cpp +++ b/prepare.cpp @@ -121,34 +121,34 @@ int main (int argc, char *argv[]) { } if(option_variables.count("help")) { - SimpleLogger().Write() << std::endl << visible_options; + SimpleLogger().Write() << "\n" << visible_options; return 0; } boost::program_options::notify(option_variables); - // if(boost::filesystem::is_regular_file(config_file_path)) { - // SimpleLogger().Write() << "Reading options from: " << config_file_path.c_str(); - // std::string config_str; - // PrepareConfigFile( config_file_path.c_str(), config_str ); - // std::stringstream config_stream( config_str ); - // boost::program_options::store(parse_config_file(config_stream, config_file_options), option_variables); - // boost::program_options::notify(option_variables); - // } - if(!option_variables.count("restrictions")) { - restrictions_path = std::string( input_path.c_str()) + ".restrictions"; + restrictions_path = std::string(input_path.string() + ".restrictions"); } if(!option_variables.count("input")) { - SimpleLogger().Write(logWARNING) << "No input file specified"; - SimpleLogger().Write() << visible_options; - return -1; + SimpleLogger().Write() << "\n" << visible_options; + return 0; + } + + if(!boost::filesystem::is_regular_file(input_path)) { + SimpleLogger().Write(logWARNING) << "Input file " << input_path.string() << " not found!"; + return 1; + } + + if(!boost::filesystem::is_regular_file(profile_path)) { + SimpleLogger().Write(logWARNING) << "Profile " << profile_path.string() << " not found!"; + return 1; } if(1 > requested_num_threads) { SimpleLogger().Write(logWARNING) << "Number of threads must be 1 or larger"; - return -1; + return 1; } SimpleLogger().Write() << "Input file: " << input_path.filename().string(); @@ -183,11 +183,11 @@ int main (int argc, char *argv[]) { std::ifstream in; in.open (input_path.c_str(), std::ifstream::in | std::ifstream::binary); - std::string nodeOut(input_path.c_str()); nodeOut += ".nodes"; - std::string edgeOut(input_path.c_str()); edgeOut += ".edges"; - std::string graphOut(input_path.c_str()); graphOut += ".hsgr"; - std::string rtree_nodes_path(input_path.c_str()); rtree_nodes_path += ".ramIndex"; - std::string rtree_leafs_path(input_path.c_str()); rtree_leafs_path += ".fileIndex"; + std::string nodeOut(input_path.string() + ".nodes"); + std::string edgeOut(input_path.string() + ".edges"); + std::string graphOut(input_path.string() + ".hsgr"); + std::string rtree_nodes_path(input_path.string() + ".ramIndex"); + std::string rtree_leafs_path(input_path.string() + ".fileIndex"); /*** Setup Scripting Environment ***/ @@ -218,7 +218,7 @@ int main (int argc, char *argv[]) { lua_tostring(myLuaState,-1) << " occured in scripting block" << std::endl; - return -1; + return 1; } speedProfile.trafficSignalPenalty = 10*lua_tointeger(myLuaState, -1); @@ -227,7 +227,7 @@ int main (int argc, char *argv[]) { lua_tostring(myLuaState,-1) << " occured in scripting block" << std::endl; - return -1; + return 1; } speedProfile.uTurnPenalty = 10*lua_tointeger(myLuaState, -1); @@ -239,7 +239,7 @@ int main (int argc, char *argv[]) { if( edgeList.empty() ) { SimpleLogger().Write(logWARNING) << "The input data is empty, exiting."; - return -1; + return 1; } SimpleLogger().Write() << @@ -395,7 +395,7 @@ int main (int argc, char *argv[]) { SimpleLogger().Write(logWARNING) << "Failed at edges of node " << node << " of " << numberOfNodes; - return -1; + return 1; } //Serialize edges hsgr_output_stream.write((char*) ¤tEdge, sizeof(StaticGraph::_StrEdge)); @@ -419,14 +419,14 @@ int main (int argc, char *argv[]) { SimpleLogger().Write() << "finished preprocessing"; } catch(boost::program_options::too_many_positional_options_error& e) { SimpleLogger().Write(logWARNING) << "Only one file can be specified"; - return -1; + return 1; } catch(boost::program_options::error& e) { SimpleLogger().Write(logWARNING) << e.what(); - return -1; + return 1; } catch ( const std::exception &e ) { SimpleLogger().Write(logWARNING) << "Exception occured: " << e.what() << std::endl; - return -1; + return 1; } return 0; }