[Swift-commit] r3505 - trunk/tests

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Aug 10 13:21:12 CDT 2010


Author: wozniak
Date: 2010-08-10 13:21:12 -0500 (Tue, 10 Aug 2010)
New Revision: 3505

Modified:
   trunk/tests/nightly.sh
Log:
New support for helper scripts (setup, check, clean)


Modified: trunk/tests/nightly.sh
===================================================================
--- trunk/tests/nightly.sh	2010-08-10 18:20:23 UTC (rev 3504)
+++ trunk/tests/nightly.sh	2010-08-10 18:21:12 UTC (rev 3505)
@@ -267,21 +267,14 @@
   TYPE=$1
   if [ "$TYPE" == "test" ]; then
 
-    LABEL=$2  # Text on link to output
+    LABEL="$2"  # Text on link to output
     CMD=$3    # Command issued (td title)
-    RESULT=$4
+    RESULT=$4 # Passed or Failed
 
-
-    if [ "$FLUSH" == "1" ]; then
-      html_~tr
-      html_~table
-      html_~tr
-    fi
-
-    WIDTH=$( width $LABEL )
+    WIDTH=$( width "$LABEL" )
     if [ "$RESULT" == "Passed" ]; then
       html "<td class=\"success\" $WIDTH title=\"$CMD\">"
-      html_a_href $TLOG $LABEL
+      html_a_href $TLOG "$LABEL"
     else
       echo "FAILED"
       cat $TLOG < /dev/null
@@ -337,7 +330,7 @@
 
 # HTML width of label (for alignment)
 width() {
-  LABEL=$1
+  LABEL="$1"
   if [ ${#LABEL} -gt 2 ]; then
     WIDTH=""
   else
@@ -379,6 +372,24 @@
   } >>$BOUT
 }
 
+# Check for early bailout condition
+check_bailout() {
+  if [ "$EXITONFAILURE" == "true" ]; then
+    if [ "$EXITCODE" != "0" ]; then
+      exit $EXITCODE
+    fi
+  fi
+}
+
+# Translate exit code into result (Passed/Failed) string
+result() {
+  if [ "$EXITCODE" == "0" ]; then
+    echo "Passed"
+  else
+    echo "Failed"
+  fi
+}
+
 aexec() {
   declare -p PWD
   printf "\nExecuting: $@" >>$LOG
@@ -399,10 +410,47 @@
   banner "$TEST (part $SEQ)"
   echo "Executing $TEST (part $SEQ)"
   aexec "$@"
-  ptest
+  RESULT=$( result )
+  tlog
+  out test $SEQ "$LASTCMD" $RESULT $TLOG
+
+  check_bailout
+
   let "SEQ=$SEQ+1"
 }
 
+# Execute helper script (setup, check, or clean)
+script_exec() {
+  SCRIPT=$1
+  SYMBOL="$2"
+
+  aexec $SCRIPT
+  RESULT=$( result )
+
+  tlog
+  out test "$SYMBOL" "$LASTCMD" $RESULT
+
+  check_bailout
+}
+
+# Execute Swift test case w/ setup, check, clean
+swift_test() {
+  SWIFTSCRIPT=$1
+  SETUPSCRIPT=${SWIFTSCRIPT%.swift}.setup.sh
+  CHECKSCRIPT=${SWIFTSCRIPT%.swift}.check.sh
+  CLEANSCRIPT=${SWIFTSCRIPT%.swift}.clean.sh
+  if [ -x $TESTDIR/$SETUPSCRIPT ]; then
+    script_exec $TESTDIR/$SETUPSCRIPT "S"
+  fi
+  pexec swift -sites.file sites.xml -tc.file tc.data $SWIFTSCRIPT
+  if [ -x $TESTDIR/$CHECKSCRIPT ]; then
+    script_exec $TESTDIR/$CHECKSCRIPT "√"
+  fi
+  if [ -x $TESTDIR/$CLEANSCRIPT ]; then
+    script_exec $TESTDIR/$CLEANSCRIPT "C"
+  fi
+}
+
 ssexec() {
   SEQSAVE=$SEQ
   SEQ=$1
@@ -412,33 +460,19 @@
   aexec "$@"
   ptest
   SEQ=$SEQSAVE
-  FLUSH=0
 }
 
 # Fake exec
 fexec() {
-  FLUSH=1
   banner "$TEST (faked)"
   echo "Faking $TEST"
   EXITCODE=0
   LASTCMD=""
-  ptest
+  # ptest
 }
 
-ptest() {
-  if [ "$EXITCODE" == "0" ]; then
-    RESULT="Passed"
-  else
-    RESULT="Failed"
-  fi
-  tlog
-  out test $SEQ "$LASTCMD" $RESULT $TLOG
-  if [ "$EXITONFAILURE" == "true" ]; then
-    if [ "$EXITCODE" != "0" ]; then
-      exit $EXITCODE
-    fi
-  fi
-}
+#ptest() {
+#}
 
 build_package() {
   TEST="Package"
@@ -519,7 +553,7 @@
 
   start_row
   for ((i=0; $i<$ITERS_LOCAL; i=$i+1)); do
-    pexec swift -sites.file sites.xml -tc.file tc.data $TESTNAME
+    swift_test $TESTNAME
   done
   end_row
 done




More information about the Swift-commit mailing list