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