~pixelherodev/zyg

ref: 0205ad9e8cb840d3a1905618b799e27db41d42ea zyg/test.bash -rw-r--r-- 1.1 KiB
0205ad9eNoam Preil tmp 2 months ago
                                                                                
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
56
57
58
59
60
#!/usr/bin/env bash

# THIS IS TO BE RUN IN `Makefile`

IFS=$'\n'

delext() {
  name=$(echo "$1" | sed 's/\..*//' | sed 's/^test\///')
  echo $name
}

getignore() {
   for line in $(cat < test/failing); do
     if [ "$1" == "$(echo $line | sed 's/:.*//')" ]; then
       # failure reason
       echo "$(echo $line | sed 's/.*://')"
       return
     fi
   done
   echo suceed
}

inbroken() {
   for line in $(cat < test/broken); do
     if [ "$1" == "$line" ]; then
       echo 1
       return
     fi
   done
   echo 0
}

testfiles=$(find test -name "*.zig" -type f)

for file in $testfiles; do
  bname=$(delext $file)
  reason=$(getignore $bname)
  if [ "$(inbroken $bname)" == "1" ]; then
    continue
  fi
  make test/$bname
  case $? in
    0)
      if [ "$reason" != "suceed" ]; then
        echo "===========TEST FAILURE==========="
        echo "expected to fail with$reason"
        exit 1
      fi
      ;;
    *)
      if [ "$reason" == "suceed" ]; then
        echo "===========TEST FAILURE==========="
        echo "didn't expect to fail"
        exit 1
      fi
      ;;
  esac
done

echo "===========ALL TESTS PASSED!==========="