#!/bin/sh # Score: 0.5 für grüne Tests auf dem Original, weitere 0.5 wenn die Tests # eingebaute Fehler (Mutationen) erkennen. Letzte Zeile ist JSON. cd /work || { echo '{"score": 0.0, "notes": "kein /work"}'; exit 0; } # Kein Bytecode-Cache: sonst nutzt Python bei gleicher Größe und Zeit veralteten Code der Mutation. export PYTHONDONTWRITEBYTECODE=1 [ -f test_rechner.py ] || { echo '{"score": 0.0, "notes": "test_rechner.py fehlt"}'; exit 0; } python3 -m pytest -q -p no:cacheprovider test_rechner.py >/tmp/orig.log 2>&1 || { echo '{"score": 0.0, "notes": "Tests auf dem Original rot"}'; exit 0; } caught=0; total=0 for m in 's/a + b/a - b/' 's/a - b/a + b/' 's/a \* b/a + b/' 's/return a \/ b/return a \/\/ b/' 's/if b == 0:/if b == 1:/'; do total=$((total+1)) rm -rf /checks/mut && mkdir -p /checks/mut && cp -r /work/. /checks/mut/ && rm -rf /checks/mut/__pycache__ sed -i "$m" /checks/mut/rechner.py if ! (cd /checks/mut && python3 -m pytest -q -p no:cacheprovider test_rechner.py >/dev/null 2>&1); then caught=$((caught+1)) fi done score=$(python3 -c "print(round(0.5 + 0.5*$caught/$total, 2))") echo "{\"score\": $score, \"notes\": \"Mutationen erkannt: $caught von $total\"}"