Step 223: evaluation runner CLI
This commit is contained in:
@@ -1151,6 +1151,9 @@ target_include_directories(step221_test PRIVATE src)
|
||||
|
||||
add_executable(step222_test tests/step222_test.cpp)
|
||||
target_include_directories(step222_test PRIVATE src)
|
||||
|
||||
add_executable(step223_test tests/step223_test.cpp)
|
||||
target_include_directories(step223_test PRIVATE src)
|
||||
add_executable(step213_test tests/step213_test.cpp)
|
||||
target_include_directories(step213_test PRIVATE src)
|
||||
target_link_libraries(step213_test PRIVATE nlohmann_json::nlohmann_json)
|
||||
@@ -1261,4 +1264,8 @@ target_link_libraries(orchestrator PRIVATE
|
||||
tree_sitter_rust
|
||||
tree_sitter_go)
|
||||
|
||||
add_executable(whetstone_eval src/eval_main.cpp)
|
||||
target_include_directories(whetstone_eval PRIVATE src)
|
||||
target_link_libraries(whetstone_eval PRIVATE nlohmann_json::nlohmann_json)
|
||||
|
||||
# Step 12: Dear ImGui shell scaffolding created (main.cpp exists but not built due to dependencies)
|
||||
|
||||
40
editor/src/eval_main.cpp
Normal file
40
editor/src/eval_main.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "EvalHarness.h"
|
||||
|
||||
static std::string getArg(int argc, char** argv, const std::string& key) {
|
||||
for (int i = 1; i < argc - 1; ++i) {
|
||||
if (argv[i] == key) return argv[i + 1];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
std::string tasksDir = getArg(argc, argv, "--tasks");
|
||||
std::string tracePath = getArg(argc, argv, "--trace");
|
||||
std::string reportPath = getArg(argc, argv, "--report");
|
||||
|
||||
if (tasksDir.empty()) {
|
||||
std::cerr << "Usage: whetstone_eval --tasks <dir> [--trace file.jsonl] [--report out.json]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto tasks = EvalRunner::loadTasksFromDir(tasksDir);
|
||||
std::vector<Trace> traces;
|
||||
if (!tracePath.empty()) {
|
||||
traces = EvalRunner::loadTracesJsonl(tracePath);
|
||||
}
|
||||
|
||||
json report = EvalRunner::run(tasks, traces);
|
||||
if (!reportPath.empty()) {
|
||||
std::ofstream out(reportPath);
|
||||
if (!out.is_open()) {
|
||||
std::cerr << "Failed to write report: " << reportPath << "\n";
|
||||
return 2;
|
||||
}
|
||||
out << report.dump(2);
|
||||
} else {
|
||||
std::cout << report.dump(2) << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
25
editor/tests/step223_test.cpp
Normal file
25
editor/tests/step223_test.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// Step 223: Evaluation runner CLI wiring.
|
||||
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
static std::string readFile(const std::string& path) {
|
||||
std::ifstream f(path);
|
||||
if (!f.is_open()) return {};
|
||||
return std::string((std::istreambuf_iterator<char>(f)),
|
||||
std::istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
static void assertContains(const std::string& text, const std::string& needle) {
|
||||
assert(text.find(needle) != std::string::npos);
|
||||
}
|
||||
|
||||
int main() {
|
||||
const std::string mainSrc = readFile("src/eval_main.cpp");
|
||||
assertContains(mainSrc, "whetstone_eval");
|
||||
assertContains(mainSrc, "--tasks");
|
||||
assertContains(mainSrc, "EvalRunner::loadTasksFromDir");
|
||||
printf("step223_test: all assertions passed\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user