Skip to content

Commit

Permalink
HBASE-25333 Add a yetus check to disable usage of VisibleForTesting a…
Browse files Browse the repository at this point in the history
…nnotation on IA.Public and IA.LimitedPrivate classes
  • Loading branch information
Apache9 committed Nov 26, 2020
1 parent 1726160 commit 4ce72fd
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions dev-support/hbase-personality.sh
Expand Up @@ -816,6 +816,66 @@ function hbaseanti_patchfile
return 0
}

######################################

add_test_type visible-for-testing

## @description visible-for-testing file filter
## @audience private
## @stability evolving
## @param filename
function visible-for-testing_filefilter
{
local filename=$1

if [[ ${filename} =~ \.java$ ]]; then
add_test visible-for-testing
fi
}

## @description visible-for-testing patch file check
## @audience private
## @stability evolving
## @param repostatus
function visible-for-testing_precompile
{
local repostatus=$1
local logfile="${PATCH_DIR}/patch-visible-for-testing.txt"
local errors

if [[ "${repostatus}" = branch ]]; then
return 0
fi

if ! verify_needed_test visible-for-testing; then
return 0
fi

big_console_header "VisibleForTesting plugin: ${BUILDMODE}"
if [[ "${BUILDMODE}" = "full" ]]; then
find -type f -name *.java | grep -v generated | xargs grep -l "@InterfaceAudience.Public\|@InterfaceAudience.LimitedPrivate" | xargs grep -l @VisibleForTesting >> ${logfile}
else
for f in "${CHANGED_FILES[@]}"
do
if [[ ${filename} =~ \.java$ ]]; then
grep -l "@InterfaceAudience.Public\|@InterfaceAudience.LimitedPrivate" ${filename} | xargs grep -l @VisibleForTesting >> ${logfile}
fi
done
fi

errors=`wc -l ${logfile} | cut -d" " -f1`
if [[ "${errors}" = "0" ]]; then
add_vote_table +1 visible-for-testing "Patch does not introduce VisibleForTesting annotation on IA.Public or IA.LimitedPrivate classes."
return 0
else
add_vote_table -1 visible-for-testing "${BUILDMODEMSG} introduces VisibleForTesting annotation on ${errors} IA.Public or IA.LimitedPrivate classes."
add_footer_table visible-for-testing "@@BASE@@/patch-visible-for-testing.txt"
return 1
fi
}

######################################

## @description process the javac output for generating WARNING/ERROR
## @audience private
## @stability evolving
Expand Down

0 comments on commit 4ce72fd

Please sign in to comment.