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