diff options
author | Ilya Zverev <zverik@textual.ru> | 2015-07-03 11:30:36 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:54:03 +0300 |
commit | e6dd2783a9023c2321b2f91c0ed95da99549a8ff (patch) | |
tree | 88c8f7c77880fd843cfc3638575e2077732623e4 /testing | |
parent | b15e566b41a272b5a76b67ede12e643004963d2d (diff) |
[testing] Fix names and other stuff by comments
Diffstat (limited to 'testing')
-rw-r--r-- | testing/testing.hpp | 16 | ||||
-rw-r--r-- | testing/testingmain.cpp | 46 |
2 files changed, 26 insertions, 36 deletions
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; |