check_source_has_test.sh 1.26 KB
Newer Older
1
2
3
4
5
6
7
8
#! /bin/sh

failed_tests=0
all_tests=0

check_directory ()
{
  echo "Current directories: $1 $2"
9

10
11
12
  for file in `ls $1`; do

    if [ -f ${1}/$file ]; then
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
      ext=${file##*.}
      base=${file%.*}

      if [ "$ext" = "hh" -a \
	   "${base##*.}" != "spe" ]; then
	test_file=${file%.hh}.cc
	all_tests=$(($all_tests + 1))

	if [ -f ${2}/$test_file ]; then
	  echo "\t\e[0;32mOK\e[m $file <-> $test_file" > /dev/null
	else
	  if [ "$file" != "all.hh"  -a \
	    "$file" != "essential.hh" ]; then
	    echo "\tFAIL Test \"$test_file\" does not exist."
	    failed_tests=$(($failed_tests + 1))
	  fi
29
	fi
30

31
      fi
32

33
34
35
36
37
38
39
40
    fi

    if [ -d ${1}/$file ]; then
      if [ -d ${2}/$file ]; then
	echo ""
	check_directory ${1}/$file ${2}/$file
      else
	if [ "$file" != "internal" ]; then
41
	  echo "FAIL Test directory \"${2}/$file\" does not exist."
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
	fi
      fi
    fi

  done
}

if [ $# -ne 2 ]; then
  echo "Usage: ./check_test_hierarchy mln/ tests/"
  exit 1
fi

echo "Source directory: $1"
echo "Test directory: $2"
echo "---"

if [ -d ${1} ]; then
  if [ -d ${2} ]; then
    check_directory ${1} ${2}
  else
    echo "\e[0;31mFAIL\e[m Test directory $2 does not exist."
  fi
else
  echo "\e[0;31mFAIL\e[m Source directory $1 does not exist."
fi

echo "\n====="
69
echo "Missing tests: $failed_tests"
70