File size: 877 Bytes
b199558
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# Oracle solution: three independent repairs -- the shell variable typo and the
# missing output directory, the dropped final record, and the truncated mean.
set -euo pipefail
cd "$TB_WORK"

cat > build.sh <<'SHEOF'
#!/usr/bin/env bash
set -euo pipefail

OUT=dist
mkdir -p "$OUT" build

python src/gen.py data/input.txt | tee build/gen.log > "$OUT/report.txt"

python -m pytest tests -q
SHEOF

python - <<'PYEOF'
from pathlib import Path

gen = Path("src/gen.py")
text = gen.read_text(encoding="utf-8")
text = text.replace("for line in lines[:-1]:", "for line in lines:")
gen.write_text(text, encoding="utf-8", newline="\n")

stats = Path("src/lib/stats.py")
text = stats.read_text(encoding="utf-8")
text = text.replace("return total // len(values)", "return total / len(values)")
stats.write_text(text, encoding="utf-8", newline="\n")
PYEOF

bash build.sh