MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / validateBook

Function validateBook

engine/Evaluator/Validate.cpp:219–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219ValidationSummary validateBook(const std::string& bookDir, GameState& gs, bool verbose)
220{
221 ValidationSummary summary;
222 EvalState& state = static_cast<EvalState&>(gs);
223 auto files = listFiles(bookDir, ".md");
224
225 for (auto& file : files)
226 {
227 std::string content = readAll(file);
228 if (content.empty())
229 continue;
230
231 auto blocks = extractCodeBlocks(content);
232 // Extract just filename for display
233 std::string fname = file;
234 size_t sep = fname.find_last_of("/\\");
235 if (sep != std::string::npos)
236 fname = fname.substr(sep + 1);
237
238 for (int i = 0; i < (int)blocks.size(); i++)
239 {
240 std::string src = fname + ":" + std::to_string(blocks[i].lineNumber);
241 auto res = tryEval(src, i, blocks[i].code, blocks[i].lang, state);
242
243 if (res.status == "pass")
244 summary.passed++;
245 else if (res.status == "fail")
246 summary.failed++;
247 else
248 summary.skipped++;
249
250 if (verbose || res.status == "fail")
251 summary.results.push_back(res);
252 }
253 }
254 return summary;
255}
256
257// Simple JSON string array extraction - handles nested brackets in strings
258static std::string extractJsonStringArray(const std::string& json, const std::string& key)

Callers 2

ValidateBookMethod · 0.85
test_validate.cppFile · 0.85

Calls 6

listFilesFunction · 0.85
readAllFunction · 0.85
extractCodeBlocksFunction · 0.85
tryEvalFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected