This repository was archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathtest_js.sh
More file actions
executable file
·53 lines (48 loc) · 1.34 KB
/
test_js.sh
File metadata and controls
executable file
·53 lines (48 loc) · 1.34 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Test is all examples in the .org files are working with lean.js
LEAN_JS=lean.js
RUN_LEAN_JS=run_lean_js.sh
if [ $# -ne 1 ]; then
echo "Usage: test.sh [file]"
exit 1
fi
if [ ! -f ${LEAN_JS} ] ; then
wget https://leanprover.github.io/lean.js/${LEAN_JS}
fi
if [ ! -f ${RUN_LEAN_JS} ] ; then
wget https://raw.githubusercontent.com/leanprover/lean.js/master/${RUN_LEAN_JS}
chmod +x ${RUN_LEAN_JS}
fi
ulimit -s unlimited
f=$1
i=0
in_code_block=0
lastbegin=0
linenum=0
echo "-- testing $f"
while read -r line; do
linenum=$((linenum + 1))
if [[ $line =~ ^#\+BEGIN_SRC\ lean ]]; then
in_code_block=1
i=$((i + 1))
lastbegin=$linenum
rm -f $f.$i.lean
echo -E "import standard" >> $f.$i.lean
elif [[ $line =~ ^#\+END_SRC ]]; then
if [[ $in_code_block -eq 1 ]]; then
if ./${RUN_LEAN_JS} ./${LEAN_JS} $f.$i.lean > $f.$i.produced.out; then
echo "code fragment #$i worked"
else
echo "ERROR executing $f.$i.lean, for in_code_block block starting at $lastbegin, produced output:"
cat $f.$i.produced.out
exit 1
fi
fi
in_code_block=0
elif [[ $in_code_block -eq 1 ]]; then
echo -E "$line" >> $f.$i.lean
fi
done < $f
rm -f $f.*.produced.out
rm -f $f.*.lean
exit 0