Author: kihwal Date: Mon Aug 12 17:03:36 2013 New Revision: 1513200 URL: http://svn.apache.org/r1513200 Log: HADOOP-9583. test-patch gives +1 despite build failure when running tests. Contributed by Jason Lowe.
Modified: hadoop/common/trunk/dev-support/test-patch.sh Modified: hadoop/common/trunk/dev-support/test-patch.sh URL: http://svn.apache.org/viewvc/hadoop/common/trunk/dev-support/test-patch.sh?rev=1513200&r1=1513199&r2=1513200&view=diff ============================================================================== --- hadoop/common/trunk/dev-support/test-patch.sh (original) +++ hadoop/common/trunk/dev-support/test-patch.sh Mon Aug 12 17:03:36 2013 @@ -731,32 +731,62 @@ of hadoop-common prior to running the un fi fi fi + failed_test_builds="" + test_timeouts="" for module in $ordered_modules; do cd $module + module_suffix=`basename ${module}` + test_logfile=$PATCH_DIR/testrun_${module_suffix}.txt echo " Running tests in $module" echo " $MVN clean install -fn $NATIVE_PROFILE $REQUIRE_TEST_LIB_HADOOP -D${PROJECT_NAME}PatchProcess" - $MVN clean install -fn $NATIVE_PROFILE $REQUIRE_TEST_LIB_HADOOP -D${PROJECT_NAME}PatchProcess + $MVN clean install -fae $NATIVE_PROFILE $REQUIRE_TEST_LIB_HADOOP -D${PROJECT_NAME}PatchProcess > $test_logfile 2>&1 + test_build_result=$? + cat $test_logfile + module_test_timeouts=`$AWK '/^Running / { if (last) { print last } last=$2 } /^Tests run: / { last="" }' $test_logfile` + if [[ -n "$module_test_timeouts" ]] ; then + test_timeouts="$test_timeouts +$module_test_timeouts" + fi module_failed_tests=`find . -name 'TEST*.xml' | xargs $GREP -l -E "<failure|<error" | sed -e "s|.*target/surefire-reports/TEST-| |g" | sed -e "s|\.xml||g"` - # With -fn mvn always exits with a 0 exit code. Because of this we need to - # find the errors instead of using the exit code. We assume that if the build - # failed a -1 is already given for that case if [[ -n "$module_failed_tests" ]] ; then failed_tests="${failed_tests} ${module_failed_tests}" fi + if [[ $test_build_result != 0 && -z "$module_failed_tests" && -z "$module_test_timeouts" ]] ; then + failed_test_builds="$module $failed_test_builds" + fi cd - done + result=0 + comment_prefix=" {color:red}-1 core tests{color}." if [[ -n "$failed_tests" ]] ; then JIRA_COMMENT="$JIRA_COMMENT - {color:red}-1 core tests{color}. The patch failed these unit tests in $modules: +$comment_prefix The patch failed these unit tests in $modules: $failed_tests" - return 1 + comment_prefix=" " + result=1 fi - JIRA_COMMENT="$JIRA_COMMENT + if [[ -n "$test_timeouts" ]] ; then + JIRA_COMMENT="$JIRA_COMMENT + +$comment_prefix The following test timeouts occurred in $modules: +$test_timeouts" + comment_prefix=" " + result=1 + fi + if [[ -n "$failed_test_builds" ]] ; then + JIRA_COMMENT="$JIRA_COMMENT + +$comment_prefix The test build failed in $failed_test_builds" + result=1 + fi + if [[ $result == 0 ]] ; then + JIRA_COMMENT="$JIRA_COMMENT {color:green}+1 core tests{color}. The patch passed unit tests in $modules." - return 0 + fi + return $result } ###############################################################################