AdithyaSK's picture
AdithyaSK HF Staff
Add files using upload-large-folder tool
f4a5c87 verified
Raw History Blame Contribute Delete
1.54 kB
#!/bin/bash
# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the
# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.
M=/var/lib/mimo
CWD=/testbed
V=/logs/verifier
mkdir -p "$V"
BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }
cd "$CWD" || exit 1
if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi
# the agent's change against the base, so its own commits count too
git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"
git reset -q
if ! (
while IFS= read -r tf; do
[ -z "$tf" ] && continue
if git cat-file -e $BASE:"$tf" 2>/dev/null; then
git checkout $BASE -- "$tf" 2>/dev/null || true
else
git rm -f --cached "$tf" >/dev/null 2>&1 || true
rm -f "$tf"
fi
done <<'EOF_RESET_TEST_FILES'
eval_test.go
mimo_build_env.tar.gz.b64
mimo_test_command.sh
EOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi
if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then
cat "$V/apply.log" >&2
echo "the hidden tests could not be applied (testbed problem, not scored)" >&2
exit 1
fi
timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1
RC=$?
tail -c 12000 "$V/test_output.log"
if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi
echo "test command exited $RC"