forked from leanprover-community/repl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·53 lines (43 loc) · 1.5 KB
/
test.sh
File metadata and controls
executable file
·53 lines (43 loc) · 1.5 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
# Define the paths
IN_DIR="test"
EXPECTED_DIR="test"
lake build
# ignore locale to ensure test `bla` runs before `bla2`
export LC_COLLATE=C
# Iterate over each .in file in the test directory
for infile in $IN_DIR/*.in; do
# Extract the base filename without the extension
base=$(basename "$infile" .in)
# Define the path for the expected output file
expectedfile="$EXPECTED_DIR/$base.expected.out"
# Check if the expected output file exists
if [[ ! -f $expectedfile ]]; then
echo "Expected output file $expectedfile does not exist. Skipping $infile."
continue
fi
# Run the command and store its output in a temporary file
tmpfile=$(mktemp)
tmpfile2=$(mktemp)
./.lake/build/bin/repl < "$infile" | jq 'del(.commandState)' > "$tmpfile2" 2>&1
SUM=$(jq '.tactics | length' $tmpfile2 | jq -s 'add')
if [[ $SUM != "0" ]]; then
jq 'del(.tactics[].extracted)' $tmpfile2 > "$tmpfile" 2>&1
else
cat $tmpfile2 > $tmpfile 2>&1
fi
# Compare the output with the expected output
if diff <(cat $tmpfile | jq --sort-keys) <(cat $expectedfile | jq --sort-keys); then
echo "$base: PASSED"
# Remove the temporary file
rm "$tmpfile"
else
echo "$base: FAILED"
# Rename the temporary file instead of removing it
mv "$tmpfile" "${expectedfile/.expected.out/.produced.out}"
exit 1
fi
done
# Run the Mathlib tests
cp lean-toolchain test/Mathlib/
cd test/Mathlib/ && ./test.sh