MCPcopy Create free account
hub / github.com/GJDuck/e9patch / main

Function main

test/regtest/regtest.cpp:202–260  ·  view source on GitHub ↗

* Entry. */

Source from the content-addressed store, hash-verified

200 * Entry.
201 */
202int main(int argc, char **argv)
203{
204 std::string options;
205 for (int i = 1; i < argc; i++)
206 {
207 if (i > 1)
208 options += ' ';
209 options += argv[i];
210 }
211
212 option_tty = (isatty(STDOUT_FILENO) && isatty(STDERR_FILENO));
213 struct dirent **tests = nullptr;
214 int n = scandir(".", &tests, isTest, alphasort);
215 if (n < 0)
216 error("failed to scan current directory: %s", strerror(errno));
217 size_t passed = 0, failed = 0, total = 0;
218 std::vector<std::string> fails;
219 for (int i = 0; i < n; i++)
220 {
221 total++;
222 if (runTest(tests[i], options))
223 passed++;
224 else
225 {
226 fails.push_back(tests[i]->d_name);
227 failed++;
228 }
229 }
230
231 const char *highlight = "", *off = "";
232 if (option_tty)
233 {
234 if (passed == total)
235 highlight = GREEN, off = WHITE;
236 else if (passed == 0)
237 highlight = RED, off = WHITE;
238 else
239 highlight = YELLOW, off = WHITE;
240 }
241 putchar('\n');
242 printf("PASSED = %s%.2f%%%s (%zu/%zu); FAILED = %s%.2f%%%s (%zu/%zu)\n\n",
243 highlight, (double)passed / (double)total * 100.0, off, passed, total,
244 highlight, (double)failed / (double)total * 100.0, off, failed, total);
245 if (fails.size() > 0)
246 {
247 printf("FAILED = {");
248 bool prev = false;
249 for (const auto &fail: fails)
250 {
251 if (prev)
252 putchar(',');
253 prev = true;
254 printf("%s", fail.c_str());
255 }
256 printf("}\n\n");
257 }
258
259 return 0;

Callers

nothing calls this directly

Calls 7

isattyFunction · 0.85
errorFunction · 0.85
strerrorFunction · 0.85
runTestFunction · 0.85
putcharFunction · 0.85
printfFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected