-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·55 lines (45 loc) · 1.21 KB
/
test.sh
File metadata and controls
executable file
·55 lines (45 loc) · 1.21 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
54
55
#! /bin/zsh
# Getting the valid and invalid directories
if [ $# -ne 1 ]; then
echo "Usage: $0 <directory>"
exit 1
fi
MAIN=$1
DIRNAME=$(dirname "$MAIN")
FILENAME=${$(basename "$MAIN")%.*}
valid_dir=$MAIN/valid
invalid_dir=$MAIN/invalid
# Build the compiler
echo "building the compiler.."
make &>/dev/null
# Testing all inputs
echo "Testing for valid tests.\n"
for input in "$valid_dir"/*; do
expected_result=${input##*return_}
expected_result=${expected_result%%.*}
output=$(./build.sh "$input")
result=$(echo "$output" | tail -n 1 | sed 's/^[ \t]*//;s/[ \t]*$//')
# result=output | tail -n 1
echo "Testing $input"
if [ "$result" = "$expected_result" ]; then
echo "PASS: $input"
else
echo "FAIL: $input"
fi
echo "Expected output: $expected_result"
echo "Actual output: $result \n"
done
echo "\nTesting for invalid tests.\n"
for input in "$invalid_dir"/*; do
output=$(./build.sh "$input") &>/dev/null
echo "Testing $input"
if echo "$output" | grep -q "error"; then
echo "PASS: $input \n"
else
echo "FAIL: $input"
echo "Expected Error message: $output\n"
fi
done
# Clean up
echo "\ncleaning up.."
make clean &>/dev/null