diff options
-rw-r--r-- | integration_tests/osrm_test_tools.cpp | 9 | ||||
-rw-r--r-- | platform/platform.hpp | 4 | ||||
-rw-r--r-- | testing/testing.hpp | 16 | ||||
-rw-r--r-- | testing/testingmain.cpp | 46 |
4 files changed, 33 insertions, 42 deletions
diff --git a/integration_tests/osrm_test_tools.cpp b/integration_tests/osrm_test_tools.cpp index 0ab9784cc4..7449daf8ca 100644 --- a/integration_tests/osrm_test_tools.cpp +++ b/integration_tests/osrm_test_tools.cpp @@ -124,10 +124,11 @@ namespace integration { // Setting stored paths from testingmain.cpp Platform & pl = GetPlatform(); - if (!testingOptions.dataPath.empty()) - pl.SetWritableDir(testingOptions.dataPath); - if (!testingOptions.resourcePath.empty()) - pl.AddOptionalPath(testingOptions.resourcePath); + CommandLineOptions const & options = GetTestingOptions(); + if (options.dataPath) + pl.SetWritableDirForTests(options.dataPath); + if (options.resourcePath) + pl.AddOptionalPath(options.resourcePath); vector<LocalCountryFile> localFiles; platform::FindAllLocalMaps(localFiles); diff --git a/platform/platform.hpp b/platform/platform.hpp index ef9d3e583b..98de3e437f 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -89,11 +89,11 @@ public: static bool IsFileExistsByFullPath(string const & filePath); /// @return void - void AddOptionalPath(string const &path) {m_optionalDir = path;} + void AddOptionalPath(string const & path) { m_optionalDir = path; } /// @return always the same writable dir for current user with slash at the end string WritableDir() const { return m_writableDir; } /// @return set writable dir — use for testing and linux stuff only - void SetWritableDir(string const &path) { m_writableDir = path; } + void SetWritableDirForTests(string const & path) { m_writableDir = path; } /// @return full path to file in user's writable directory string WritablePathForFile(string const & file) const { return WritableDir() + file; } /// @return full path to indexes directory for country file. diff --git a/testing/testing.hpp b/testing/testing.hpp index cd6d27dc57..ef34611b89 100644 --- a/testing/testing.hpp +++ b/testing/testing.hpp @@ -27,12 +27,20 @@ namespace my } } -struct TestingOptions +// This struct contains parsed command line options. It may contain pointers to argc contents. +struct CommandLineOptions { - string dataPath; - string resourcePath; + CommandLineOptions() : filterRegExp(nullptr), suppressRegExp(nullptr), + dataPath(nullptr), resourcePath(nullptr), help(false) {} + + char const * filterRegExp; + char const * suppressRegExp; + char const * dataPath; + char const * resourcePath; + + bool help; }; -extern TestingOptions testingOptions; +CommandLineOptions const & GetTestingOptions(); #define TEST(X, msg) { if (X) {} else { \ ::my::OnTestFailed(SRC(), ::my::impl::Message("TEST("#X")", ::my::impl::Message msg));}} diff --git a/testing/testingmain.cpp b/testing/testingmain.cpp index d494be9957..c57b7e50c5 100644 --- a/testing/testingmain.cpp +++ b/testing/testingmain.cpp @@ -28,7 +28,12 @@ #endif #endif -TestingOptions testingOptions; +CommandLineOptions testingOptions; + +CommandLineOptions const & GetTestingOptions() +{ + return testingOptions; +} namespace { @@ -48,23 +53,6 @@ enum Status STATUS_BROKEN_FRAMEWORK = 5, }; -// This struct contains parsed command line options. It may contain pointers to argc contents. -struct CommandLineOptions -{ - CommandLineOptions() : filterRegExp(nullptr), suppressRegExp(nullptr), help(false) {} - - // Non-owning ptr. - char const * filterRegExp; - - // Non-owning ptr. - char const * suppressRegExp; - - char const * dataPath; - char const * resourcePath; - - bool help; -}; - void DisplayOption(ostream & os, char const * option, char const * description) { os << " " << setw(kOptionFieldWidth) << left << option << " " << description << endl; @@ -128,26 +116,20 @@ int main(int argc, char * argv[]) vector<bool> testResults; int numFailedTests = 0; - CommandLineOptions options; - ParseOptions(argc, argv, options); - if (options.help) + ParseOptions(argc, argv, testingOptions); + if (testingOptions.help) { Usage(argv[0]); return STATUS_SUCCESS; } regexp::RegExpT filterRegExp; - if (options.filterRegExp) - regexp::Create(options.filterRegExp, filterRegExp); + if (testingOptions.filterRegExp) + regexp::Create(testingOptions.filterRegExp, filterRegExp); regexp::RegExpT suppressRegExp; - if (options.suppressRegExp) - regexp::Create(options.suppressRegExp, suppressRegExp); - - if (options.resourcePath) - testingOptions.resourcePath = options.resourcePath; - if (options.dataPath) - testingOptions.dataPath = options.dataPath; + if (testingOptions.suppressRegExp) + regexp::Create(testingOptions.suppressRegExp, suppressRegExp); for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; pTest = pTest->m_pNext) { @@ -166,9 +148,9 @@ int main(int argc, char * argv[]) int iTest = 0; for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; ++iTest, pTest = pTest->m_pNext) { - if (options.filterRegExp && !regexp::Matches(testNames[iTest], filterRegExp)) + if (testingOptions.filterRegExp && !regexp::Matches(testNames[iTest], filterRegExp)) continue; - if (options.suppressRegExp && regexp::Matches(testNames[iTest], suppressRegExp)) + if (testingOptions.suppressRegExp && regexp::Matches(testNames[iTest], suppressRegExp)) continue; cerr << "Running " << testNames[iTest] << endl; |