2011-01-29 14:42:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script runs all the test scripts it finds in the current folder
|
|
|
|
# Tests are identified as having a file name of *-in.txt
|
|
|
|
# For failed tests, the collected output is kept in the corresponding folder
|
|
|
|
|
2011-07-03 17:00:18 +00:00
|
|
|
export LYX_ROOT=../../..
|
|
|
|
export LYX_EXE=$LYX_ROOT/src/lyx
|
2011-02-06 22:50:07 +00:00
|
|
|
|
|
|
|
if [ "$XVKBD_HACKED" != "" ]; then
|
2011-02-10 22:33:23 +00:00
|
|
|
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
|
2011-02-06 22:50:07 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-12 23:47:06 +00:00
|
|
|
if [ "$(which wmctrl)" == "" ]; then
|
|
|
|
echo "You need to install wmctrl first, try:"
|
|
|
|
echo " sudo apt-get install wmctrl"
|
|
|
|
exit -1;
|
|
|
|
fi
|
2013-11-13 02:13:32 +00:00
|
|
|
|
|
|
|
if [ "$(which pcregrep)" == "" ]; then
|
|
|
|
echo "You need to install pcregrep first, try:"
|
|
|
|
echo " sudo apt-get install pcregrep"
|
|
|
|
exit -1;
|
|
|
|
fi
|
2013-11-13 20:07:53 +00:00
|
|
|
|
2013-11-13 02:41:38 +00:00
|
|
|
PROGRAM_SUFFIX=$(grep -e '#define PACKAGE ' ../../config.h | sed -e 's/#define PACKAGE "lyx\(.*\)"/\1/')
|
2012-10-12 23:47:06 +00:00
|
|
|
|
2011-02-10 22:33:23 +00:00
|
|
|
export XVKBD_EXE=../$XVKBD_EXE
|
2011-01-29 14:42:53 +00:00
|
|
|
export KEYTEST=../keytest.py
|
2011-02-02 23:18:16 +00:00
|
|
|
LYX_HOME=out-home
|
2013-11-13 02:41:38 +00:00
|
|
|
export LYX_USERDIR=$(pwd)/$LYX_HOME/.lyx$PROGRAM_SUFFIX
|
2011-02-10 22:33:23 +00:00
|
|
|
# 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
|
2011-01-29 14:42:53 +00:00
|
|
|
|
|
|
|
if [ "$#" -eq 0 ]; then
|
2017-04-16 09:26:29 +00:00
|
|
|
TESTS=$(ls *-in.txt *-in.sh | sed -e 's/hello-world-in.txt\|first-time-in.txt\|export-in.sh//')
|
2011-02-10 22:33:23 +00:00
|
|
|
rm -rf out-*;
|
2011-01-29 14:42:53 +00:00
|
|
|
else
|
|
|
|
TESTS=$*
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2011-02-01 22:08:07 +00:00
|
|
|
|
2011-02-02 23:18:16 +00:00
|
|
|
if [ ! -d $LYX_HOME ]; then
|
2011-02-10 22:33:23 +00:00
|
|
|
mkdir -p $LYX_HOME
|
2017-04-16 21:10:17 +00:00
|
|
|
mkdir -p $LYX_USERDIR
|
2011-02-10 22:33:23 +00:00
|
|
|
# cp preferences $LYX_USERDIR
|
2011-02-02 23:18:16 +00:00
|
|
|
cd $LYX_HOME
|
2011-02-01 22:08:07 +00:00
|
|
|
echo "Initializing testing environment . . ."
|
2011-07-03 17:00:18 +00:00
|
|
|
if ! ../single-test.sh "../first-time-in.txt" > test-log.txt 2>&1; then
|
2011-02-01 22:08:07 +00:00
|
|
|
echo "Some error occurred: check $(pwd)"
|
|
|
|
exit -1;
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
2011-02-07 23:32:27 +00:00
|
|
|
# Launch the emergency STOP button
|
2011-02-12 11:05:04 +00:00
|
|
|
./stop_autotests.tcl &
|
|
|
|
pid=$!
|
2011-02-07 23:32:27 +00:00
|
|
|
|
2011-07-03 17:00:18 +00:00
|
|
|
function stop_button() {
|
|
|
|
kill $pid
|
|
|
|
wait $pid > /dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2011-01-29 14:42:53 +00:00
|
|
|
echo "Running test cases . . ."
|
|
|
|
failed=0
|
2011-07-03 17:00:18 +00:00
|
|
|
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
|
2011-02-01 22:08:07 +00:00
|
|
|
exit -1;
|
|
|
|
fi
|
2011-01-29 14:42:53 +00:00
|
|
|
rm -rf "out-$t"
|
|
|
|
mkdir "out-$t"
|
|
|
|
cd "out-$t"
|
2011-07-10 00:13:12 +00:00
|
|
|
if $cmd > test-log.txt 2>&1; then
|
2011-01-29 14:42:53 +00:00
|
|
|
echo Ok
|
|
|
|
cd ..
|
2012-12-15 12:05:51 +00:00
|
|
|
if [ "$V" != "" ]; then rm -rf "out-$t"; fi
|
2011-01-29 14:42:53 +00:00
|
|
|
else
|
|
|
|
echo FAILED
|
|
|
|
cd ..
|
|
|
|
failed=$[$failed+1];
|
|
|
|
fi;
|
|
|
|
done
|
|
|
|
|
2011-07-03 17:00:18 +00:00
|
|
|
stop_button
|
2011-02-07 23:37:34 +00:00
|
|
|
|
2011-01-29 14:42:53 +00:00
|
|
|
echo
|
|
|
|
if [ $failed -eq 0 ]; then
|
|
|
|
echo "All tests SUCCESSFUL"
|
|
|
|
else
|
|
|
|
echo "There were $failed FAILED tests";
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|