]> git.lyx.org Git - lyx.git/blob - development/autotests/run-tests.sh
Now run-tests.sh captures PROGRAM_SUFFIX from config.h, in order to use the correct...
[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 <<<<<<< Updated upstream
25 if [ "$(which pcregrep)" == "" ]; then
26     echo "You need to install pcregrep first, try:"
27     echo "  sudo apt-get install pcregrep"
28     exit -1;
29 fi
30 =======
31 PROGRAM_SUFFIX=$(grep -e '#define PACKAGE ' ../../config.h | sed -e 's/#define PACKAGE "lyx\(.*\)"/\1/')
32 >>>>>>> Stashed changes
33
34 export XVKBD_EXE=../$XVKBD_EXE
35 export KEYTEST=../keytest.py
36 LYX_HOME=out-home
37 export LYX_USERDIR=$(pwd)/$LYX_HOME/.lyx$PROGRAM_SUFFIX
38 # Create locale links 
39 export LOCALE_DIR=../locale
40
41 if [ ! -d ../../locale ]; then
42     echo "Some tests may require the GUI showing up in a specified language."
43     echo "In order to make it work, I'm going to run this command:"
44     mkdir -p locale
45     cmd="ln -s `pwd`/locale ../../"
46     echo "  $cmd"
47     ans=""
48     while [ "$ans" != "y" -a "$ans" != "n" ]; do
49         echo "Should I proceed (y/n) ?"
50         read ans;
51     done
52     if [ "$ans" == "y" ]; then
53         $cmd;
54     fi;
55 fi
56
57 if [ "$#" -eq 0 ]; then
58     TESTS=$(ls *-in.txt *-in.sh | sed -e 's/hello-world-in.txt\|first-time-in.txt//')
59     rm -rf out-*;
60 else
61     TESTS=$*
62 fi
63
64 echo
65
66 if [ ! -d $LYX_HOME ]; then
67     mkdir -p $LYX_HOME
68 #    mkdir -p $LYX_USERDIR
69 #    cp preferences $LYX_USERDIR
70     cd $LYX_HOME
71     echo "Initializing testing environment . . ."
72     if ! ../single-test.sh "../first-time-in.txt" > test-log.txt 2>&1; then
73         echo "Some error occurred: check $(pwd)"
74         exit -1;
75     fi
76     cd ..
77 fi
78
79 # Launch the emergency STOP button
80 ./stop_autotests.tcl &
81 pid=$!
82
83 function stop_button() {
84     kill $pid
85     wait $pid > /dev/null 2>&1
86 }
87
88 echo "Running test cases . . ."
89 failed=0
90 for tf in $(echo "$TESTS"); do
91     t=$(echo $tf | sed -e 's/-in.txt//g' | sed -e 's/-in.sh//g')
92     printf "%40s: " $tf
93     if [ -f "$t-in.txt" ]; then
94         cmd="../single-test.sh ../$t-in.txt";
95     elif [ -f "$t-in.sh" ]; then
96         if [ ! -x "$t-in.sh" ]; then
97             echo "ERROR: $t-in.sh is not executable"
98             stop_button
99             exit -1;
100         fi
101         cmd="../$tf";
102     else
103         echo "ERROR: File not found: $t-in.txt or $t-in.sh"
104         stop_button
105         exit -1;
106     fi
107     rm -rf "out-$t"
108     mkdir "out-$t"
109     cd "out-$t"
110     if $cmd > test-log.txt 2>&1; then
111         echo Ok
112         cd ..
113         if [ "$V" != "" ]; then rm -rf "out-$t"; fi
114     else
115         echo FAILED
116         cd ..
117         failed=$[$failed+1];
118     fi;
119 done
120
121 stop_button
122
123 echo
124 if [ $failed -eq 0 ]; then
125     echo "All tests SUCCESSFUL"
126 else
127     echo "There were $failed FAILED tests";
128 fi
129
130 echo