X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=development%2Fautotests%2Frun-tests.sh;h=25d29340e8414e8567f4ea826c458dd6926abc3b;hb=226e0bb2b7361646bea84098d7bab4b87018ad99;hp=1b3ab651c4bdfc49b7bd11b8a561fa99f3e2b8a8;hpb=3596e02d6a26752cf6c3ad5d0ff28220e12ed53a;p=lyx.git diff --git a/development/autotests/run-tests.sh b/development/autotests/run-tests.sh index 1b3ab651c4..25d29340e8 100755 --- a/development/autotests/run-tests.sh +++ b/development/autotests/run-tests.sh @@ -4,23 +4,57 @@ # Tests are identified as having a file name of *-in.txt # For failed tests, the collected output is kept in the corresponding folder -if [ ! -x xvkbd/xvkbd ]; then - echo "You need to build XVKBD first, try: cd xvkbd && xmkmf && make" - exit -1; +export LYX_ROOT=../../.. +export LYX_EXE=$LYX_ROOT/src/lyx + +if [ "$XVKBD_HACKED" != "" ]; then + export XVKBD_EXE=${XVKBD:-./xvkbd/xvkbd}; + if [ ! -x $XVKBD_EXE ]; then + echo "You need to build XVKBD first, try: cd xvkbd && xmkmf && make" + exit -1; + fi fi -export LYX_EXE=../../../src/lyx +if [ "$(which wmctrl)" == "" ]; then + echo "You need to install wmctrl first, try:" + echo " sudo apt-get install wmctrl" + exit -1; +fi -if [ "$XVKBD_HACKED" != "" ]; then - export XVKBD_EXE=${XVKBD:-../xvkbd/xvkbd}; +if [ "$(which pcregrep)" == "" ]; then + echo "You need to install pcregrep first, try:" + echo " sudo apt-get install pcregrep" + exit -1; fi +PROGRAM_SUFFIX=$(grep -e '#define PACKAGE ' ../../config.h | sed -e 's/#define PACKAGE "lyx\(.*\)"/\1/') + +export XVKBD_EXE=../$XVKBD_EXE export KEYTEST=../keytest.py LYX_HOME=out-home -export LYX_USERDIR=$(pwd)/$LYX_HOME/.lyx +export LYX_USERDIR=$(pwd)/$LYX_HOME/.lyx$PROGRAM_SUFFIX +# Create locale links +export LOCALE_DIR=../locale + +if [ ! -d ../../locale ]; then + echo "Some tests may require the GUI showing up in a specified language." + echo "In order to make it work, I'm going to run this command:" + mkdir -p locale + cmd="ln -s `pwd`/locale ../../" + echo " $cmd" + ans="" + while [ "$ans" != "y" -a "$ans" != "n" ]; do + echo "Should I proceed (y/n) ?" + read ans; + done + if [ "$ans" == "y" ]; then + $cmd; + fi; +fi if [ "$#" -eq 0 ]; then - TESTS=$(ls *-in.txt | sed -e 's/hello-world-in.txt\|first-time-in.txt//'); + TESTS=$(ls *-in.txt *-in.sh | sed -e 's/hello-world-in.txt\|first-time-in.txt\|export-in.sh//') + rm -rf out-*; else TESTS=$* fi @@ -28,10 +62,12 @@ fi echo if [ ! -d $LYX_HOME ]; then - mkdir $LYX_HOME + mkdir -p $LYX_HOME + mkdir -p $LYX_USERDIR +# cp preferences $LYX_USERDIR cd $LYX_HOME echo "Initializing testing environment . . ." - if ! ../single-test.sh "../first-time-in.txt" > keytest-log.txt 2>&1; then + if ! ../single-test.sh "../first-time-in.txt" > test-log.txt 2>&1; then echo "Some error occurred: check $(pwd)" exit -1; fi @@ -40,22 +76,39 @@ fi # Launch the emergency STOP button ./stop_autotests.tcl & +pid=$! + +function stop_button() { + kill $pid + wait $pid > /dev/null 2>&1 +} echo "Running test cases . . ." failed=0 -for t in $(echo "$TESTS" | sed -e 's/-in.txt//g'); do - printf "%40s: " $t - if [ ! -f "$t-in.txt" ]; then - echo "ERROR: File not found: $t-in.txt" +for tf in $(echo "$TESTS"); do + t=$(echo $tf | sed -e 's/-in.txt//g' | sed -e 's/-in.sh//g') + printf "%40s: " $tf + if [ -f "$t-in.txt" ]; then + cmd="../single-test.sh ../$t-in.txt"; + elif [ -f "$t-in.sh" ]; then + if [ ! -x "$t-in.sh" ]; then + echo "ERROR: $t-in.sh is not executable" + stop_button + exit -1; + fi + cmd="../$tf"; + else + echo "ERROR: File not found: $t-in.txt or $t-in.sh" + stop_button exit -1; fi rm -rf "out-$t" mkdir "out-$t" cd "out-$t" - if ../single-test.sh "../$t-in.txt" > keytest-log.txt 2>&1; then + if $cmd > test-log.txt 2>&1; then echo Ok cd .. - rm -rf "out-$t"; + if [ "$V" != "" ]; then rm -rf "out-$t"; fi else echo FAILED cd .. @@ -63,7 +116,7 @@ for t in $(echo "$TESTS" | sed -e 's/-in.txt//g'); do fi; done -killall stop_autotests.tcl > /dev/null 2>&1 +stop_button echo if [ $failed -eq 0 ]; then