phpunit-indiv - Change args. Generate XML and/or JSON.
authorTim Otten <totten@civicrm.org>
Thu, 14 Aug 2014 00:56:59 +0000 (17:56 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 14 Aug 2014 00:56:59 +0000 (17:56 -0700)
tools/scripts/jmat
tools/scripts/phpunit-indiv

index ae874562e80b4699ad1f4a5cf53a7b8903de2c86..c29dcfa7d1c0d1019c9b341472ede76bc74082bb 100755 (executable)
@@ -67,7 +67,7 @@ while [ -n "$1" ]; do
       reset_dir "$OUTDIR/bundled-indiv"
 
       pushd "$CIVI/tools"
-        phpunit-indiv --civi "../$TESTPATH" "$OUTDIR/bundled-indiv"
+        ./scripts/phpunit-indiv --civi --test-dir "../$TESTPATH" --json-dir "$OUTDIR/bundled-indiv"
       popd
 
       cat "$OUTDIR"/bundled-indiv/*-*.json > "$OUTDIR/bundled-indiv/all.json"
@@ -90,7 +90,7 @@ while [ -n "$1" ]; do
 
       pushd "$CIVI"
         [ -d "packages/PHPUnit" ] && mv "packages/PHPUnit" "packages/PHPUnit.bak"
-        phpunit-indiv "$TESTPATH" "$OUTDIR/standalone-indiv"
+        ./tools/scripts/phpunit-indiv --test-dir "$TESTPATH" --json-dir "$OUTDIR/standalone-indiv"
         [ -d "packages/PHPUnit.bak" ] && mv "packages/PHPUnit.bak" "packages/PHPUnit"
       popd
 
index 6768418075edf22c4b903afb6e4d599469458a5f..459ec6608d21e796d74fa5189f47767a7e60f171 100755 (executable)
@@ -2,32 +2,60 @@
 PHP=${PHP:-php}
 PHPUNIT=${PHPUNIT:-phpunit}
 MODE=standalone
+XMLDIR=
+JSONDIR=
 
-if [ "$1" == "--civi" ]; then
-  MODE=civi
+while [ -n "$1" ]; do
+  ARG="$1"
   shift
-fi
 
-TESTSUITE="$1"
-shift
+  case "$ARG" in
+    --civi)
+      MODE=civi
+      ;;
+    --test-dir)
+      TESTSUITE="$1"
+      shift
+      ;;
+    --json-dir)
+      JSONDIR="$1"
+      [ ! -d "$JSONDIR" ] && mkdir -p "$JSONDIR"
+      shift
+      ;;
+    --xml-dir)
+      XMLDIR="$1"
+      [ ! -d "$XMLDIR" ] && mkdir -p "$XMLDIR"
+      shift
+      ;;
+    *)
+      echo "unrecognized option: $ARG"
+      ;;
+  esac
+done
 
-OUTDIR="$1"
-shift
 
-if [ -z "$TESTSUITE" -o -z "$OUTDIR" ]; then
+if [ -z "$TESTSUITE" ]; then
   echo "summary: Executes all tests in a suite (individually)"
-  echo "usage: $0 <test-suite-path> <output-dir>"
+  echo "usage: $0 --test-dir <dir> [--json-dir <dir>] [--xml-dir <dir>] [--civi]"
   exit 1
 fi
 
-[ ! -d "$OUTDIR" ] && mkdir -p "$OUTDIR"
 
 #phpunit-ls "$TESTSUITE"
 phpunit-ls "$TESTSUITE" | while read FILE CLASS METHOD ; do
+  PHPUNITARGS="--tap"
+  if [ -n "$JSONDIR" ]; then
+    PHPUNITARGS="$PHPUNITARGS --log-json $JSONDIR/$CLASS-$METHOD.json"
+  fi
+  if [ -n "$XMLDIR" ]; then
+    PHPUNITARGS="$PHPUNITARGS --log-junit $XMLDIR/$CLASS-$METHOD.xml"
+  fi
+
+
   if [ "$MODE" == "civi" ]; then
-    $PHP ./scripts/phpunit --tap --log-json "$OUTDIR/$CLASS-$METHOD.json" --filter $METHOD'( with.*)?$' "$CLASS"
+    $PHP ./scripts/phpunit $PHPUNITARGS --filter $METHOD'( with.*)?$' "$CLASS"
   fi
   if [ "$MODE" == "standalone" ]; then
-    $PHP $(which $PHPUNIT) --tap --log-json "$OUTDIR/$CLASS-$METHOD.json" --filter $METHOD'( with.*)?$' "$FILE"
+    $PHP $(which $PHPUNIT) $PHPUNITARGS --filter $METHOD'( with.*)?$' "$FILE"
   fi
 done