| 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 | 
 | 
|---|
| 19 | # copy Makefile.am
 | 
|---|
| 20 | #cp Makefile.am $DIR
 | 
|---|
| 21 | #cp testsuite.at $DIR
 | 
|---|
| 22 | 
 | 
|---|
| 23 | # go over all testsuite files
 | 
|---|
| 24 | for file in `find . -name 'testsuite*.at' | grep -v "/testsuite\.at"`; do
 | 
|---|
| 25 |         filename=`basename ${file} | sed -e "s#testsuite#session#" -e "s#\.at#.py#"`
 | 
|---|
| 26 |         basename=`basename $file`
 | 
|---|
| 27 |         dirname=`dirname $file`
 | 
|---|
| 28 |         found=0
 | 
|---|
| 29 |         for e in `seq 0 $((${#exceptions[*]}-1))`; do
 | 
|---|
| 30 |                 if test "$basename" == "${exceptions[$e]}"; then
 | 
|---|
| 31 |                         echo "${exceptions[$e]} is excluded."
 | 
|---|
| 32 |                         found=1
 | 
|---|
| 33 |                 fi
 | 
|---|
| 34 |         done
 | 
|---|
| 35 |         if test $found != 1; then
 | 
|---|
| 36 |                 mkdir -p $DIR/$dirname
 | 
|---|
| 37 |                 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
 | 
|---|
| 38 |         else
 | 
|---|
| 39 |                 rm -f $DIR/$file
 | 
|---|
| 40 |         fi
 | 
|---|
| 41 | done
 | 
|---|
| 42 | 
 | 
|---|
| 43 | # grep and remove exceptions from all top-level testsuite files
 | 
|---|
| 44 | testscripts=""
 | 
|---|
| 45 | for file in `find . -name 'testsuite*.at' | grep -v "/testsuite\.at"`; do
 | 
|---|
| 46 |         basename=`basename $file`
 | 
|---|
| 47 |         found=1
 | 
|---|
| 48 |         while test $found == 1; do
 | 
|---|
| 49 |                 found=0
 | 
|---|
| 50 |                 for e in `seq 0 $((${#exceptions[*]}-1))`; do
 | 
|---|
| 51 |                         grep -E "m4_include.*${exceptions[$e]}" $DIR/$file &>/dev/null
 | 
|---|
| 52 |                         if test $? == 0; then
 | 
|---|
| 53 |                                 echo "${exceptions[$e]} is removed from $DIR/$file."
 | 
|---|
| 54 |                                 found=1
 | 
|---|
| 55 |                                 # remove from file
 | 
|---|
| 56 |                                 mv -f $DIR/$file $DIR/${file}.bak
 | 
|---|
| 57 |                                 cat <$DIR/${file}.bak | grep -v -E "m4_include.*${exceptions[$e]}" >$DIR/$file
 | 
|---|
| 58 |                                 rm -f $DIR/${file}.bak
 | 
|---|
| 59 |                         fi
 | 
|---|
| 60 |                 done
 | 
|---|
| 61 |         done
 | 
|---|
| 62 |         removed=0
 | 
|---|
| 63 |         for e in `seq 0 $((${#exceptions[*]}-1))`; do
 | 
|---|
| 64 |                 if test "$basename" == "${exceptions[$e]}"; then
 | 
|---|
| 65 |                         removed=1
 | 
|---|
| 66 |                 fi
 | 
|---|
| 67 |         done
 | 
|---|
| 68 |         if test $removed == 0; then
 | 
|---|
| 69 |                 # add to TESTSCRIPTS
 | 
|---|
| 70 |                 if test -z "$testscripts"; then
 | 
|---|
| 71 |                         testscripts="\t\$(srcdir)/${file}"
 | 
|---|
| 72 |                 else
 | 
|---|
| 73 |                         testscripts="${testscripts} \\\\\n\t\$(srcdir)/${file}"
 | 
|---|
| 74 |                 fi
 | 
|---|
| 75 |         fi
 | 
|---|
| 76 | done
 | 
|---|
| 77 | 
 | 
|---|
| 78 | # modify TESTSCRIPTS variable in Makefile.am
 | 
|---|
| 79 | startline=`grep -n "TESTSCRIPTS =" $DIR/Makefile.am | awk -F":" '{print $1}'`
 | 
|---|
| 80 | endline=`grep -n "DISTCLEANFILES =" $DIR/Makefile.am | awk -F":" '{print $1}'`
 | 
|---|
| 81 | mv $DIR/Makefile.am $DIR/Makefile.am.bak
 | 
|---|
| 82 | head -n $startline $DIR/Makefile.am.bak >$DIR/Makefile.am
 | 
|---|
| 83 | echo -e "\t\$(srcdir)/./Testlauncher/testsuite-testlauncher-works.at \\" >>$DIR/Makefile.am
 | 
|---|
| 84 | echo -e "${testscripts}" >>$DIR/Makefile.am
 | 
|---|
| 85 | echo -e -n "\n" >>$DIR/Makefile.am
 | 
|---|
| 86 | tail -n +${endline} $DIR/Makefile.am.bak >>$DIR/Makefile.am
 | 
|---|
| 87 | rm -f $DIR/Makefile.am.bak
 | 
|---|
| 88 | 
 | 
|---|
| 89 | exit 0
 | 
|---|