From 35e0b420b361291573b04c79327e8057c09b0bdb Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 13 Aug 2014 17:56:59 -0700 Subject: [PATCH] phpunit-indiv - Change args. Generate XML and/or JSON. --- tools/scripts/jmat | 4 +-- tools/scripts/phpunit-indiv | 52 ++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/tools/scripts/jmat b/tools/scripts/jmat index ae874562e8..c29dcfa7d1 100755 --- a/tools/scripts/jmat +++ b/tools/scripts/jmat @@ -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 diff --git a/tools/scripts/phpunit-indiv b/tools/scripts/phpunit-indiv index 6768418075..459ec6608d 100755 --- a/tools/scripts/phpunit-indiv +++ b/tools/scripts/phpunit-indiv @@ -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 " + echo "usage: $0 --test-dir [--json-dir ] [--xml-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 -- 2.25.1