| [fae462] | 1 | #!/bin/bash | 
|---|
|  | 2 |  | 
|---|
|  | 3 | test ! -z $1 || { echo "Usage: $0 <relative destdir>"; exit 255; } | 
|---|
|  | 4 | DIR=$1 | 
|---|
|  | 5 |  | 
|---|
|  | 6 | # false | 
|---|
|  | 7 | exceptions=( | 
|---|
|  | 8 | "testsuite-options-no-elements-db.at" | 
|---|
|  | 9 | "testsuite-options-invalid-commands.at" | 
|---|
|  | 10 | "testsuite-options-empty-configs.at" | 
|---|
|  | 11 | "testsuite-options-store-session-cli.at" | 
|---|
|  | 12 | "testsuite-options-store-session-python.at" | 
|---|
|  | 13 | "testsuite-options-load-session-python.at" | 
|---|
|  | 14 | "testsuite-options-dryrun.at" | 
|---|
|  | 15 | "testsuite-options-no-dryrun.at" | 
|---|
|  | 16 | "testsuite-options-dryrun-storesession.at" | 
|---|
|  | 17 | ) | 
|---|
|  | 18 |  | 
|---|
| [b9e47e] | 19 | # mark as XFAIL_IF | 
|---|
|  | 20 | failing_ones=( | 
|---|
|  | 21 | "testsuite-molecules-translation.at" | 
|---|
|  | 22 | "testsuite-molecules-translation-periodic.at" | 
|---|
|  | 23 | ) | 
|---|
|  | 24 |  | 
|---|
| [fae462] | 25 | # copy Makefile.am | 
|---|
|  | 26 | #cp Makefile.am $DIR | 
|---|
|  | 27 | #cp testsuite.at $DIR | 
|---|
|  | 28 |  | 
|---|
|  | 29 | # go over all testsuite files | 
|---|
|  | 30 | for file in `find . -name 'testsuite*.at' | grep -v "/testsuite\.at"`; do | 
|---|
|  | 31 | filename=`basename ${file} | sed -e "s#testsuite#session#" -e "s#\.at#.py#"` | 
|---|
|  | 32 | basename=`basename $file` | 
|---|
|  | 33 | dirname=`dirname $file` | 
|---|
|  | 34 | found=0 | 
|---|
|  | 35 | for e in `seq 0 $((${#exceptions[*]}-1))`; do | 
|---|
|  | 36 | if test "$basename" == "${exceptions[$e]}"; then | 
|---|
|  | 37 | echo "${exceptions[$e]} is excluded." | 
|---|
|  | 38 | found=1 | 
|---|
|  | 39 | fi | 
|---|
|  | 40 | done | 
|---|
|  | 41 | if test $found != 1; then | 
|---|
|  | 42 | mkdir -p $DIR/$dirname | 
|---|
| [599b32] | 43 | 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 | 
|---|
| [b9e47e] | 44 | for f in `seq 0 $((${#failing_ones[*]}-1))`; do | 
|---|
|  | 45 | if test "$basename" == "${failing_ones[$f]}"; then | 
|---|
|  | 46 | sed -i -e "s#\(AT_KEYWORDS.*\)#\1\nAT_XFAIL_IF([/bin/true])#" $DIR/$file | 
|---|
|  | 47 | echo "${failing_ones[$f]} is set to XFAIL." | 
|---|
|  | 48 | fi | 
|---|
|  | 49 | done | 
|---|
| [fae462] | 50 | else | 
|---|
|  | 51 | rm -f $DIR/$file | 
|---|
|  | 52 | fi | 
|---|
|  | 53 | done | 
|---|
|  | 54 |  | 
|---|
|  | 55 | # grep and remove exceptions from all top-level testsuite files | 
|---|
|  | 56 | testscripts="" | 
|---|
|  | 57 | for file in `find . -name 'testsuite*.at' | grep -v "/testsuite\.at"`; do | 
|---|
|  | 58 | basename=`basename $file` | 
|---|
|  | 59 | found=1 | 
|---|
|  | 60 | while test $found == 1; do | 
|---|
|  | 61 | found=0 | 
|---|
|  | 62 | for e in `seq 0 $((${#exceptions[*]}-1))`; do | 
|---|
|  | 63 | grep -E "m4_include.*${exceptions[$e]}" $DIR/$file &>/dev/null | 
|---|
|  | 64 | if test $? == 0; then | 
|---|
|  | 65 | echo "${exceptions[$e]} is removed from $DIR/$file." | 
|---|
|  | 66 | found=1 | 
|---|
|  | 67 | # remove from file | 
|---|
|  | 68 | mv -f $DIR/$file $DIR/${file}.bak | 
|---|
|  | 69 | cat <$DIR/${file}.bak | grep -v -E "m4_include.*${exceptions[$e]}" >$DIR/$file | 
|---|
|  | 70 | rm -f $DIR/${file}.bak | 
|---|
|  | 71 | fi | 
|---|
|  | 72 | done | 
|---|
|  | 73 | done | 
|---|
|  | 74 | removed=0 | 
|---|
|  | 75 | for e in `seq 0 $((${#exceptions[*]}-1))`; do | 
|---|
|  | 76 | if test "$basename" == "${exceptions[$e]}"; then | 
|---|
|  | 77 | removed=1 | 
|---|
|  | 78 | fi | 
|---|
|  | 79 | done | 
|---|
|  | 80 | if test $removed == 0; then | 
|---|
|  | 81 | # add to TESTSCRIPTS | 
|---|
|  | 82 | if test -z "$testscripts"; then | 
|---|
|  | 83 | testscripts="\t\$(srcdir)/${file}" | 
|---|
|  | 84 | else | 
|---|
|  | 85 | testscripts="${testscripts} \\\\\n\t\$(srcdir)/${file}" | 
|---|
|  | 86 | fi | 
|---|
|  | 87 | fi | 
|---|
|  | 88 | done | 
|---|
|  | 89 |  | 
|---|
|  | 90 | # modify TESTSCRIPTS variable in Makefile.am | 
|---|
|  | 91 | startline=`grep -n "TESTSCRIPTS =" $DIR/Makefile.am | awk -F":" '{print $1}'` | 
|---|
|  | 92 | endline=`grep -n "DISTCLEANFILES =" $DIR/Makefile.am | awk -F":" '{print $1}'` | 
|---|
|  | 93 | mv $DIR/Makefile.am $DIR/Makefile.am.bak | 
|---|
|  | 94 | head -n $startline $DIR/Makefile.am.bak >$DIR/Makefile.am | 
|---|
|  | 95 | echo -e "\t\$(srcdir)/./Testlauncher/testsuite-testlauncher-works.at \\" >>$DIR/Makefile.am | 
|---|
|  | 96 | echo -e "${testscripts}" >>$DIR/Makefile.am | 
|---|
|  | 97 | echo -e -n "\n" >>$DIR/Makefile.am | 
|---|
|  | 98 | tail -n +${endline} $DIR/Makefile.am.bak >>$DIR/Makefile.am | 
|---|
|  | 99 | rm -f $DIR/Makefile.am.bak | 
|---|
|  | 100 |  | 
|---|
|  | 101 | exit 0 | 
|---|