| 307 | } |
| 308 | |
| 309 | int Runner::runCommandLine(int argc, const char* argv[]) const { |
| 310 | // typedef std::deque<JSONCPP_STRING> TestNames; |
| 311 | Runner subrunner; |
| 312 | for (int index = 1; index < argc; ++index) { |
| 313 | JSONCPP_STRING opt = argv[index]; |
| 314 | if (opt == "--list-tests") { |
| 315 | listTests(); |
| 316 | return 0; |
| 317 | } else if (opt == "--test-auto") { |
| 318 | preventDialogOnCrash(); |
| 319 | } else if (opt == "--test") { |
| 320 | ++index; |
| 321 | if (index < argc) { |
| 322 | size_t testNameIndex; |
| 323 | if (testIndex(argv[index], testNameIndex)) { |
| 324 | subrunner.add(tests_[testNameIndex]); |
| 325 | } else { |
| 326 | fprintf(stderr, "Test '%s' does not exist!\n", argv[index]); |
| 327 | return 2; |
| 328 | } |
| 329 | } else { |
| 330 | printUsage(argv[0]); |
| 331 | return 2; |
| 332 | } |
| 333 | } else { |
| 334 | printUsage(argv[0]); |
| 335 | return 2; |
| 336 | } |
| 337 | } |
| 338 | bool succeeded; |
| 339 | if (subrunner.testCount() > 0) { |
| 340 | succeeded = subrunner.runAllTest(subrunner.testCount() > 1); |
| 341 | } else { |
| 342 | succeeded = runAllTest(true); |
| 343 | } |
| 344 | return succeeded ? 0 : 1; |
| 345 | } |
| 346 | |
| 347 | #if defined(_MSC_VER) && defined(_DEBUG) |
| 348 | // Hook MSVCRT assertions to prevent dialog from appearing |
no test coverage detected