File: run_tests

package info (click to toggle)
openstack-pkg-tools 139
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 940 kB
  • sloc: sh: 4,216; makefile: 31
file content (39 lines) | stat: -rwxr-xr-x 744 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

set -e

# This is a basic test runner for shell script tests
# it just searches for all test_ scripts under the tests
# folder, and run them.

GREEN="\033[1;32m"
RED="\033[1;31m"
NO_COL="\033[0m"

echo "Running shell script unit tests..."

CURDIR=$(pwd)
SUCCESS=yes
CNT=0
for i in $(find tests -type f -iname 'test_*') ; do
	DIRNAME=$(dirname $i)
	BASENAME=$(basename $i)
	cd ${DIRNAME}
	echo -n $i" ... "
	if ./${BASENAME} ; then
		echo "${GREEN}OK${NO_COL}"
	else
		SUCCESS=no
		echo "${RED}FAILED${NO_COL}"
	fi
	cd ${CURDIR}
	CNT=$(( ${CNT} + 1 ))
done

if [ "${SUCCESS}" = "yes" ] ; then
	echo "${GREEN}Successfully ran ${CNT} tests :)${NO_COL}"
	exit 0
else
	echo "${RED}Failure while running unit tests :(${NO_COL}"
	exit 1
fi