The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test: reject incomplete JSON-RPC enumeration in the full product runner
Steven Enamakel175a4fc56f56
diff --git a/scripts/__tests__/rust-product-enumeration.test.mjs b/scripts/__tests__/rust-product-enumeration.test.mjsnew file mode 100644index 0000000000..4908b4b582--- /dev/null+++ b/scripts/__tests__/rust-product-enumeration.test.mjs@@ -0,0 +1,76 @@+import assert from "node:assert/strict";+import { spawnSync } from "node:child_process";+import {+ mkdtempSync,+ readFileSync,+ rmSync,+ writeFileSync,+ existsSync,+} from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import test from "node:test";++const source = readFileSync(+ new URL("../test-rust-with-mock.sh", import.meta.url),+ "utf8",+);+const start = source.indexOf("run_json_rpc_e2e() {");+const end = source.indexOf("\n}\n", start);+assert.ok(start >= 0 && end > start);+const body = source.slice(start, end + 3);++for (const [description, listing, code] of [+ ["failed", "", 101],+ ["partial", "scenario_a: test\n", 101],+ ["empty", "0 tests, 0 benchmarks\n", 0],+ ["complete", "scenario_a: test\n", 0],+]) {+ test(`the full product runner checks ${description} JSON-RPC enumeration`, () => {+ const root = mkdtempSync(join(tmpdir(), "product-enumeration-"));+ try {+ const cargo = join(root, "cargo");+ writeFileSync(+ cargo,+ '#!/bin/bash\nif [[ " $* " == *" --list "* ]]; then\n printf "%s" "$TEST_LISTING"\n exit "$TEST_LIST_CODE"\nfi\nprintf "%s" "$*" > "$TEST_RAN"\n',+ { mode: 0o755 },+ );+ const ran = join(root, "ran");+ const result = spawnSync(+ "bash",+ [+ "-c",+ 'set -euo pipefail\ncargo_test() { "$TEST_CARGO" "$@"; }\n' ++ body ++ "\nrun_json_rpc_e2e\n",+ ],+ {+ encoding: "utf8",+ env: {+ ...process.env,+ TEST_CARGO: cargo,+ TEST_LISTING: listing,+ TEST_LIST_CODE: String(code),+ TEST_RAN: ran,+ },+ },+ );+ if (description === "complete") {+ assert.equal(result.status, 0, result.stdout + result.stderr);+ assert.match(+ readFileSync(ran, "utf8"),+ /--test json_rpc_e2e scenario_a -- --exact --test-threads=1/,+ );+ } else {+ assert.notEqual(result.status, 0, result.stdout + result.stderr);+ assert.equal(+ existsSync(ran),+ false,+ "an incomplete list must run no cases",+ );+ }+ } finally {+ rmSync(root, { recursive: true, force: true });+ }+ });+}diff --git a/scripts/test-rust-with-mock.sh b/scripts/test-rust-with-mock.shindex df9c0bb58e..22986b9149 100755--- a/scripts/test-rust-with-mock.sh+++ b/scripts/test-rust-with-mock.sh@@ -236,11 +236,20 @@ run_json_rpc_e2e() {# The JSON-RPC E2E binary intentionally changes process-global environment# and runtime configuration. Run each case in a fresh test process so a# provider route persisted by one scenario cannot affect another one.+ local listing test_names test_name+ if ! listing="$(cargo_test --test json_rpc_e2e -- --list)"; then+ echo "[test-rust-with-mock] ERROR: could not enumerate json_rpc_e2e tests; refusing an empty or partial list." >&2+ return 1+ fi+ test_names="$(printf '%s\n' "$listing" | sed -n 's/: test$//p')"+ if [ -z "$test_names" ]; then+ echo "[test-rust-with-mock] ERROR: json_rpc_e2e enumeration returned no tests." >&2+ return 1+ fiwhile IFS= read -r test_name; do- [ -n "$test_name" ] || continueecho "[test-rust-with-mock] JSON-RPC E2E test: ${test_name}"- cargo_test --test json_rpc_e2e "$test_name" -- --test-threads=1 "$@"- done < <(cargo_test --test json_rpc_e2e -- --list | sed -n 's/: test$//p')+ cargo_test --test json_rpc_e2e "$test_name" -- --exact --test-threads=1 "$@"+ done <<<"$test_names"}run_build_only_reaper_test() {