]> git.lyx.org Git - lyx.git/blob - development/autotests/run-tests.sh
keytests: Handle function-keys for xvkbd too
[lyx.git] / development / autotests / run-tests.sh
1 #!/bin/bash
2
3 # This script runs all the test scripts it finds in the current folder
4 # Tests are identified as having a file name of *-in.txt
5 # For failed tests, the collected output is kept in the corresponding folder
6
7 export LYX_ROOT=../../..
8 export LYX_EXE=$LYX_ROOT/src/lyx
9
10 if [ "$XVKBD_HACKED" != "" ]; then
11     export XVKBD_EXE=${XVKBD:-./xvkbd/xvkbd};
12     if [ ! -x $XVKBD_EXE ]; then
13         echo "You need to build XVKBD first, try: cd xvkbd && xmkmf && make"
14         exit -1;
15     fi
16 fi
17
18 if [ "$(which wmctrl)" == "" ]; then
19     echo "You need to install wmctrl first, try:"
20     echo "  sudo apt-get install wmctrl"
21     exit -1;
22 fi
23
24 if [ "$(which pcregrep)" == "" ]; then
25     echo "You need to install pcregrep first, try:"
26     echo "  sudo apt-get install pcregrep"
27     exit -1;
28 fi
29
30 PROGRAM_SUFFIX=$(grep -e '#define PACKAGE ' ../../config.h | sed -e 's/#define PACKAGE "lyx\(.*\)"/\1/')
31
32 export XVKBD_EXE=../$XVKBD_EXE
33 export KEYTEST=../keytest.py
34 LYX_HOME=out-home
35 export LYX_USERDIR=$(pwd)/$LYX_HOME/.lyx$PROGRAM_SUFFIX
36 # Create locale links 
37 export LOCALE_DIR=../locale
38
39 if [ ! -d ../../locale ]; then
40     echo "Some tests may require the GUI showing up in a specified language."
41     echo "In order to make it work, I'm going to run this command:"
42     mkdir -p locale
43     cmd="ln -s `pwd`/locale ../../"
44     echo "  $cmd"
45     ans=""
46     while [ "$ans" != "y" -a "$ans" != "n" ]; do
47         echo "Should I proceed (y/n) ?"
48         read ans;
49     done
50     if [ "$ans" == "y" ]; then
51         $cmd;
52     fi;
53 fi
54
55 if [ "$#" -eq 0 ]; then
56     TESTS=$(ls *-in.txt *-in.sh | sed -e 's/hello-world-in.txt\|first-time-in.txt\|export-in.sh//')
57     rm -rf out-*;
58 else
59     TESTS=$*
60 fi
61
62 echo
63
64 if [ ! -d $LYX_HOME ]; then
65     mkdir -p $LYX_HOME
66     mkdir -p $LYX_USERDIR
67 #    cp preferences $LYX_USERDIR
68     cd $LYX_HOME
69     echo "Initializing testing environment . . ."
70     if ! ../single-test.sh "../first-time-in.txt" > test-log.txt 2>&1; then
71         echo "Some error occurred: check $(pwd)"
72         exit -1;
73     fi
74     cd ..
75 fi
76
77 # Launch the emergency STOP button
78 ./stop_autotests.tcl &
79 pid=$!
80
81 function stop_button() {
82     kill $pid
83     wait $pid > /dev/null 2>&1
84 }
85
86 echo "Running test cases . . ."
87 failed=0
88 for tf in $(echo "$TESTS"); do
89     t=$(echo $tf | sed -e 's/-in.txt//g' | sed -e 's/-in.sh//g')
90     printf "%40s: " $tf
91     if [ -f "$t-in.txt" ]; then
92         cmd="../single-test.sh ../$t-in.txt";
93     elif [ -f "$t-in.sh" ]; then
94         if [ ! -x "$t-in.sh" ]; then
95             echo "ERROR: $t-in.sh is not executable"
96             stop_button
97             exit -1;
98         fi
99         cmd="../$tf";
100     else
101         echo "ERROR: File not found: $t-in.txt or $t-in.sh"
102         stop_button
103         exit -1;
104     fi
105     rm -rf "out-$t"
106     mkdir "out-$t"
107     cd "out-$t"
108     if $cmd > test-log.txt 2>&1; then
109         echo Ok
110         cd ..
111         if [ "$V" != "" ]; then rm -rf "out-$t"; fi
112     else
113         echo FAILED
114         cd ..
115         failed=$[$failed+1];
116     fi;
117 done
118
119 stop_button
120
121 echo
122 if [ $failed -eq 0 ]; then
123     echo "All tests SUCCESSFUL"
124 else
125     echo "There were $failed FAILED tests";
126 fi
127
128 echo