| 323 | } |
| 324 | |
| 325 | int Runner::runCommandLine(int argc, const char* argv[]) const { |
| 326 | // typedef std::deque<JSONCPP_STRING> TestNames; |
| 327 | Runner subrunner; |
| 328 | for (int index = 1; index < argc; ++index) { |
| 329 | JSONCPP_STRING opt = argv[index]; |
| 330 | if (opt == "--list-tests") { |
| 331 | listTests(); |
| 332 | return 0; |
| 333 | } else if (opt == "--test-auto") { |
| 334 | preventDialogOnCrash(); |
| 335 | } else if (opt == "--test") { |
| 336 | ++index; |
| 337 | if (index < argc) { |
| 338 | unsigned int testNameIndex; |
| 339 | if (testIndex(argv[index], testNameIndex)) { |
| 340 | subrunner.add(tests_[testNameIndex]); |
| 341 | } else { |
| 342 | fprintf(stderr, "Test '%s' does not exist!\n", argv[index]); |
| 343 | return 2; |
| 344 | } |
| 345 | } else { |
| 346 | printUsage(argv[0]); |
| 347 | return 2; |
| 348 | } |
| 349 | } else { |
| 350 | printUsage(argv[0]); |
| 351 | return 2; |
| 352 | } |
| 353 | } |
| 354 | bool succeeded; |
| 355 | if (subrunner.testCount() > 0) { |
| 356 | succeeded = subrunner.runAllTest(subrunner.testCount() > 1); |
| 357 | } else { |
| 358 | succeeded = runAllTest(true); |
| 359 | } |
| 360 | return succeeded ? 0 : 1; |
| 361 | } |
| 362 | |
| 363 | #if defined(_MSC_VER) && defined(_DEBUG) |
| 364 | // Hook MSVCRT assertions to prevent dialog from appearing |
no test coverage detected