Skip to content

Commit 0797b0c

Browse files
committed
test(eval): cover typed JSON judges through CLI
1 parent 97fc52a commit 0797b0c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/eval_run_e2e.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ eval {
6969
judges {
7070
judge "deliverable exists" { exec "test -f $CATALOG/worker/DONE" }
7171
judge "deliverable content" { file "worker/DONE" has "resolved" }
72+
judge "typed values" {
73+
json "worker/values.json" field "text" is "hello"
74+
json "worker/values.json" field "ok" is #true
75+
json "worker/values.json" field "count" is 7
76+
}
7277
judge "one native bus root" {
7378
exec "test \"$ST_ROOT\" = \"$CATALOG\" && test \"$(cat $CATALOG/sup/ST_ROOT)\" = \"$CATALOG\" && test \"$(cat $CATALOG/worker/ST_ROOT)\" = \"$CATALOG\""
7479
}
@@ -89,6 +94,7 @@ sleep 0.4
8994
mkdir -p "$CATALOG/worker"
9095
printf '%s\n' "$ST_ROOT" > "$CATALOG/worker/ST_ROOT"
9196
echo "resolved by t.worker" > "$CATALOG/worker/DONE"
97+
printf '%s\n' '{"text":"hello","ok":true,"count":7}' > "$CATALOG/worker/values.json"
9298
st2 message send t.sup --root "$ST_ROOT" --as t.worker -m "worker done" >/dev/null 2>&1
9399
sleep 60
94100
"#,
@@ -135,7 +141,7 @@ sleep 60
135141
assert!(stdout.contains("VERDICT: PASS"), "expected PASS:\n--stdout--\n{stdout}\n--stderr--\n{stderr}");
136142
assert!(out.status.success(), "exit non-zero:\n{stdout}\n{stderr}");
137143
// Both judges (bash + declarative) passed.
138-
assert!(stdout.contains("SCORE: 4 PASS / 0 FAIL"), "expected 4/0:\n{stdout}");
144+
assert!(stdout.contains("SCORE: 5 PASS / 0 FAIL"), "expected 5/0:\n{stdout}");
139145

140146
let json_out = Command::new(bin)
141147
.args(["eval", "--json"])
@@ -154,7 +160,8 @@ sleep 60
154160

155161
let fail_cell = cell.join("fail.kdl");
156162
let fail_spec = std::fs::read_to_string(cell.join("cell.kdl")).unwrap()
157-
.replace("test -f $CATALOG/worker/DONE", "test -f $CATALOG/worker/NOPE");
163+
.replace("test -f $CATALOG/worker/DONE", "test -f $CATALOG/worker/NOPE")
164+
.replace("field \"count\" is 7", "field \"count\" is 8");
158165
std::fs::write(&fail_cell, fail_spec).unwrap();
159166
let fail_out = Command::new(bin)
160167
.args(["eval", "--json"])
@@ -166,6 +173,7 @@ sleep 60
166173
assert!(!fail_out.status.success());
167174
let fail_json: serde_json::Value = serde_json::from_slice(&fail_out.stdout).expect("failed eval report");
168175
assert_eq!(fail_json["judges"][0]["passed"], false);
176+
assert!(fail_json["judges"].as_array().unwrap().iter().any(|j| j["detail"].as_str().unwrap_or("").contains("count")));
169177
assert!(!String::from_utf8_lossy(&fail_out.stdout).contains("=="));
170178

171179
let invalid = Command::new(bin)

0 commit comments

Comments
 (0)