Download tasks/data/forward/20tab__bvh-python.b7e0058/tests/test.sh from Lego-X/ProgramGen: direct link, hf CLI and curl.
- Browser
- Download file 3.03 kB
-
https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/forward/20tab__bvh-python.b7e0058/tests/test.sh
- Command line
-
hf download hf://datasets/Lego-X/ProgramGen/tasks/data/forward/20tab__bvh-python.b7e0058/tests/test.sh
-
curl -L -o test.sh https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/forward/20tab__bvh-python.b7e0058/tests/test.sh
3.03 kB
| # Harbor verifier: inject the hidden suite, run it, and score against the | |
| # generation-time measured test count. Every path emits reward + metrics. | |
| set -uo pipefail | |
| mkdir -p /logs/verifier | |
| cd "${WORKDIR:-/workspace/repo}" | |
| OUT_FILE=/logs/verifier/test-output.log | |
| : > "$OUT_FILE" | |
| EXPECTED=$(python3 -c 'import json; d=json.load(open("/tests/tests.json")); print(int(d.get("expected_test_count") or d.get("measured_test_count") or 0))' 2>/dev/null || echo 0) | |
| grade_and_exit() { | |
| local phase="$1" reason="$2" rc="$3" | |
| python3 /tests/grader.py --output "$OUT_FILE" --return-code "$rc" --expected-count "$EXPECTED" --phase "$phase" --reason "$reason" >/dev/null | |
| cat /logs/verifier/reward.txt | |
| exit 0 | |
| } | |
| python3 - /tests/test_patch.diff <<'PY' 2>/dev/null || true | |
| import os, sys | |
| try: | |
| lines = open(sys.argv[1], encoding='utf-8', errors='replace').read().splitlines() | |
| except OSError: | |
| lines = [] | |
| i = 0 | |
| while i < len(lines): | |
| line = lines[i] | |
| if line.startswith('diff --git a/'): | |
| rest = line[len('diff --git a/'):] | |
| split = rest.find(' b/') | |
| path = rest[:split] if split != -1 else None | |
| is_new = False | |
| j = i + 1 | |
| while j < len(lines) and not lines[j].startswith('diff --git '): | |
| is_new = is_new or lines[j].startswith('new file mode') | |
| j += 1 | |
| if is_new and path and os.path.isfile(path): | |
| try: | |
| os.remove(path) | |
| except OSError: | |
| pass | |
| i = j | |
| continue | |
| i += 1 | |
| PY | |
| PATCH_APPLIED=0 | |
| if git apply --check /tests/test_patch.diff 2>/dev/null; then | |
| git apply /tests/test_patch.diff 2>/dev/null && PATCH_APPLIED=1 | |
| elif git apply --reverse --check /tests/test_patch.diff 2>/dev/null; then | |
| PATCH_APPLIED=1 | |
| elif patch --dry-run -p1 < /tests/test_patch.diff >/dev/null 2>&1; then | |
| patch -p1 < /tests/test_patch.diff >/dev/null 2>&1 && PATCH_APPLIED=1 | |
| fi | |
| if [ "$PATCH_APPLIED" -ne 1 ]; then | |
| echo 'hidden test patch could not be applied' > "$OUT_FILE" | |
| grade_and_exit patch hidden-test-patch-failed 1 | |
| fi | |
| if ! { | |
| SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 PDM_BUILD_SCM_VERSION=0.0.0 POETRY_DYNAMIC_VERSIONING_BYPASS=0.0.0 UV_DYNAMIC_VERSIONING_BYPASS=0.0.0 SETUPTOOLS_SCM_WRITE_TO_SOURCE=1 python3 -m pip install -e "$PWD" --no-build-isolation --no-deps; | |
| } >/logs/verifier/pip-install.log 2>&1; then | |
| cat /logs/verifier/pip-install.log > "$OUT_FILE" | |
| grade_and_exit install python-install-contract-failed 86 | |
| fi | |
| if [ -d /tests/test_assets ]; then | |
| find /tests/test_assets -mindepth 1 -maxdepth 1 -exec cp -a -t "$PWD" -- {} + | |
| fi | |
| timeout --signal=TERM --kill-after=30s 3300s python3 -m pytest -vv --continue-on-collection-errors -o addopts= tests/test_bvh.py 2>&1 | tail -c 1500000 > "$OUT_FILE" | |
| RC=${PIPESTATUS[0]} | |
| cat "$OUT_FILE" | |
| if [ "$RC" -eq 124 ] || [ "$RC" -eq 137 ]; then | |
| grade_and_exit tests verifier-timeout "$RC" | |
| fi | |
| python3 /tests/grader.py --output "$OUT_FILE" --return-code "$RC" --expected-count "$EXPECTED" --phase tests >/dev/null | |
| cat /logs/verifier/reward.txt | |