~cypheon/rapid

ref: 9928b2ee6ed80e49271a11f7254409cdad7a574f rapid/runtests.sh -rwxr-xr-x 2.1 KiB
9928b2ee — Johann Rudloff [refactor] Codegen: use simpler state modification methods 6 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash

rapidc=${rapidc:-$PWD/build/exec/rapidc}

tests=(chez001 chez002 chez003 chez004 chez005 chez006 chez007 chez008 chez009 chez010 chez011 chez012 chez013 chez014 chez014 chez015 chez016 chez017 chez018 reg001)

if [[ -n "$1" ]]; then
  if [[ "$1" = "--good" ]]; then
    tests=(
      chez001
      chez002
      chez003
      chez004
      chez005
      chez006
      chez007
      chez008
      chez009
      chez011
      chez012
      reg001
      rapid001
      rapid002
      rapid003
      rapid004
      rapid005
      rapid006
      rapid008
      rapid012
      rapid013
      rapid014
    )
  else
    read -r -a tests <<< "$@"
  fi
fi

if [[ -n "$RAPID_TEST_DEBUG" ]]; then
  debug_directive="--directive debug"
  echo "test will be compiled with DEBUG directive"
else
  debug_directive=""
  echo "test will be compiled without DEBUG directive"
fi

count_total=0
count_ok=0
count_failed=0
count_error=0

for test in ${tests[*]}; do
  ((count_total++))
  testdir="$PWD/tests/chez/$test"
  idr=$(echo ${testdir}/*.idr)
  if [[ ! -d "$testdir" ]]; then
    echo "dir does not exist: $testdir"
    ((count_error++))
    continue
  fi

  pushd "$testdir" >/dev/null
  rm -rf ./build output
  if $rapidc --cg llvm $debug_directive -p contrib -p network -o "$test" "$idr" >& "${testdir}/compile.log"; then
    "./build/exec/$test" > "${testdir}/output"
    #"$testdir/build/rapid/$(basename "$idr" .idr).native" > "${testdir}/output"

    expected="${testdir}/expected"
    expected_os="${testdir}/expected.$(uname)"
    if [[ -f "${expected_os}" ]]; then
      expected="${expected_os}"
    fi

    if git diff --quiet --no-index -- "${expected}" "${testdir}/output"; then
      echo "OK: $test"
      ((count_ok++))
    else
      git --no-pager diff --exit-code --no-index -- "${expected}" "${testdir}/output"
      ((count_failed++))
    fi
  else
    echo "COMPILE ERROR: $test"
    cat "${testdir}/compile.log"
    ((count_error++))
  fi
  popd >/dev/null
done

echo "Tests run: $count_total, ok: $count_ok, failed: $count_failed, error: $count_error"

if [[ "${count_total}" -eq "${count_ok}" ]]; then
  exit 0
else
  exit 1
fi