yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject yetus git commit: YETUS-658. Built-in Support For Unit Test Excluding
Date Tue, 21 Aug 2018 21:29:25 GMT
Repository: yetus
Updated Branches:
  refs/heads/master 31d2ca6a5 -> e1e22b361


YETUS-658. Built-in Support For Unit Test Excluding

Signed-off-by: Allen Wittenauer <aw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/e1e22b36
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/e1e22b36
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/e1e22b36

Branch: refs/heads/master
Commit: e1e22b361632b307432017ed4721de65ebfca9e6
Parents: 31d2ca6
Author: jackbearden <jack@jackbearden.com>
Authored: Fri Aug 10 14:42:46 2018 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Tue Aug 21 14:29:07 2018 -0700

----------------------------------------------------------------------
 precommit/jenkins/unit-test-filter-file.example |  2 ++
 .../test-patch-docker/launch-test-patch.sh      |  3 ++
 precommit/test-patch.d/maven.sh                 | 34 +++++++++++++++++++-
 precommit/test-patch.sh                         | 19 +++++++++++
 4 files changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/e1e22b36/precommit/jenkins/unit-test-filter-file.example
----------------------------------------------------------------------
diff --git a/precommit/jenkins/unit-test-filter-file.example b/precommit/jenkins/unit-test-filter-file.example
new file mode 100644
index 0000000..dc38859
--- /dev/null
+++ b/precommit/jenkins/unit-test-filter-file.example
@@ -0,0 +1,2 @@
+[package].[class].[method]
+![package].[class].[method]

http://git-wip-us.apache.org/repos/asf/yetus/blob/e1e22b36/precommit/test-patch-docker/launch-test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/launch-test-patch.sh b/precommit/test-patch-docker/launch-test-patch.sh
index ea3395a..b170cd2 100755
--- a/precommit/test-patch-docker/launch-test-patch.sh
+++ b/precommit/test-patch-docker/launch-test-patch.sh
@@ -48,6 +48,9 @@ TESTPATCHMODE=${TESTPATCHMODE%--docker}
 PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
 OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--patch-dir=${PATCH_DIR}")
 OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--user-plugins=${PATCH_DIR}/precommit/user-plugins")
+if [[ -f "${PATCH_DIR}/precommit/unit_test_filter_file.txt" ]]; then
+  OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--unit-test-filter-file=${PATCH_DIR}/precommit/unit_test_filter_file.txt")
+fi
 
 # if patch system is generic, then it's either a local
 # patch file or was in some other way not pulled from a bug

http://git-wip-us.apache.org/repos/asf/yetus/blob/e1e22b36/precommit/test-patch.d/maven.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/maven.sh b/precommit/test-patch.d/maven.sh
index f772d2a..2a384de 100755
--- a/precommit/test-patch.d/maven.sh
+++ b/precommit/test-patch.d/maven.sh
@@ -282,7 +282,9 @@ function maven_modules_worker
 {
   declare repostatus=$1
   declare tst=$2
+  declare maven_unit_test_filter
 
+  maven_unit_test_filter="$(maven_unit_test_filter)"
   # shellcheck disable=SC2034
   UNSUPPORTED_TEST=false
 
@@ -303,7 +305,11 @@ function maven_modules_worker
       modules_workers "${repostatus}" scaladoc clean scala:doc -DskipTests=true
     ;;
     unit)
-      modules_workers "${repostatus}" unit clean test -fae
+      if [[ -n "${maven_unit_test_filter}" ]]; then
+        modules_workers "${repostatus}" unit clean test -fae "${maven_unit_test_filter}"
+      else
+        modules_workers "${repostatus}" unit clean test -fae
+      fi
     ;;
     *)
       # shellcheck disable=SC2034
@@ -498,6 +504,32 @@ function maven_builtin_personality_file_tests
   fi
 }
 
+## @description  Maven unit test filter file string
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+## @return       string
+function maven_unit_test_filter()
+{
+  declare filtered
+
+  if [[ ! -z "${UNIT_TEST_FILTER_FILE}" ]]; then
+    while read -r line || [[ -n "${line}" ]]; do
+      if [[ -z $line ]]; then
+        continue
+      fi
+
+      filtered="${filtered}${line},"
+    done < "${UNIT_TEST_FILTER_FILE}"
+  fi
+
+  if [[ -z "${filtered}" ]]; then
+    printf "%s" ""
+  else
+    printf "%s" "-Dtest=${filtered%,}"
+  fi
+}
+
 ## @description  Confirm site pre-patch
 ## @audience     private
 ## @stability    stable

http://git-wip-us.apache.org/repos/asf/yetus/blob/e1e22b36/precommit/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh
index 5b375ca..df1849b 100755
--- a/precommit/test-patch.sh
+++ b/precommit/test-patch.sh
@@ -757,6 +757,7 @@ function yetus_usage
   yetus_add_option "--summarize=<bool>" "Allow tests to summarize results"
   yetus_add_option "--test-parallel=<bool>" "Run multiple tests in parallel (default
false in developer mode, true in Jenkins mode)"
   yetus_add_option "--test-threads=<int>" "Number of tests to run in parallel (default
defined in ${PROJECT_NAME} build)"
+  yetus_add_option "--unit-test-filter-file=<file>" "The unit test filter file to load"
   yetus_add_option "--tests-filter=<list>" "Lists of tests to turn failures into warnings"
   yetus_add_option "--user-plugins=<dir>" "A directory of user provided plugins. see
test-patch.d for examples (default empty)"
   yetus_add_option "--version" "Print release version information and exit"
@@ -946,6 +947,9 @@ function parse_args
         # shellcheck disable=SC2034
         TEST_THREADS=${i#*=}
       ;;
+      --unit-test-filter-file=*)
+        UNIT_TEST_FILTER_FILE=${i#*=}
+      ;;
       --tests-filter=*)
         yetus_comma_to_array VOTE_FILTER "${i#*=}"
       ;;
@@ -998,6 +1002,15 @@ function parse_args
     yetus_add_entry EXEC_MODES Robot
   fi
 
+  if [[ -n $UNIT_TEST_FILTER_FILE ]]; then
+    if [[ -f $UNIT_TEST_FILTER_FILE ]]; then
+      UNIT_TEST_FILTER_FILE=$(yetus_abs "${UNIT_TEST_FILTER_FILE}")
+    else
+      yetus_error "ERROR: Unit test filter file (${UNIT_TEST_FILTER_FILE}) does not exist!"
+      cleanup_and_exit 1
+    fi
+  fi
+
   if [[ -n ${REEXECLAUNCHTIMER} ]]; then
     TIMER=${REEXECLAUNCHTIMER};
   else
@@ -1651,6 +1664,12 @@ function copytpbits
     cp -pr "${PERSONALITY}" "${PATCH_DIR}/precommit/personality/provided.sh"
   fi
 
+  if [[ -n ${UNIT_TEST_FILTER_FILE}
+    && -f ${UNIT_TEST_FILTER_FILE} ]]; then
+    yetus_debug "copying '${UNIT_TEST_FILTER_FILE}' over to '${PATCH_DIR}/precommit/unit_test_filter_file.txt'"
+    cp -pr "${UNIT_TEST_FILTER_FILE}" "${PATCH_DIR}/precommit/unit_test_filter_file.txt"
+  fi
+
   if [[ -n ${DOCKERFILE}
       && -f ${DOCKERFILE} ]]; then
     yetus_debug "copying '${DOCKERFILE}' over to '${PATCH_DIR}/precommit/test-patch-docker/Dockerfile'"


Mime
View raw message