#!/bin/bash test ! -z $1 || { echo "Usage: $0 "; exit 255; } DIR=$1 # false exceptions=( "testsuite-options-no-elements-db.at" "testsuite-options-invalid-commands.at" "testsuite-options-empty-configs.at" "testsuite-options-store-session-cli.at" "testsuite-options-store-session-python.at" "testsuite-options-load-session-python.at" "testsuite-options-dryrun.at" "testsuite-options-no-dryrun.at" "testsuite-options-dryrun-storesession.at" ) # mark as XFAIL_IF failing_ones=( "testsuite-molecules-translation.at" "testsuite-molecules-translation-periodic.at" ) # copy Makefile.am #cp Makefile.am $DIR #cp testsuite.at $DIR # go over all testsuite files for file in `find . -name 'testsuite*.at' | grep -v "/testsuite\.at"`; do filename=`basename ${file} | sed -e "s#testsuite#session#" -e "s#\.at#.py#"` basename=`basename $file` dirname=`dirname $file` found=0 for e in `seq 0 $((${#exceptions[*]}-1))`; do if test "$basename" == "${exceptions[$e]}"; then echo "${exceptions[$e]} is excluded." found=1 fi done if test $found != 1; then mkdir -p $DIR/$dirname sed -e ':x; /\\$/ { N; s/\\\n//; tx }' -e "s#\(AT_CHECK(\)\[../../molecuilder \([^]]*\)\][[:space:]]*,[[:space:]]*\([0-9]*\)\(.*\)#\1[../../molecuilder --dry-run \2 --no-dry-run --store-session $filename --session-type python], 0\4\nAT_CHECK([grep -v \"Command.*DryRun\" $filename >${filename/.py/_new.py}], 0, [ignore], [ignore])\n\1[../../molecuilderguitest ${filename/.py/_new.py}], \3\4#" -e "/^AT_CHECK(\[[a-z]*grep.*stdout/d" -e "s#CommandVerbose(\".*\")#CommandVerbose(\"1\")#" $file >$DIR/$file for f in `seq 0 $((${#failing_ones[*]}-1))`; do if test "$basename" == "${failing_ones[$f]}"; then sed -i -e "s#\(AT_KEYWORDS.*\)#\1\nAT_XFAIL_IF([/bin/true])#" $DIR/$file echo "${failing_ones[$f]} is set to XFAIL." fi done else rm -f $DIR/$file fi done # grep and remove exceptions from all top-level testsuite files testscripts="" for file in `find . -name 'testsuite*.at' | grep -v "/testsuite\.at"`; do basename=`basename $file` found=1 while test $found == 1; do found=0 for e in `seq 0 $((${#exceptions[*]}-1))`; do grep -E "m4_include.*${exceptions[$e]}" $DIR/$file &>/dev/null if test $? == 0; then echo "${exceptions[$e]} is removed from $DIR/$file." found=1 # remove from file mv -f $DIR/$file $DIR/${file}.bak cat <$DIR/${file}.bak | grep -v -E "m4_include.*${exceptions[$e]}" >$DIR/$file rm -f $DIR/${file}.bak fi done done removed=0 for e in `seq 0 $((${#exceptions[*]}-1))`; do if test "$basename" == "${exceptions[$e]}"; then removed=1 fi done if test $removed == 0; then # add to TESTSCRIPTS if test -z "$testscripts"; then testscripts="\t\$(srcdir)/${file}" else testscripts="${testscripts} \\\\\n\t\$(srcdir)/${file}" fi fi done # modify TESTSCRIPTS variable in Makefile.am startline=`grep -n "TESTSCRIPTS =" $DIR/Makefile.am | awk -F":" '{print $1}'` endline=`grep -n "DISTCLEANFILES =" $DIR/Makefile.am | awk -F":" '{print $1}'` mv $DIR/Makefile.am $DIR/Makefile.am.bak head -n $startline $DIR/Makefile.am.bak >$DIR/Makefile.am echo -e "\t\$(srcdir)/./Testlauncher/testsuite-testlauncher-works.at \\" >>$DIR/Makefile.am echo -e "${testscripts}" >>$DIR/Makefile.am echo -e -n "\n" >>$DIR/Makefile.am tail -n +${endline} $DIR/Makefile.am.bak >>$DIR/Makefile.am rm -f $DIR/Makefile.am.bak exit 0