verify.py v0.3: pre-fix missing tests count as failing (upstream semantics), record all cmd lists
Browse files- scripts/verify.py +13 -10
scripts/verify.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
-
"""PatchBench row verification + context expansion harness (v0.
|
| 2 |
|
| 3 |
For each candidate row:
|
| 4 |
1. clone the repo at base_commit
|
| 5 |
2. apply test_patch -> run rebuild_cmds -> run test_cmds (twice) -> parse per-test results
|
| 6 |
-
verify: every FAIL_TO_PASS test FAILS
|
|
|
|
| 7 |
3. apply gold_patch -> rebuild -> run test_cmds (twice) -> parse
|
| 8 |
verify: every FAIL_TO_PASS PASSES and every PASS_TO_PASS still PASSES in both runs
|
| 9 |
4. slice a 500-1500 line context window around the buggy files
|
|
@@ -11,7 +12,8 @@ For each candidate row:
|
|
| 11 |
|
| 12 |
Native (non-Docker) reproduction of the upstream env: toolchain dirs are prepended
|
| 13 |
to PATH per language, and the upstream /testbed convention is rewritten to the
|
| 14 |
-
local checkout path.
|
|
|
|
| 15 |
|
| 16 |
Usage (inside a job with the right language toolchain image):
|
| 17 |
python verify.py --lang go --file pilot/candidates/go.jsonl --limit 6
|
|
@@ -24,7 +26,6 @@ CMD_TIMEOUT_S = 2100
|
|
| 24 |
GIT_TIMEOUT_S = 900
|
| 25 |
MAX_CONTEXT_LINES = 1500
|
| 26 |
|
| 27 |
-
# toolchain dirs that login-shell /etc/profile resets away, or that images install off-PATH
|
| 28 |
LANG_PATH_PREPEND = {
|
| 29 |
"go": ["/usr/local/go/bin"],
|
| 30 |
"rust": ["/usr/local/cargo/bin", "/usr/local/rustup/bin"],
|
|
@@ -99,12 +100,15 @@ def run_tests(row, repo_dir):
|
|
| 99 |
return parser(out), out[-3000:]
|
| 100 |
|
| 101 |
|
| 102 |
-
def grade(tests, want, expect):
|
|
|
|
|
|
|
| 103 |
missing, wrong = [], []
|
| 104 |
for t in want:
|
| 105 |
s = tests.get(t)
|
| 106 |
if s is None:
|
| 107 |
-
|
|
|
|
| 108 |
elif s != expect:
|
| 109 |
wrong.append((t, s))
|
| 110 |
return (not missing and not wrong), {"missing": len(missing), "wrong": wrong[:10],
|
|
@@ -178,13 +182,12 @@ def verify_row(row, lang):
|
|
| 178 |
rec["error"] = f"checkout failed: {out[-500:]}"
|
| 179 |
return rec
|
| 180 |
|
| 181 |
-
# native env fixes: toolchain PATH + /testbed convention
|
| 182 |
os.environ["PATH"] = ":".join(LANG_PATH_PREPEND.get(lang, [])) + ":" + os.environ["PATH"]
|
| 183 |
def tb(cmds):
|
| 184 |
return [c.replace(TESTBED, repo_dir) for c in (cmds or [])]
|
| 185 |
row = {**row, "test_cmds": tb(row["test_cmds"]), "rebuild_cmds": tb(row.get("rebuild_cmds")),
|
| 186 |
"print_cmds": tb(row.get("print_cmds"))}
|
| 187 |
-
rec["test_cmds"] = row["test_cmds"]
|
| 188 |
rec["timing"]["setup"] = round(time.time() - t0, 1)
|
| 189 |
|
| 190 |
# ---- PRE-FIX (twice) ----
|
|
@@ -199,8 +202,8 @@ def verify_row(row, lang):
|
|
| 199 |
tests, tail = run_tests(row, repo_dir)
|
| 200 |
pre_runs.append((tests, tail))
|
| 201 |
rec["timing"][f"pre_test_{i}"] = round(time.time() - s, 1)
|
| 202 |
-
pre_detail = grade(pre_runs[0][0], row["fail_to_pass"], "fail")[1]
|
| 203 |
-
f2p_ok_pre = all(grade(t, row["fail_to_pass"], "fail")[0] for t, _ in pre_runs)
|
| 204 |
rec["f2p_pre_ok"], rec["pre_detail"] = f2p_ok_pre, pre_detail
|
| 205 |
|
| 206 |
# ---- POST-FIX (twice) ----
|
|
|
|
| 1 |
+
"""PatchBench row verification + context expansion harness (v0.3).
|
| 2 |
|
| 3 |
For each candidate row:
|
| 4 |
1. clone the repo at base_commit
|
| 5 |
2. apply test_patch -> run rebuild_cmds -> run test_cmds (twice) -> parse per-test results
|
| 6 |
+
verify: every FAIL_TO_PASS test FAILS pre-fix in both runs (a test that does not
|
| 7 |
+
exist because its package fails to build counts as failing -- upstream semantics)
|
| 8 |
3. apply gold_patch -> rebuild -> run test_cmds (twice) -> parse
|
| 9 |
verify: every FAIL_TO_PASS PASSES and every PASS_TO_PASS still PASSES in both runs
|
| 10 |
4. slice a 500-1500 line context window around the buggy files
|
|
|
|
| 12 |
|
| 13 |
Native (non-Docker) reproduction of the upstream env: toolchain dirs are prepended
|
| 14 |
to PATH per language, and the upstream /testbed convention is rewritten to the
|
| 15 |
+
local checkout path. Toolchain image must satisfy the repos' go.mod/tool requirements
|
| 16 |
+
(use golang:1.25+ for Go rows).
|
| 17 |
|
| 18 |
Usage (inside a job with the right language toolchain image):
|
| 19 |
python verify.py --lang go --file pilot/candidates/go.jsonl --limit 6
|
|
|
|
| 26 |
GIT_TIMEOUT_S = 900
|
| 27 |
MAX_CONTEXT_LINES = 1500
|
| 28 |
|
|
|
|
| 29 |
LANG_PATH_PREPEND = {
|
| 30 |
"go": ["/usr/local/go/bin"],
|
| 31 |
"rust": ["/usr/local/cargo/bin", "/usr/local/rustup/bin"],
|
|
|
|
| 100 |
return parser(out), out[-3000:]
|
| 101 |
|
| 102 |
|
| 103 |
+
def grade(tests, want, expect, allow_missing=False):
|
| 104 |
+
"""allow_missing=True for pre-fix 'fail' checks: a test that never ran (build
|
| 105 |
+
failure in its package) is not passing, which is what upstream means by fail."""
|
| 106 |
missing, wrong = [], []
|
| 107 |
for t in want:
|
| 108 |
s = tests.get(t)
|
| 109 |
if s is None:
|
| 110 |
+
if not allow_missing:
|
| 111 |
+
missing.append(t)
|
| 112 |
elif s != expect:
|
| 113 |
wrong.append((t, s))
|
| 114 |
return (not missing and not wrong), {"missing": len(missing), "wrong": wrong[:10],
|
|
|
|
| 182 |
rec["error"] = f"checkout failed: {out[-500:]}"
|
| 183 |
return rec
|
| 184 |
|
|
|
|
| 185 |
os.environ["PATH"] = ":".join(LANG_PATH_PREPEND.get(lang, [])) + ":" + os.environ["PATH"]
|
| 186 |
def tb(cmds):
|
| 187 |
return [c.replace(TESTBED, repo_dir) for c in (cmds or [])]
|
| 188 |
row = {**row, "test_cmds": tb(row["test_cmds"]), "rebuild_cmds": tb(row.get("rebuild_cmds")),
|
| 189 |
"print_cmds": tb(row.get("print_cmds"))}
|
| 190 |
+
rec["test_cmds"], rec["rebuild_cmds"], rec["print_cmds"] = row["test_cmds"], row["rebuild_cmds"], row["print_cmds"]
|
| 191 |
rec["timing"]["setup"] = round(time.time() - t0, 1)
|
| 192 |
|
| 193 |
# ---- PRE-FIX (twice) ----
|
|
|
|
| 202 |
tests, tail = run_tests(row, repo_dir)
|
| 203 |
pre_runs.append((tests, tail))
|
| 204 |
rec["timing"][f"pre_test_{i}"] = round(time.time() - s, 1)
|
| 205 |
+
pre_detail = grade(pre_runs[0][0], row["fail_to_pass"], "fail", allow_missing=True)[1]
|
| 206 |
+
f2p_ok_pre = all(grade(t, row["fail_to_pass"], "fail", allow_missing=True)[0] for t, _ in pre_runs)
|
| 207 |
rec["f2p_pre_ok"], rec["pre_detail"] = f2p_ok_pre, pre_detail
|
| 208 |
|
| 209 |
# ---- POST-FIX (twice) ----
|