summaryrefslogtreecommitdiff
path: root/runtests.sh
blob: 7e5fda89bc30dc320cfe7d946da60ae4fbfdaa09 (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
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
95
96
97
98
#!/bin/sh

###### Denemo: run the tests that are found in the directory $1 and reference files in $2
###### This script should be run from the toplevel denemo directory after the make
 
if [[ $# -ne 2 ]]; then
  echo Usage: $0 testdirectory referencedirectory 1>&2
  echo example:
  echo $0 tests reference
  exit 1
fi



tests=$1
reference=$2
toplevel=$(pwd)

if [[ ! -f denemo.conf ]] ; then
    echo $pwd: this does not seem to be the top level denemo directory
    exit 1
fi
if [[ ! -d $toplevel/$tests ]] ; then
    echo no directory $toplevel/$tests found
    exit 1
fi

failedtests=$toplevel/failed$tests
if [[  -d $failedtests ]] ; then
    rm -rf $failedtests
fi
mkdir $failedtests
#### set $HOME so that the test can expect a known set of keybindings
export HOME=$toplevel/$tests
echo home directory set to $HOME
if [[ -d $HOME/.denemo ]] ; then
    echo found $HOME/.denemo
else
    echo creating $HOME/.denemo
    mkdir $HOME/.denemo
fi

unset EDITOR
#FIXME -other things like locale need standardizing for test run?

if [[ -d testtemp ]] ; then
    cd testtemp
    file=$(ls)
    for f in $file; do
      echo removing old test file $f
      rm $f
    done
    cd ..
else
    echo make testtemp
    mkdir testtemp
fi

cd $tests
testfiles=$(ls)
echo "**************************"
echo TESTS TO BE DONE: $testfiles
echo "**************************"
for f in $testfiles; do
        echo ********PERFORMING TEST $f *****************
        cd ../testtemp
#make two file entries to mimic presence of fifos that were there during recording
#ignore the permission bits 
	touch gttfifo1
	touch gttfifo2
#restore the environment after previous test run
	cp $toplevel/denemo.keymaprc $HOME/.denemo/keymaprc
	cp $toplevel/denemo.conf $HOME/.denemo/denemorc

	gnome-test-tool-play  -e ../$tests/$f  -r ../$reference/denemo-play.res ../src/denemo
	/bin/rm gttfifo1
	/bin/rm gttfifo2
	results=$(ls)
	for result in $results; do
	        echo Comparing $result with $reference
		diff $result ../$reference/$f
		if [[ $? -eq 0 ]] ; then
		    echo test passed   
		else
		    cp ../$tests/$f $failedtests
		    echo test $f failed to repeat 
		    echo To retry run tests on directory failed$tests
		fi
		rm $result
	done
	echo ********END OF TEST $f *****************
done

	echo ********END OF ALL TESTS *****************
echo Failures are in $failedtests - here is the listing:
ls $failedtests

exit 0