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