Repository: yetus Updated Branches: refs/heads/master 6070d4fc8 -> ce2240d71
YETUS-62. add auto-formatting of usage options Signed-off-by: Allen Wittenauer <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/ce2240d7 Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/ce2240d7 Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/ce2240d7 Branch: refs/heads/master Commit: ce2240d71f41ccab0da430a57ccc356d94044f72 Parents: 6070d4f Author: Allen Wittenauer <[email protected]> Authored: Thu Dec 10 12:08:51 2015 -0800 Committer: Allen Wittenauer <[email protected]> Committed: Sat Dec 12 11:09:58 2015 -0800 ---------------------------------------------------------------------- precommit/core.d/00-yetuslib.sh | 99 ++++++++++++++++++++++++ precommit/core.d/01-common.sh | 12 +++ precommit/personality/bigtop.sh | 3 +- precommit/personality/jmeter.sh | 3 +- precommit/smart-apply-patch.sh | 62 +++++++++------ precommit/test-patch.d/ant.sh | 3 +- precommit/test-patch.d/asflicense.sh | 5 +- precommit/test-patch.d/bugzilla.sh | 3 +- precommit/test-patch.d/checkstyle.sh | 3 +- precommit/test-patch.d/findbugs.sh | 5 +- precommit/test-patch.d/github.sh | 13 ++-- precommit/test-patch.d/gradle.sh | 5 +- precommit/test-patch.d/jira.sh | 11 ++- precommit/test-patch.d/maven.sh | 9 +-- precommit/test-patch.d/perlcritic.sh | 5 +- precommit/test-patch.d/pylint.sh | 5 +- precommit/test-patch.d/rubocop.sh | 3 +- precommit/test-patch.d/ruby-lint.sh | 3 +- precommit/test-patch.d/tap.sh | 3 +- precommit/test-patch.sh | 123 +++++++++++++++++------------- 20 files changed, 253 insertions(+), 125 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/core.d/00-yetuslib.sh ---------------------------------------------------------------------- diff --git a/precommit/core.d/00-yetuslib.sh b/precommit/core.d/00-yetuslib.sh index c3f4eaf..5d0a942 100755 --- a/precommit/core.d/00-yetuslib.sh +++ b/precommit/core.d/00-yetuslib.sh @@ -14,6 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# we need to declare this globally as an array, which can only +# be done outside of a function +declare -a YETUS_OPTION_USAGE + ## @description Print a message to stderr ## @audience public ## @stability stable @@ -125,3 +129,98 @@ function yetus_abs fi return 1 } + +## @description Add a header to the usage output +## @audience public +## @stability evolving +## @replaceable no +## @param header +function yetus_add_header +{ + declare text=$1 + + YETUS_USAGE_HEADER="${text}" +} + +## @description Add an option to the usage output +## @audience public +## @stability evolving +## @replaceable no +## @param subcommand +## @param subcommanddesc +function yetus_add_option +{ + declare option=$1 + declare text=$2 + + YETUS_OPTION_USAGE[${YETUS_OPTION_USAGE_COUNTER}]="${option}@${text}" + ((YETUS_OPTION_USAGE_COUNTER=YETUS_OPTION_USAGE_COUNTER+1)) +} + +## @description Reset the usage information to blank +## @audience private +## @stability evolving +## @replaceable no +function yetus_reset_usage +{ + YETUS_OPTION_USAGE=() + YETUS_OPTION_USAGE_COUNTER=0 +} + +## @description Print a screen-size aware two-column output +## @audience public +## @stability evolving +## @replaceable no +## @param array +function yetus_generic_columnprinter +{ + declare -a input=("$@") + declare -i i=0 + declare -i counter=0 + declare line + declare text + declare option + declare giventext + declare -i maxoptsize + declare -i foldsize + declare -a tmpa + declare numcols + + if [[ -n "${COLUMNS}" ]]; then + numcols=${COLUMNS} + else + numcols=$(tput cols) 2>/dev/null + fi + + if [[ -z "${numcols}" + || ! "${numcols}" =~ ^[0-9]+$ ]]; then + numcols=75 + else + ((numcols=numcols-5)) + fi + + while read -r line; do + tmpa[${counter}]=${line} + ((counter=counter+1)) + option=$(echo "${line}" | cut -f1 -d'@') + if [[ ${#option} -gt ${maxoptsize} ]]; then + maxoptsize=${#option} + fi + done < <(for text in "${input[@]}"; do + echo "${text}" + done | sort) + + i=0 + ((foldsize=numcols-maxoptsize)) + + until [[ $i -eq ${#tmpa[@]} ]]; do + option=$(echo "${tmpa[$i]}" | cut -f1 -d'@') + giventext=$(echo "${tmpa[$i]}" | cut -f2 -d'@') + + while read -r line; do + printf "%-${maxoptsize}s %-s\n" "${option}" "${line}" + option=" " + done < <(echo "${giventext}"| fold -s -w ${foldsize}) + ((i=i+1)) + done +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/core.d/01-common.sh ---------------------------------------------------------------------- diff --git a/precommit/core.d/01-common.sh b/precommit/core.d/01-common.sh index dff228a..96b092c 100755 --- a/precommit/core.d/01-common.sh +++ b/precommit/core.d/01-common.sh @@ -500,3 +500,15 @@ function importplugins personality_globals fi } + +## @description Print the plugin's usage info +## @audience public +## @stability evolving +## @replaceable no +## @param array +function plugin_usage_output +{ + echo "" + echo "${YETUS_USAGE_HEADER}" + echo "" +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/personality/bigtop.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/bigtop.sh b/precommit/personality/bigtop.sh index 9f234de..039618b 100755 --- a/precommit/personality/bigtop.sh +++ b/precommit/personality/bigtop.sh @@ -34,8 +34,7 @@ add_test_type bigtop function bigtop_usage { - echo "Bigtop specific:" - echo "--bigtop-puppet=[false|true] execute the bigtop puppet setup (needs sudo to root)" + yetus_add_option "--bigtop-puppet=[false|true]" "execute the bigtop puppet setup (needs sudo to root)" } function bigtop_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/personality/jmeter.sh ---------------------------------------------------------------------- diff --git a/precommit/personality/jmeter.sh b/precommit/personality/jmeter.sh index 0af744c..a9da710 100755 --- a/precommit/personality/jmeter.sh +++ b/precommit/personality/jmeter.sh @@ -32,8 +32,7 @@ add_test_type jmeter function jmeter_usage { - echo "JMeter specific:" - echo "--jmeter-download-jars=[false|true] download third-party jars needed by ant build" + yetus_add_option "--jmeter-download-jars=<bool>" "download third-party jars needed by ant build" } function jmeter_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/smart-apply-patch.sh ---------------------------------------------------------------------- diff --git a/precommit/smart-apply-patch.sh b/precommit/smart-apply-patch.sh index 8e028f6..de0a643 100755 --- a/precommit/smart-apply-patch.sh +++ b/precommit/smart-apply-patch.sh @@ -82,32 +82,43 @@ function setup_defaults ## @replaceable no function yetus_usage { - echo "Usage: smart-apply-patch.sh [options] patch" - echo - echo "--committer Apply patches like a boss." - echo "--debug If set, then output some extra stuff to stderr" - echo "--dry-run Check for patch viability without applying" - echo "--list-plugins List all installed plug-ins and then exit" - echo "--modulelist=<list> Specify additional modules to test (comma delimited)" - echo "--offline Avoid connecting to the Internet" - echo "--patch-dir=<dir> The directory for working and output files (default '/tmp/yetus-(random))" - echo "--personality=<file> The personality file to load" - echo "--plugins=<list> Specify which plug-ins to add/delete (comma delimited; use 'all' for all found)" - echo "--project=<name> The short name for project currently using test-patch (default 'yetus')" - echo "--skip-system-plugins Do not load plugins from ${BINDIR}/test-patch.d" - echo "--user-plugins=<dir> A directory of user provided plugins. see test-patch.d for examples (default empty)" - echo "--version Print release version information and exit" + echo "test-patch.sh [OPTIONS] patch" + echo "" + echo "Where:" + echo " patch is a file, URL, or bugsystem-compatible location of the patch file" + echo "" + echo "Options:" + echo "" + yetus_add_option "--committer" "Apply patches like a boss." + yetus_add_option "--debug" "If set, then output some extra stuff to stderr" + yetus_add_option "--dry-run" "Check for patch viability without applying" + yetus_add_option "--list-plugins" "List all installed plug-ins and then exit" + yetus_add_option "--modulelist=<list>" "Specify additional modules to test (comma delimited)" + yetus_add_option "--offline" "Avoid connecting to the Internet" + yetus_add_option "--patch-dir=<dir>" "The directory for working and output files (default '/tmp/yetus-(random))" + yetus_add_option "--personality=<file>" "he personality file to load" + yetus_add_option "--plugins=<list>" "Specify which plug-ins to add/delete (comma delimited; use 'all' for all found)" + yetus_add_option "--project=<name>" "The short name for project currently using test-patch (default 'yetus')" + yetus_add_option "--skip-system-plugins" "Do not load plugins from ${BINDIR}/test-patch.d" + 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" + yetus_generic_columnprinter "${YETUS_OPTION_USAGE[@]}" + yetus_reset_usage + echo "" echo "Shell binary overrides:" - echo "--awk-cmd=<cmd> The 'awk' command to use (default 'awk')" - echo "--curl-cmd=<cmd> The 'curl' command to use (default 'curl')" - echo "--diff-cmd=<cmd> The GNU-compatible 'diff' command to use (default 'diff')" - echo "--file-cmd=<cmd> The 'file' command to use (default 'file')" - echo "--git-cmd=<cmd> The 'git' command to use (default 'git')" - echo "--grep-cmd=<cmd> The 'grep' command to use (default 'grep')" - echo "--patch-cmd=<cmd> The 'patch' command to use (default 'patch')" - echo "--sed-cmd=<cmd> The 'sed' command to use (default 'sed')" + yetus_add_option "--awk-cmd=<cmd>" "The 'awk' command to use (default 'awk')" + yetus_add_option "--curl-cmd=<cmd>" "The 'curl' command to use (default 'curl')" + yetus_add_option "--diff-cmd=<cmd>" "The GNU-compatible 'diff' command to use (default 'diff')" + yetus_add_option "--file-cmd=<cmd>" "The 'file' command to use (default 'file')" + yetus_add_option "--git-cmd=<cmd>" "The 'git' command to use (default 'git')" + yetus_add_option "--grep-cmd=<cmd>" "The 'grep' command to use (default 'grep')" + yetus_add_option "--patch-cmd=<cmd>" "The 'patch' command to use (default 'patch')" + yetus_add_option "--sed-cmd=<cmd>" "The 'sed' command to use (default 'sed')" + yetus_generic_columnprinter "${YETUS_OPTION_USAGE[@]}" + yetus_reset_usage + echo "" importplugins unset TESTFORMATS @@ -116,8 +127,11 @@ function yetus_usage for plugin in ${BUGSYSTEMS}; do if declare -f ${plugin}_usage >/dev/null 2>&1; then - echo + echo "" + echo "${plugin} plugin usage options:" "${plugin}_usage" + yetus_generic_columnprinter "${YETUS_OPTION_USAGE[@]}" + yetus_reset_usage fi done } http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/ant.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/ant.sh b/precommit/test-patch.d/ant.sh index 31c5881..51356e7 100755 --- a/precommit/test-patch.d/ant.sh +++ b/precommit/test-patch.d/ant.sh @@ -26,8 +26,7 @@ declare -a ANT_ARGS=("-noinput") function ant_usage { - echo "ant specific:" - echo "--ant-cmd=<cmd> The 'ant' command to use (default \${ANT_HOME}/bin/ant, or 'ant')" + yetus_add_option "--ant-cmd=<cmd>" "The 'ant' command to use (default \${ANT_HOME}/bin/ant, or 'ant')" } function ant_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/asflicense.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/asflicense.sh b/precommit/test-patch.d/asflicense.sh index e69db9f..23dfae5 100755 --- a/precommit/test-patch.d/asflicense.sh +++ b/precommit/test-patch.d/asflicense.sh @@ -19,9 +19,8 @@ add_test_type asflicense function asflicense_usage { - echo "ASF License Options:" - echo "--asflicense-rat-excludes=<path> path to file containing exclusion patterns" - echo "--asflicense-rat-jar=<path> path to Apache Creadur Rat jar file" + yetus_add_option "--asflicense-rat-excludes=<path>" "path to file containing exclusion patterns" + yetus_add_option "--asflicense-rat-jar=<path>" "path to Apache Creadur Rat jar file" } function asflicense_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/bugzilla.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/bugzilla.sh b/precommit/test-patch.d/bugzilla.sh index 2077689..885a752 100755 --- a/precommit/test-patch.d/bugzilla.sh +++ b/precommit/test-patch.d/bugzilla.sh @@ -21,8 +21,7 @@ BUGZILLA_BASE_URL="https://bz.apache.org/bugzilla" function bugzilla_usage { - echo "Bugzilla Options:" - echo "--bugzilla-base-url=<url> The URL of the bugzilla server" + yetus_add_option "--bugzilla-base-url=<url>" "The URL of the bugzilla server" } function bugzilla_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/checkstyle.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/checkstyle.sh b/precommit/test-patch.d/checkstyle.sh index 236664a..1d45819 100755 --- a/precommit/test-patch.d/checkstyle.sh +++ b/precommit/test-patch.d/checkstyle.sh @@ -36,8 +36,7 @@ function checkstyle_filefilter function checkstyle_usage { - echo "Checkstyle options:" - echo "--checkstyle-goal=<goal> Checkstyle maven plugin goal to use, 'check' and 'checkstyle' supported. Defaults to '${CHECKSTYLE_GOAL_DEFAULT}'." + yetus_add_option "--checkstyle-goal=<goal>" "Checkstyle maven plugin goal to use, 'check' and 'checkstyle' supported. Defaults to '${CHECKSTYLE_GOAL_DEFAULT}'." } function checkstyle_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/findbugs.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/findbugs.sh b/precommit/test-patch.d/findbugs.sh index 42d59fb..da0328b 100755 --- a/precommit/test-patch.d/findbugs.sh +++ b/precommit/test-patch.d/findbugs.sh @@ -35,9 +35,8 @@ function findbugs_filefilter function findbugs_usage { - echo "FindBugs specific:" - echo "--findbugs-home=<path> Findbugs home directory (default FINDBUGS_HOME environment variable)" - echo "--findbugs-strict-precheck If there are Findbugs warnings during precheck, fail" + yetus_add_option "--findbugs-home=<path>" "Findbugs home directory (default \${FINDBUGS_HOME})" + yetus_add_option "--findbugs-strict-precheck" "If there are Findbugs warnings during precheck, fail" } function findbugs_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/github.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/github.sh b/precommit/test-patch.d/github.sh index 63ed178..a3e4b9a 100755 --- a/precommit/test-patch.d/github.sh +++ b/precommit/test-patch.d/github.sh @@ -41,13 +41,12 @@ GITHUB_COMMITSHA="" function github_usage { - echo "GITHUB Options:" - echo "--github-api-url=<url> The URL of the API for github (default: '${GITHUB_API_URL}')" - echo "--github-base-url=<url> The URL of the github server (default:'${GITHUB_BASE_URL}')" - echo "--github-password=<pw> Github password" - echo "--github-repo=<repo> github repo to use (default:'${GITHUB_REPO}')" - echo "--github-token=<token> The token to use to write to github" - echo "--github-user=<user> Github user" + yetus_add_option "--github-api-url=<url>" "The URL of the API for github (default: '${GITHUB_API_URL}')" + yetus_add_option "--github-base-url=<url>" "The URL of the github server (default:'${GITHUB_BASE_URL}')" + yetus_add_option "--github-password=<pw>" "Github password" + yetus_add_option "--github-repo=<repo>" "github repo to use (default:'${GITHUB_REPO}')" + yetus_add_option "--github-token=<token>" "The token to use to write to github" + yetus_add_option "--github-user=<user>" "Github user" } function github_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/gradle.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/gradle.sh b/precommit/test-patch.d/gradle.sh index 4a4e4d2..84f5a6b 100755 --- a/precommit/test-patch.d/gradle.sh +++ b/precommit/test-patch.d/gradle.sh @@ -20,9 +20,8 @@ declare -a GRADLE_ARGS=() function gradle_usage { - echo "gradle specific:" - echo "--gradle-cmd=<cmd> The 'gradle' command to use (default 'gradle')" - echo "--gradlew-cmd=<cmd> The 'gradlew' command to use (default 'basedir/gradlew')" + yetus_add_option "--gradle-cmd=<cmd>" "The 'gradle' command to use (default 'gradle')" + yetus_add_option "--gradlew-cmd=<cmd>" "The 'gradlew' command to use (default 'basedir/gradlew')" } function gradle_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/jira.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/jira.sh b/precommit/test-patch.d/jira.sh index 7f375d0..91167a9 100755 --- a/precommit/test-patch.d/jira.sh +++ b/precommit/test-patch.d/jira.sh @@ -30,12 +30,11 @@ add_bugsystem jira function jira_usage { - echo "JIRA Options:" - echo "--jira-base-url=<url> The URL of the JIRA server (default:'${JIRA_URL}')" - echo "--jira-issue-re=<expr> Bash regular expression to use when trying to find a jira ref in the patch name (default: \'${JIRA_ISSUE_RE}\')" - echo "--jira-password=<pw> The password for the 'jira' command" - echo "--jira-status-re=<expr> Grep regular expression representing the issue status whose patch is applicable to the codebase (default: \'${JIRA_STATUS_RE}\')" - echo "--jira-user=<user> The user for the 'jira' command" + yetus_add_option "--jira-base-url=<url>" "The URL of the JIRA server (default:'${JIRA_URL}')" + yetus_add_option "--jira-issue-re=<expr>" "Bash regular expression to use when trying to find a jira ref in the patch name (default: '${JIRA_ISSUE_RE}')" + yetus_add_option "--jira-password=<pw>" "The password for the 'jira' command" + yetus_add_option "--jira-status-re=<expr>" "Grep regular expression representing the issue status whose patch is applicable to the codebase (default: '${JIRA_STATUS_RE}')" + yetus_add_option "--jira-user=<user>" "The user for the 'jira' command" } function jira_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/maven.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/maven.sh b/precommit/test-patch.d/maven.sh index 9deffb5..06b1b69 100755 --- a/precommit/test-patch.d/maven.sh +++ b/precommit/test-patch.d/maven.sh @@ -31,11 +31,10 @@ add_build_tool maven function maven_usage { - echo "maven specific:" - echo "--mvn-cmd=<cmd> The 'mvn' command to use (default \${MAVEN_HOME}/bin/mvn, or 'mvn')" - echo "--mvn-custom-repos Use per-project maven repos" - echo "--mvn-custom-repos-dir=dir Location of repos, default is \'${MAVEN_CUSTOM_REPOS_DIR}\'" - echo "--mvn-settings=file File to use for settings.xml" + yetus_add_option "--mvn-cmd=<cmd>" "The 'mvn' command to use (default \${MAVEN_HOME}/bin/mvn, or 'mvn')" + yetus_add_option "--mvn-custom-repos" "Use per-project maven repos" + yetus_add_option "--mvn-custom-repos-dir=dir" "Location of repos, default is '${MAVEN_CUSTOM_REPOS_DIR}'" + yetus_add_option "--mvn-settings=file" "File to use for settings.xml" } function maven_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/perlcritic.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/perlcritic.sh b/precommit/test-patch.d/perlcritic.sh index c55f01a..a099fd6 100755 --- a/precommit/test-patch.d/perlcritic.sh +++ b/precommit/test-patch.d/perlcritic.sh @@ -22,8 +22,7 @@ PERLCRITIC=${PERLCRITIC:-$(which perlcritic 2>/dev/null)} function perlcritic_usage { - echo "Perl::Critic specific:" - echo "--perlcritic=<path> path to perlcritic executable" + yetus_add_option "--perlcritic=<path>" "path to perlcritic executable" } function perlcritic_parse_args @@ -148,4 +147,4 @@ function perlcritic_postcompile else perlcritic_postapply fi -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/pylint.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/pylint.sh b/precommit/test-patch.d/pylint.sh index f97a140..5706d23 100755 --- a/precommit/test-patch.d/pylint.sh +++ b/precommit/test-patch.d/pylint.sh @@ -23,9 +23,8 @@ PYLINT_OPTIONS=${PYLINT_OPTIONS:-} function pylint_usage { - echo "Pylint specific:" - echo "--pylint=<path> path to pylint executable" - echo "--pylint-options=<path> pylint options other than output-format and reports" + yetus_add_option "--pylint=<path>" "path to pylint executable" + yetus_add_option "--pylint-options=<path>" "pylint options other than output-format and reports" } function pylint_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/rubocop.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/rubocop.sh b/precommit/test-patch.d/rubocop.sh index c0fa2ac..36a5e5d 100755 --- a/precommit/test-patch.d/rubocop.sh +++ b/precommit/test-patch.d/rubocop.sh @@ -22,8 +22,7 @@ RUBOCOP=${RUBOCOP:-$(which rubocop 2>/dev/null)} function rubocop_usage { - echo "Rubocop specific:" - echo "--rubocop=<path> path to rubocop executable" + yetus_add_option "--rubocop=<path>" "path to rubocop executable" } function rubocop_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/ruby-lint.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/ruby-lint.sh b/precommit/test-patch.d/ruby-lint.sh index aa18f58..3246a6a 100755 --- a/precommit/test-patch.d/ruby-lint.sh +++ b/precommit/test-patch.d/ruby-lint.sh @@ -22,8 +22,7 @@ RUBY_LINT=${RUBY_LINT:-$(which ruby-lint 2>/dev/null)} function ruby_lint_usage { - echo "Ruby-lint specific:" - echo "--ruby-lint=<path> path to ruby-lint executable" + yetus_add_option "--ruby-lint=<path>" "path to ruby-lint executable" } function ruby_lint_parse_args http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.d/tap.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.d/tap.sh b/precommit/test-patch.d/tap.sh index 8de68f1..465b7f1 100755 --- a/precommit/test-patch.d/tap.sh +++ b/precommit/test-patch.d/tap.sh @@ -34,8 +34,7 @@ function tap_parse_args function tap_usage { - echo "TAP Options:" - echo "--tap-log-dir=<dir> Directory relative to the module for tap output (default: \"target/tap\")" + yetus_add_option "--tap-log-dir=<dir>" "Directory relative to the module for tap output (default: \"target/tap\")" } function tap_process_tests http://git-wip-us.apache.org/repos/asf/yetus/blob/ce2240d7/precommit/test-patch.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh index c5ac5ca..4eca16a 100755 --- a/precommit/test-patch.sh +++ b/precommit/test-patch.sh @@ -646,70 +646,89 @@ function relative_dir ## @replaceable no function yetus_usage { - echo "Usage: test-patch.sh [options] patch" - echo + + declare bugsys + + importplugins + + bugsys=$(echo ${BUGSYSTEMS}) + bugsys=${bugsys// /,} + + echo "test-patch.sh [OPTIONS] patch" + echo "" echo "Where:" echo " patch is a file, URL, or bugsystem-compatible location of the patch file" - echo + echo "" echo "Options:" - echo "--basedir=<dir> The directory to apply the patch to (default current directory)" - echo "--branch=<ref> Forcibly set the branch" - echo "--branch-default=<ref> If the branch isn't forced and we don't detect one in the patch name, use this branch (default 'master')" - echo "--build-native=<bool> If true, then build native components (default 'true')" + echo "" + yetus_add_option "--basedir=<dir>" "The directory to apply the patch to (default current directory)" + yetus_add_option "--branch=<ref>" "Forcibly set the branch" + yetus_add_option "--branch-default=<ref>" "If the branch isn't forced and we don't detect one in the patch name, use this branch (default 'master')" + yetus_add_option "--build-native=<bool>" "If true, then build native components (default 'true')" # shellcheck disable=SC2153 - echo "--build-tool=<tool> Pick which build tool to focus around (${BUILDTOOLS})" - echo "--bugcomments=<bug> Only write comments to the screen and this comma delimited list (${BUGSYSTEMS})" - echo "--contrib-guide=<url> URL to point new users towards project conventions. (default: ${PATCH_NAMING_RULE} )" - echo "--debug If set, then output some extra stuff to stderr" - echo "--dirty-workspace Allow the local git workspace to have uncommitted changes" - echo "--docker Spawn a docker container" - echo "--dockercmd=<file> Command to use as docker executable (default: docker from path)" - echo "--dockerfile=<file> Dockerfile fragment to use as the base" - echo "--dockeronfail=<list> If Docker fails, determine fallback method order (default: ${DOCKERFAIL})" - echo "--java-home=<path> Set JAVA_HOME (In Docker mode, this should be local to the image)" - echo "--linecomments=<bug> Only write line comments to this comma delimited list (defaults to bugcomments)" - echo "--list-plugins List all installed plug-ins and then exit" - echo "--multijdkdirs=<paths> Comma delimited lists of JDK paths to use for multi-JDK tests" - echo "--multijdktests=<list> Comma delimited tests to use when multijdkdirs is used. (default: javac,javadoc,unit)" - echo "--modulelist=<list> Specify additional modules to test (comma delimited)" - echo "--offline Avoid connecting to the Internet" - echo "--patch-dir=<dir> The directory for working and output files (default '/tmp/test-patch-${PROJECT_NAME}/pid')" - echo "--personality=<file> The personality file to load" - echo "--project=<name> The short name for project currently using test-patch (default 'yetus')" - echo "--plugins=<list> Specify which plug-ins to add/delete (comma delimited; use 'all' for all found)" - echo " e.g. --plugins=all,-ant,-scalac (all plugins except ant and scalac)" - echo "--resetrepo Forcibly clean the repo" - echo "--run-tests Run all relevant tests below the base directory" - echo "--skip-dirs=<list> Skip following directories for module finding" - echo "--skip-system-plugins Do not load plugins from ${BINDIR}/test-patch.d" - echo "--summarize=<bool> Allow tests to summarize results" - echo "--test-parallel=<bool> Run multiple tests in parallel (default false in developer mode, true in Jenkins mode)" - echo "--test-threads=<int> Number of tests to run in parallel (default defined in ${PROJECT_NAME} build)" - echo "--user-plugins=<dir> A directory of user provided plugins. see test-patch.d for examples (default empty)" - echo "--version Print release version information and exit" + yetus_add_option "--build-tool=<tool>" "Pick which build tool to focus around (one of ${BUILDTOOLS})" + yetus_add_option "--bugcomments=<bug>" "Only write comments to the screen and this comma delimited list (default: ${bugsys})" + yetus_add_option "--contrib-guide=<url>" "URL to point new users towards project conventions. (default: ${PATCH_NAMING_RULE} )" + yetus_add_option "--debug" "If set, then output some extra stuff to stderr" + yetus_add_option "--dirty-workspace" "Allow the local git workspace to have uncommitted changes" + yetus_add_option "--docker" "Spawn a docker container" + yetus_add_option "--dockercmd=<file>" "Command to use as docker executable (default: docker from path)" + yetus_add_option "--dockerfile=<file>" "Dockerfile fragment to use as the base" + yetus_add_option "--dockeronfail=<list>" "If Docker fails, determine fallback method order (default: ${DOCKERFAIL})" + yetus_add_option "--java-home=<path>" "Set JAVA_HOME (In Docker mode, this should be local to the image)" + yetus_add_option "--linecomments=<bug>" "Only write line comments to this comma delimited list (defaults to bugcomments)" + yetus_add_option "--list-plugins" "List all installed plug-ins and then exit" + yetus_add_option "--multijdkdirs=<paths>" "Comma delimited lists of JDK paths to use for multi-JDK tests" + yetus_add_option "--multijdktests=<list>" "Comma delimited tests to use when multijdkdirs is used. (default: javac,javadoc,unit)" + yetus_add_option "--modulelist=<list>" "Specify additional modules to test (comma delimited)" + yetus_add_option "--offline" "Avoid connecting to the Internet" + yetus_add_option "--patch-dir=<dir>" "The directory for working and output files (default '/tmp/test-patch-${PROJECT_NAME}/pid')" + yetus_add_option "--personality=<file>" "The personality file to load" + yetus_add_option "--project=<name>" "The short name for project currently using test-patch (default 'yetus')" + yetus_add_option "--plugins=<list>" "Specify which plug-ins to add/delete (comma delimited; use 'all' for all found) e.g. --plugins=all,-ant,-scalac (all plugins except ant and scalac)" + yetus_add_option "--resetrepo" "Forcibly clean the repo" + yetus_add_option "--run-tests" "Run all relevant tests below the base directory" + yetus_add_option "--skip-dirs=<list>" "Skip following directories for module finding" + yetus_add_option "--skip-system-plugins" "Do not load plugins from ${BINDIR}/test-patch.d" + 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 "--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" + + yetus_generic_columnprinter "${YETUS_OPTION_USAGE[@]}" + yetus_reset_usage + echo "" echo "Shell binary overrides:" - echo "--awk-cmd=<cmd> The 'awk' command to use (default 'awk')" - echo "--curl-cmd=<cmd> The 'curl' command to use (default 'curl')" - echo "--diff-cmd=<cmd> The GNU-compatible 'diff' command to use (default 'diff')" - echo "--file-cmd=<cmd> The 'file' command to use (default 'file')" - echo "--git-cmd=<cmd> The 'git' command to use (default 'git')" - echo "--grep-cmd=<cmd> The 'grep' command to use (default 'grep')" - echo "--patch-cmd=<cmd> The 'patch' command to use (default 'patch')" - echo "--sed-cmd=<cmd> The 'sed' command to use (default 'sed')" - - echo + yetus_add_option "--awk-cmd=<cmd>" "The 'awk' command to use (default 'awk')" + yetus_add_option "--curl-cmd=<cmd>" "The 'curl' command to use (default 'curl')" + yetus_add_option "--diff-cmd=<cmd>" "The GNU-compatible 'diff' command to use (default 'diff')" + yetus_add_option "--file-cmd=<cmd>" "The 'file' command to use (default 'file')" + yetus_add_option "--git-cmd=<cmd>" "The 'git' command to use (default 'git')" + yetus_add_option "--grep-cmd=<cmd>" "The 'grep' command to use (default 'grep')" + yetus_add_option "--patch-cmd=<cmd>" "The 'patch' command to use (default 'patch')" + yetus_add_option "--sed-cmd=<cmd>" "The 'sed' command to use (default 'sed')" + + yetus_generic_columnprinter "${YETUS_OPTION_USAGE[@]}" + yetus_reset_usage + + echo "" echo "Jenkins-only options:" - echo "--jenkins Jenkins mode" - echo "--build-url Set the build location web page" - echo "--mv-patch-dir Move the patch-dir into the basedir during cleanup." + yetus_add_option "--jenkins" "Jenkins mode" + yetus_add_option "--build-url" "Set the build location web page" + yetus_add_option "--mv-patch-dir" "Move the patch-dir into the basedir during cleanup." - importplugins + yetus_generic_columnprinter "${YETUS_OPTION_USAGE[@]}" + yetus_reset_usage for plugin in ${BUILDTOOLS} ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS}; do if declare -f ${plugin}_usage >/dev/null 2>&1; then - echo + echo "" + echo "'${plugin}' plugin usage options:" "${plugin}_usage" + yetus_generic_columnprinter "${YETUS_OPTION_USAGE[@]}" + yetus_reset_usage fi done }
