MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / UnitTestMain

Function UnitTestMain

tests/testutils/UnitTest.cpp:69–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67int unit_test_failures{ 0 };
68
69int UnitTestMain(int argc, const char ** argv)
70{
71
72#if !defined(NDEBUG) && defined(_WIN32)
73 // Disable the 'assert' dialog box in debug mode.
74 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
75#endif
76
77 bool printHelp = false;
78 bool stopOnFirstError = false;
79
80 // Note that empty strings mean to run all the unit tests.
81 std::string filter, utestGroupAllowed, utestNameAllowed;
82
83 ArgParse ap;
84 ap.options("\nCommand line arguments:\n",
85 "--help", &printHelp, "Print help message",
86 "--stop_on_error", &stopOnFirstError, "Stop on the first error",
87 "--run_only %s", &filter, "Run only some unit tests\n"
88 "\tex: --run_only \"FileRules/clone\"\n"
89 "\tex: --run_only FileRules i.e. \"FileRules/*\"\n"
90 "\tex: --run_only /clone i.e. \"*/clone\"\n",
91 nullptr);
92
93 if (ap.parse(argc, argv) < 0)
94 {
95 std::cerr << ap.geterror() << std::endl;
96 ap.usage();
97 return 1;
98 }
99
100 if (printHelp)
101 {
102 ap.usage();
103 return 1;
104 }
105
106 if (!filter.empty())
107 {
108 const std::vector<std::string> results = StringUtils::Split(filter, '/');
109 if (results.size() >= 1)
110 {
111 utestGroupAllowed = StringUtils::Lower(StringUtils::Trim(results[0]));
112 if (results.size() >= 2)
113 {
114 utestNameAllowed = StringUtils::Lower(StringUtils::Trim(results[1]));
115
116 if (results.size() >= 3)
117 {
118 std::cerr << "Invalid value for the argument '--run_only'." << std::endl;
119 ap.usage();
120 return 1;
121 }
122 }
123 }
124 }
125
126

Callers 1

mainFunction · 0.85

Calls 11

SplitFunction · 0.85
LowerFunction · 0.85
optionsMethod · 0.80
usageMethod · 0.80
TrimFunction · 0.50
parseMethod · 0.45
geterrorMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected