summaryrefslogtreecommitdiff
path: root/test/run-testlinter.sh
blob: ea3ef6a8f210fd151a62e8a387ad43e510acacbb (plain)
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
#!/bin/bash
set -eu
THIS="$(readlink -f "$0")"
THISDIR="$(dirname "${THIS}")"

cd "$THISDIR"

is_windows_os=false
[[ $(uname) == Windows_NT* ]] && is_windows_os=true
[[ $(uname) == MINGW64_NT* ]] && is_windows_os=true

testShStartsWith() {
  if [[ $is_windows_os == true ]]; then
    return
  fi

  for test_sh in ./*test; do
    file_name="$(basename -- "$test_sh")"
    if [[ -f "${test_sh}" ]]; then
      echo ">> Test $file_name"
      local etalon_head="$(printf '#!/bin/bash
set -eu
THIS="$(readlink -f "$0")"
THISDIR="$(dirname "${THIS}")"
')"
      assertEquals  "$etalon_head" "$(cat "${test_sh}" | head -4)"
    fi
  done
}

# Load and run shUnit2.
source "./shunit2/shunit2"