| 358 | } |
| 359 | |
| 360 | ValidationSummary validateRef(const std::string& refDir, GameState& gs, bool verbose) |
| 361 | { |
| 362 | ValidationSummary summary; |
| 363 | EvalState& state = static_cast<EvalState&>(gs); |
| 364 | auto files = listFiles(refDir, ".json"); |
| 365 | |
| 366 | for (auto& file : files) |
| 367 | { |
| 368 | std::string content = readAll(file); |
| 369 | if (content.empty()) |
| 370 | continue; |
| 371 | |
| 372 | std::string fname = extractJsonString(content, "name"); |
| 373 | if (fname.empty()) |
| 374 | { |
| 375 | size_t sep = file.find_last_of("/\\"); |
| 376 | fname = sep != std::string::npos ? file.substr(sep + 1) : file; |
| 377 | } |
| 378 | |
| 379 | std::string exArr = extractJsonStringArray(content, "examples"); |
| 380 | auto examples = parseStringArray(exArr); |
| 381 | |
| 382 | for (int i = 0; i < (int)examples.size(); i++) |
| 383 | { |
| 384 | std::string src = fname; |
| 385 | auto res = tryEval(src, i, examples[i], "sqf", state); |
| 386 | |
| 387 | if (res.status == "pass") |
| 388 | summary.passed++; |
| 389 | else if (res.status == "fail") |
| 390 | summary.failed++; |
| 391 | else |
| 392 | summary.skipped++; |
| 393 | |
| 394 | if (verbose || res.status != "pass") |
| 395 | summary.results.push_back(res); |
| 396 | } |
| 397 | } |
| 398 | return summary; |
| 399 | } |
no test coverage detected