You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by bu...@apache.org on 2015/10/28 05:31:36 UTC
[01/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Repository: yetus
Updated Branches:
refs/heads/master 357181410 -> 6f38afa5a
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/release-doc-maker/releasedocmaker.py
----------------------------------------------------------------------
diff --git a/release-doc-maker/releasedocmaker.py b/release-doc-maker/releasedocmaker.py
new file mode 100755
index 0000000..ae3ce45
--- /dev/null
+++ b/release-doc-maker/releasedocmaker.py
@@ -0,0 +1,642 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from glob import glob
+from optparse import OptionParser
+from time import gmtime, strftime
+from distutils.version import LooseVersion
+import os
+import re
+import sys
+import urllib
+import urllib2
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
+RELEASE_VERSION = {}
+NAME_PATTERN = re.compile(r' \([0-9]+\)')
+RELNOTE_PATTERN = re.compile('^\<\!\-\- ([a-z]+) \-\-\>')
+
+ASF_LICENSE = '''
+<!---
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+-->
+'''
+
+def clean(_str):
+ return tableclean(re.sub(NAME_PATTERN, "", _str))
+
+def format_components(_str):
+ _str = re.sub(NAME_PATTERN, '', _str).replace("'", "")
+ if _str != "":
+ ret = _str
+ else:
+ # some markdown parsers don't like empty tables
+ ret = "."
+ return clean(ret)
+
+# convert to utf-8
+# protect some known md metachars
+# or chars that screw up doxia
+def tableclean(_str):
+ _str = _str.encode('utf-8')
+ _str = _str.replace("_", r"\_")
+ _str = _str.replace("\r", "")
+ _str = _str.rstrip()
+ return _str
+
+# same thing as tableclean,
+# except table metachars are also
+# escaped as well as more
+# things we don't want doxia to
+# screw up
+def notableclean(_str):
+ _str = tableclean(_str)
+ _str = _str.replace("|", r"\|")
+ _str = _str.replace("<", r"\<")
+ _str = _str.replace(">", r"\>")
+ _str = _str.replace("*", r"\*")
+ _str = _str.rstrip()
+ return _str
+
+# if release notes have a special marker,
+# we'll treat them as already in markdown format
+def processrelnote(_str):
+ fmt = RELNOTE_PATTERN.match(_str)
+ if fmt is None:
+ return notableclean(_str)
+ else:
+ return {
+ 'markdown' : tableclean(_str),
+ }.get(fmt.group(1),notableclean(_str))
+
+# clean output dir
+def clean_output_dir(directory):
+ files = os.listdir(directory)
+ for name in files:
+ os.remove(os.path.join(directory, name))
+ os.rmdir(directory)
+
+def mstr(obj):
+ if obj is None:
+ return ""
+ return unicode(obj)
+
+def buildindex(title, asf_license):
+ """Write an index file for later conversion using mvn site"""
+ versions = glob("[0-9]*.[0-9]*.[0-9]*")
+ versions.sort(key=LooseVersion, reverse=True)
+ with open("index.md", "w") as indexfile:
+ if asf_license is True:
+ indexfile.write(ASF_LICENSE)
+ for version in versions:
+ indexfile.write("* %s v%s\n" % (title, version))
+ for k in ("Changes", "Release Notes"):
+ indexfile.write(" * [%s](%s/%s.%s.html)\n" \
+ % (k, version, k.upper().replace(" ", ""), version))
+
+def buildreadme(title, asf_license):
+ """Write an index file for Github using README.md"""
+ versions = glob("[0-9]*.[0-9]*.[0-9]*")
+ versions.sort(key=LooseVersion, reverse=True)
+ with open("README.md", "w") as indexfile:
+ if asf_license is True:
+ indexfile.write(ASF_LICENSE)
+ for version in versions:
+ indexfile.write("* %s v%s\n" % (title, version))
+ for k in ("Changes", "Release Notes"):
+ indexfile.write(" * [%s](%s/%s.%s.md)\n" \
+ % (k, version, k.upper().replace(" ", ""), version))
+
+class GetVersions(object):
+ """ List of version strings """
+ def __init__(self, versions, projects):
+ versions = versions
+ projects = projects
+ self.newversions = []
+ versions.sort(key=LooseVersion)
+ print "Looking for %s through %s"%(versions[0], versions[-1])
+ for project in projects:
+ url = "https://issues.apache.org/jira/rest/api/2/project/%s/versions" % project
+ resp = urllib2.urlopen(url)
+ datum = json.loads(resp.read())
+ for data in datum:
+ name = data['name']
+ if name[0].isdigit and versions[0] <= name and name <= versions[-1]:
+ print "Adding %s to the list" % name
+ self.newversions.append(name)
+ newlist = list(set(self.newversions))
+ self.newversions = newlist
+
+ def getlist(self):
+ return self.newversions
+
+class Version(object):
+ """Represents a version number"""
+ def __init__(self, data):
+ self.mod = False
+ self.data = data
+ found = re.match(r'^((\d+)(\.\d+)*).*$', data)
+ if found:
+ self.parts = [int(p) for p in found.group(1).split('.')]
+ else:
+ self.parts = []
+ # backfill version with zeroes if missing parts
+ self.parts.extend((0,) * (3 - len(self.parts)))
+
+ def __str__(self):
+ if self.mod:
+ return '.'.join([str(p) for p in self.parts])
+ return self.data
+
+ def __cmp__(self, other):
+ return cmp(self.parts, other.parts)
+
+class Jira(object):
+ """A single JIRA"""
+
+ def __init__(self, data, parent):
+ self.key = data['key']
+ self.fields = data['fields']
+ self.parent = parent
+ self.notes = None
+ self.incompat = None
+ self.reviewed = None
+ self.important = None
+
+ def get_id(self):
+ return mstr(self.key)
+
+ def get_description(self):
+ return mstr(self.fields['description'])
+
+ def get_release_note(self):
+ if self.notes is None:
+ field = self.parent.field_id_map['Release Note']
+ if self.fields.has_key(field):
+ self.notes = mstr(self.fields[field])
+ elif self.get_incompatible_change() or self.get_important():
+ self.notes = self.get_description()
+ else:
+ self.notes = ""
+ return self.notes
+
+ def get_priority(self):
+ ret = ""
+ pri = self.fields['priority']
+ if pri is not None:
+ ret = pri['name']
+ return mstr(ret)
+
+ def get_assignee(self):
+ ret = ""
+ mid = self.fields['assignee']
+ if mid is not None:
+ ret = mid['displayName']
+ return mstr(ret)
+
+ def get_components(self):
+ if len(self.fields['components']) > 0:
+ return ", ".join([comp['name'] for comp in self.fields['components']])
+ else:
+ return ""
+
+ def get_summary(self):
+ return self.fields['summary']
+
+ def get_type(self):
+ ret = ""
+ mid = self.fields['issuetype']
+ if mid is not None:
+ ret = mid['name']
+ return mstr(ret)
+
+ def get_reporter(self):
+ ret = ""
+ mid = self.fields['reporter']
+ if mid is not None:
+ ret = mid['displayName']
+ return mstr(ret)
+
+ def get_project(self):
+ ret = ""
+ mid = self.fields['project']
+ if mid is not None:
+ ret = mid['key']
+ return mstr(ret)
+
+ def __cmp__(self, other):
+ selfsplit = self.get_id().split('-')
+ othersplit = other.get_id().split('-')
+ result = cmp(selfsplit[0], othersplit[0])
+ if result != 0:
+ return result
+ else:
+ if selfsplit[1] < othersplit[1]:
+ return True
+ elif selfsplit[1] > othersplit[1]:
+ return False
+ return False
+
+ def get_incompatible_change(self):
+ if self.incompat is None:
+ field = self.parent.field_id_map['Hadoop Flags']
+ self.reviewed = False
+ self.incompat = False
+ if self.fields.has_key(field):
+ if self.fields[field]:
+ for flag in self.fields[field]:
+ if flag['value'] == "Incompatible change":
+ self.incompat = True
+ if flag['value'] == "Reviewed":
+ self.reviewed = True
+ return self.incompat
+
+ def get_important(self):
+ if self.important is None:
+ field = self.parent.field_id_map['Flags']
+ self.important = False
+ if self.fields.has_key(field):
+ if self.fields[field]:
+ for flag in self.fields[field]:
+ if flag['value'] == "Important":
+ self.important = True
+ return self.important
+
+ def check_missing_component(self):
+ if len(self.fields['components']) > 0:
+ return False
+ return True
+
+ def check_missing_assignee(self):
+ if self.fields['assignee'] is not None:
+ return False
+ return True
+
+ def check_version_string(self):
+ field = self.parent.field_id_map['Fix Version/s']
+ for ver in self.fields[field]:
+ found = re.match(r'^((\d+)(\.\d+)*).*$|^(\w+\-\d+)$', ver['name'])
+ if not found:
+ return True
+ return False
+
+ def get_release_date(self, version):
+ fix_versions = self.fields['fixVersions']
+ for j in range(len(fix_versions)):
+ if fix_versions[j] == version:
+ return fix_versions[j]['releaseDate']
+ return None
+
+class JiraIter(object):
+ """An Iterator of JIRAs"""
+
+ def __init__(self, version, projects):
+ self.version = version
+ self.projects = projects
+ ver = str(version).replace("-SNAPSHOT", "")
+
+ resp = urllib2.urlopen("https://issues.apache.org/jira/rest/api/2/field")
+ data = json.loads(resp.read())
+
+ self.field_id_map = {}
+ for part in data:
+ self.field_id_map[part['name']] = part['id']
+
+ self.jiras = []
+ pos = 0
+ end = 1
+ count = 100
+ while pos < end:
+ pjs = "','".join(projects)
+ jql = "project in ('%s') and fixVersion in ('%s') and resolution = Fixed" % (pjs, ver)
+ params = urllib.urlencode({'jql': jql, 'startAt':pos, 'maxResults':count})
+ resp = urllib2.urlopen("https://issues.apache.org/jira/rest/api/2/search?%s" % params)
+ data = json.loads(resp.read())
+ if data.has_key('error_messages'):
+ raise Exception(data['error_messages'])
+ pos = data['startAt'] + data['maxResults']
+ end = data['total']
+ self.jiras.extend(data['issues'])
+
+ needaversion = False
+ if ver not in RELEASE_VERSION:
+ needaversion = True
+
+ if needaversion is True:
+ issues = data['issues']
+ for i in range(len(issues)):
+ fix_versions = issues[i]['fields']['fixVersions']
+ for j in range(len(fix_versions)):
+ fields = fix_versions[j]
+ if 'releaseDate' in fields:
+ RELEASE_VERSION[fields['name']] = fields['releaseDate']
+
+ self.iter = self.jiras.__iter__()
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ data = self.iter.next()
+ j = Jira(data, self)
+ return j
+
+class Outputs(object):
+ """Several different files to output to at the same time"""
+
+ def __init__(self, base_file_name, file_name_pattern, keys, params=None):
+ if params is None:
+ params = {}
+ self.params = params
+ self.base = open(base_file_name%params, 'w')
+ self.others = {}
+ for key in keys:
+ both = dict(params)
+ both['key'] = key
+ self.others[key] = open(file_name_pattern%both, 'w')
+
+ def write_all(self, pattern):
+ both = dict(self.params)
+ both['key'] = ''
+ self.base.write(pattern%both)
+ for key in self.others.keys():
+ both = dict(self.params)
+ both['key'] = key
+ self.others[key].write(pattern%both)
+
+ def write_key_raw(self, key, _str):
+ self.base.write(_str)
+ if self.others.has_key(key):
+ self.others[key].write(_str)
+
+ def close(self):
+ self.base.close()
+ for value in self.others.values():
+ value.close()
+
+ def write_list(self, mylist):
+ for jira in sorted(mylist):
+ line = '| [%s](https://issues.apache.org/jira/browse/%s) | %s | %s | %s | %s | %s |\n'
+ line = line % (notableclean(jira.get_id()),
+ notableclean(jira.get_id()),
+ notableclean(jira.get_summary()),
+ notableclean(jira.get_priority()),
+ format_components(jira.get_components()),
+ notableclean(jira.get_reporter()),
+ notableclean(jira.get_assignee()))
+ self.write_key_raw(jira.get_project(), line)
+
+def main():
+ usage = "usage: %prog --project PROJECT [--project PROJECT] --version VERSION [--version VERSION2 ...]"
+ parser = OptionParser(usage=usage,
+ epilog="Markdown-formatted CHANGES and RELEASENOTES files will be stored"
+ "in a directory named after the highest version provided.")
+ parser.add_option("-i", "--index", dest="index", action="store_true",
+ default=False, help="build an index file")
+ parser.add_option("-l", "--license", dest="license", action="store_false",
+ default=True, help="Add an ASF license")
+ parser.add_option("-n", "--lint", dest="lint", action="store_true",
+ help="use lint flag to exit on failures")
+ parser.add_option("-p", "--project", dest="projects",
+ action="append", type="string",
+ help="projects in JIRA to include in releasenotes", metavar="PROJECT")
+ parser.add_option("-r", "--range", dest="range", action="store_true",
+ default=False, help="Given versions are a range")
+ parser.add_option("-t", "--projecttitle", dest="title", type="string",
+ help="Title to use for the project (default is Apache PROJECT)")
+ parser.add_option("-u", "--usetoday", dest="usetoday", action="store_true",
+ default=False, help="use current date for unreleased versions")
+ parser.add_option("-v", "--version", dest="versions", action="append", type="string",
+ help="versions in JIRA to include in releasenotes", metavar="VERSION")
+ (options, _) = parser.parse_args()
+
+ if options.versions is None:
+ parser.error("At least one version needs to be supplied")
+
+ proxy = urllib2.ProxyHandler()
+ opener = urllib2.build_opener(proxy)
+ urllib2.install_opener(opener)
+
+ projects = options.projects
+ if projects is None:
+ parser.error("At least one project needs to be supplied")
+
+ if options.range is True:
+ versions = [Version(v) for v in GetVersions(options.versions, projects).getlist()]
+ else:
+ versions = [Version(v) for v in options.versions]
+ versions.sort()
+
+ if options.title is None:
+ title = projects[0]
+ else:
+ title = options.title
+
+ haderrors = False
+
+ for version in versions:
+ vstr = str(version)
+ jlist = JiraIter(vstr, projects)
+
+ if vstr in RELEASE_VERSION:
+ reldate = RELEASE_VERSION[vstr]
+ elif options.usetoday:
+ reldate = strftime("%Y-%m-%d", gmtime())
+ else:
+ reldate = "Unreleased (as of %s)" % strftime("%Y-%m-%d", gmtime())
+
+ if not os.path.exists(vstr):
+ os.mkdir(vstr)
+
+ reloutputs = Outputs("%(ver)s/RELEASENOTES.%(ver)s.md",
+ "%(ver)s/RELEASENOTES.%(key)s.%(ver)s.md",
+ [], {"ver":version, "date":reldate, "title":title})
+ choutputs = Outputs("%(ver)s/CHANGES.%(ver)s.md",
+ "%(ver)s/CHANGES.%(key)s.%(ver)s.md",
+ [], {"ver":version, "date":reldate, "title":title})
+
+ if options.license is True:
+ reloutputs.write_all(ASF_LICENSE)
+ choutputs.write_all(ASF_LICENSE)
+
+ relhead = '# %(title)s %(key)s %(ver)s Release Notes\n\n' \
+ 'These release notes cover new developer and user-facing ' \
+ 'incompatibilities, important issues, features, and major improvements.\n\n'
+ chhead = '# %(title)s Changelog\n\n' \
+ '## Release %(ver)s - %(date)s\n'\
+ '\n'
+
+ reloutputs.write_all(relhead)
+ choutputs.write_all(chhead)
+ error_count = 0
+ warning_count = 0
+ lint_message = ""
+ incompatlist = []
+ importantlist = []
+ buglist = []
+ improvementlist = []
+ newfeaturelist = []
+ subtasklist = []
+ tasklist = []
+ testlist = []
+ otherlist = []
+
+ for jira in sorted(jlist):
+ if jira.get_incompatible_change():
+ incompatlist.append(jira)
+ elif jira.get_important():
+ importantlist.append(jira)
+ elif jira.get_type() == "Bug":
+ buglist.append(jira)
+ elif jira.get_type() == "Improvement":
+ improvementlist.append(jira)
+ elif jira.get_type() == "New Feature":
+ newfeaturelist.append(jira)
+ elif jira.get_type() == "Sub-task":
+ subtasklist.append(jira)
+ elif jira.get_type() == "Task":
+ tasklist.append(jira)
+ elif jira.get_type() == "Test":
+ testlist.append(jira)
+ else:
+ otherlist.append(jira)
+
+ line = '* [%s](https://issues.apache.org/jira/browse/%s) | *%s* | **%s**\n' \
+ % (notableclean(jira.get_id()), notableclean(jira.get_id()),
+ notableclean(jira.get_priority()), notableclean(jira.get_summary()))
+
+ if jira.get_incompatible_change() and len(jira.get_release_note()) == 0:
+ warning_count += 1
+ reloutputs.write_key_raw(jira.get_project(), "\n---\n\n")
+ reloutputs.write_key_raw(jira.get_project(), line)
+ line = '\n**WARNING: No release note provided for this incompatible change.**\n\n'
+ lint_message += "\nWARNING: incompatible change %s lacks release notes." % \
+ (notableclean(jira.get_id()))
+ reloutputs.write_key_raw(jira.get_project(), line)
+
+ if jira.get_important() and len(jira.get_release_note()) == 0:
+ warning_count += 1
+ reloutputs.write_key_raw(jira.get_project(), "\n---\n\n")
+ reloutputs.write_key_raw(jira.get_project(), line)
+ line = '\n**WARNING: No release note provided for this important issue.**\n\n'
+ lint_message += "\nWARNING: important issue %s lacks release notes." % \
+ (notableclean(jira.get_id()))
+ reloutputs.write_key_raw(jira.get_project(), line)
+
+ if jira.check_version_string():
+ warning_count += 1
+ lint_message += "\nWARNING: Version string problem for %s " % jira.get_id()
+
+ if jira.check_missing_component() or jira.check_missing_assignee():
+ error_count += 1
+ error_message = []
+ if jira.check_missing_component():
+ error_message.append("component")
+ if jira.check_missing_assignee():
+ error_message.append("assignee")
+ lint_message += "\nERROR: missing %s for %s " \
+ % (" and ".join(error_message), jira.get_id())
+
+ if len(jira.get_release_note()) > 0:
+ reloutputs.write_key_raw(jira.get_project(), "\n---\n\n")
+ reloutputs.write_key_raw(jira.get_project(), line)
+ line = '\n%s\n\n' % (processrelnote(jira.get_release_note()))
+ reloutputs.write_key_raw(jira.get_project(), line)
+
+ if options.lint is True:
+ print lint_message
+ print "======================================="
+ print "%s: Error:%d, Warning:%d \n" % (vstr, error_count, warning_count)
+ if error_count > 0:
+ haderrors = True
+ clean_output_dir(vstr)
+ continue
+
+ reloutputs.write_all("\n\n")
+ reloutputs.close()
+
+ choutputs.write_all("### INCOMPATIBLE CHANGES:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(incompatlist)
+
+ choutputs.write_all("\n\n### IMPORTANT ISSUES:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(importantlist)
+
+ choutputs.write_all("\n\n### NEW FEATURES:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(newfeaturelist)
+
+ choutputs.write_all("\n\n### IMPROVEMENTS:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(improvementlist)
+
+ choutputs.write_all("\n\n### BUG FIXES:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(buglist)
+
+ choutputs.write_all("\n\n### TESTS:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(testlist)
+
+ choutputs.write_all("\n\n### SUB-TASKS:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(subtasklist)
+
+ choutputs.write_all("\n\n### OTHER:\n\n")
+ choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
+ choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
+ choutputs.write_list(otherlist)
+ choutputs.write_list(tasklist)
+
+ choutputs.write_all("\n\n")
+ choutputs.close()
+
+ if options.index:
+ buildindex(title, options.license)
+ buildreadme(title, options.license)
+
+ if haderrors is True:
+ sys.exit(1)
+
+if __name__ == "__main__":
+ main()
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/shelldocs/shelldocs.py
----------------------------------------------------------------------
diff --git a/shelldocs/shelldocs.py b/shelldocs/shelldocs.py
new file mode 100755
index 0000000..7a1fe21
--- /dev/null
+++ b/shelldocs/shelldocs.py
@@ -0,0 +1,274 @@
+#!/usr/bin/python
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import re
+import sys
+import string
+from optparse import OptionParser
+
+asflicense='''
+<!---
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+-->
+'''
+
+def docstrip(key,string):
+ string=re.sub("^## @%s " % key ,"",string)
+ string=string.lstrip()
+ string=string.rstrip()
+ return string
+
+def toc(list):
+ tocout=[]
+ header=()
+ for i in list:
+ if header != i.getinter():
+ header=i.getinter()
+ line=" * %s\n" % (i.headerbuild())
+ tocout.append(line)
+ line=" * [%s](#%s)\n" % (i.getname().replace("_","\_"),i.getname())
+ tocout.append(line)
+ return tocout
+
+class ShellFunction:
+ def __init__(self):
+ self.reset()
+
+ def __cmp__(self,other):
+ if (self.audience == other.audience):
+ if (self.stability == other.stability):
+ if (self.replaceb == other.replaceb):
+ return(cmp(self.name,other.name))
+ else:
+ if (self.replaceb == "Yes"):
+ return -1
+ else:
+ return 1
+ else:
+ if (self.stability == "Stable"):
+ return -1
+ else:
+ return 1
+ else:
+ if (self.audience == "Public"):
+ return -1
+ else:
+ return 1
+
+ def reset(self):
+ self.name=None
+ self.audience=None
+ self.stability=None
+ self.replaceb=None
+ self.returnt=None
+ self.desc=None
+ self.params=None
+
+ def setname(self,text):
+ definition=text.split();
+ self.name=definition[1]
+
+ def getname(self):
+ if (self.name is None):
+ return "None"
+ else:
+ return self.name
+
+ def setaudience(self,text):
+ self.audience=docstrip("audience",text)
+ self.audience=self.audience.capitalize()
+
+ def getaudience(self):
+ if (self.audience is None):
+ return "None"
+ else:
+ return self.audience
+
+ def setstability(self,text):
+ self.stability=docstrip("stability",text)
+ self.stability=self.stability.capitalize()
+
+ def getstability(self):
+ if (self.stability is None):
+ return "None"
+ else:
+ return self.stability
+
+ def setreplace(self,text):
+ self.replaceb=docstrip("replaceable",text)
+ self.replaceb=self.replaceb.capitalize()
+
+ def getreplace(self):
+ if (self.replaceb is None):
+ return "None"
+ else:
+ return self.replaceb
+
+ def getinter(self):
+ return( (self.getaudience(), self.getstability(), self.getreplace()))
+
+ def addreturn(self,text):
+ if (self.returnt is None):
+ self.returnt = []
+ self.returnt.append(docstrip("return",text))
+
+ def getreturn(self):
+ if (self.returnt is None):
+ return "Nothing"
+ else:
+ return "\n\n".join(self.returnt)
+
+ def adddesc(self,text):
+ if (self.desc is None):
+ self.desc = []
+ self.desc.append(docstrip("description",text))
+
+ def getdesc(self):
+ if (self.desc is None):
+ return "None"
+ else:
+ return " ".join(self.desc)
+
+ def addparam(self,text):
+ if (self.params is None):
+ self.params = []
+ self.params.append(docstrip("param",text))
+
+ def getparams(self):
+ if (self.params is None):
+ return ""
+ else:
+ return " ".join(self.params)
+
+ def getusage(self):
+ line="%s %s" % (self.name, self.getparams())
+ return line
+
+ def headerbuild(self):
+ if self.getreplace() == "Yes":
+ replacetext="Replaceable"
+ else:
+ replacetext="Not Replaceable"
+ line="%s/%s/%s" % (self.getaudience(), self.getstability(), replacetext)
+ return(line)
+
+ def getdocpage(self):
+ line="### `%s`\n\n"\
+ "* Synopsis\n\n"\
+ "```\n%s\n"\
+ "```\n\n" \
+ "* Description\n\n" \
+ "%s\n\n" \
+ "* Returns\n\n" \
+ "%s\n\n" \
+ "| Classification | Level |\n" \
+ "| :--- | :--- |\n" \
+ "| Audience | %s |\n" \
+ "| Stability | %s |\n" \
+ "| Replaceable | %s |\n\n" \
+ % (self.getname(),
+ self.getusage(),
+ self.getdesc(),
+ self.getreturn(),
+ self.getaudience(),
+ self.getstability(),
+ self.getreplace())
+ return line
+
+ def __str__(self):
+ line="{%s %s %s %s}" \
+ % (self.getname(),
+ self.getaudience(),
+ self.getstability(),
+ self.getreplace())
+ return line
+
+def main():
+ parser=OptionParser(usage="usage: %prog --skipprnorep --output OUTFILE --input INFILE [--input INFILE ...]")
+ parser.add_option("-o","--output", dest="outfile",
+ action="store", type="string",
+ help="file to create", metavar="OUTFILE")
+ parser.add_option("-i","--input", dest="infile",
+ action="append", type="string",
+ help="file to read", metavar="INFILE")
+ parser.add_option("--skipprnorep", dest="skipprnorep",
+ action="store_true", help="Skip Private & Not Replaceable")
+
+ (options, args)=parser.parse_args()
+
+ allfuncs=[]
+ for filename in options.infile:
+ with open(filename,"r") as shellcode:
+ funcdef=ShellFunction()
+ for line in shellcode:
+ if line.startswith('## @description'):
+ funcdef.adddesc(line)
+ elif line.startswith('## @audience'):
+ funcdef.setaudience(line)
+ elif line.startswith('## @stability'):
+ funcdef.setstability(line)
+ elif line.startswith('## @replaceable'):
+ funcdef.setreplace(line)
+ elif line.startswith('## @param'):
+ funcdef.addparam(line)
+ elif line.startswith('## @return'):
+ funcdef.addreturn(line)
+ elif line.startswith('function'):
+ funcdef.setname(line)
+ if options.skipprnorep and \
+ funcdef.getaudience() == "Private" and \
+ funcdef.getreplace() == "No":
+ pass
+ else:
+ allfuncs.append(funcdef)
+ funcdef=ShellFunction()
+
+ allfuncs=sorted(allfuncs)
+
+ outfile=open(options.outfile, "w")
+ outfile.write(asflicense)
+ for line in toc(allfuncs):
+ outfile.write(line)
+
+ outfile.write("\n------\n\n")
+
+ header=[]
+ for funcs in allfuncs:
+ if header != funcs.getinter():
+ header=funcs.getinter()
+ line="## %s\n" % (funcs.headerbuild())
+ outfile.write(line)
+ outfile.write(funcs.getdocpage())
+ outfile.close()
+
+if __name__ == "__main__":
+ main()
+
[10/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
YETUS-6 Reoganize repository for split to TLP.
move things out into top level components:
- precommit for test-patch and smart-apply-patch
- shelldocs
- release-doc-maker
Adds a README that warns about temporary nature of layout.
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/6f38afa5
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/6f38afa5
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/6f38afa5
Branch: refs/heads/master
Commit: 6f38afa5a0c6b27df8ca56f069b4f4a860e727a7
Parents: 3571814
Author: Sean Busbey <bu...@apache.org>
Authored: Fri Oct 23 23:23:49 2015 -0500
Committer: Sean Busbey <bu...@apache.org>
Committed: Tue Oct 27 23:30:37 2015 -0500
----------------------------------------------------------------------
README.md | 51 +
dev-support/core.d/00-yetuslib.sh | 95 -
dev-support/core.d/01-common.sh | 469 ----
dev-support/core.d/builtin-bugsystem.sh | 149 -
dev-support/core.d/builtin-personality.sh | 29 -
dev-support/core.d/patchfiles.sh | 330 ---
dev-support/personality/bigtop.sh | 72 -
dev-support/personality/flink.sh | 115 -
dev-support/personality/geode.sh | 18 -
dev-support/personality/hadoop.sh | 376 ---
dev-support/personality/hbase.sh | 236 --
dev-support/personality/kafka.sh | 63 -
dev-support/personality/pig.sh | 64 -
dev-support/personality/samza.sh | 32 -
dev-support/personality/tajo.sh | 29 -
dev-support/personality/tez.sh | 29 -
dev-support/releasedocmaker.py | 642 -----
dev-support/shelldocs.py | 274 --
dev-support/smart-apply-patch.sh | 251 --
.../test-patch-docker/Dockerfile-endstub | 19 -
.../test-patch-docker/Dockerfile-startstub | 91 -
.../test-patch-docker/launch-test-patch.sh | 50 -
.../test-patch-docker/test-patch-docker.sh | 388 ---
dev-support/test-patch.d/ant.sh | 201 --
dev-support/test-patch.d/asflicense.sh | 194 --
dev-support/test-patch.d/author.sh | 52 -
dev-support/test-patch.d/cc.sh | 63 -
dev-support/test-patch.d/checkstyle.sh | 237 --
dev-support/test-patch.d/findbugs.sh | 411 ---
dev-support/test-patch.d/github.sh | 492 ----
dev-support/test-patch.d/gradle.sh | 263 --
dev-support/test-patch.d/java.sh | 168 --
dev-support/test-patch.d/jira.sh | 436 ---
dev-support/test-patch.d/junit.sh | 68 -
dev-support/test-patch.d/maven.sh | 440 ---
dev-support/test-patch.d/nobuild.sh | 55 -
dev-support/test-patch.d/perlcritic.sh | 151 -
dev-support/test-patch.d/pylint.sh | 179 --
dev-support/test-patch.d/rubocop.sh | 151 -
dev-support/test-patch.d/ruby-lint.sh | 151 -
dev-support/test-patch.d/scala.sh | 77 -
dev-support/test-patch.d/shellcheck.sh | 176 --
dev-support/test-patch.d/tap.sh | 80 -
dev-support/test-patch.d/test4tests.sh | 58 -
dev-support/test-patch.d/whitespace.sh | 92 -
dev-support/test-patch.d/xml.sh | 74 -
dev-support/test-patch.sh | 2647 ------------------
precommit/core.d/00-yetuslib.sh | 95 +
precommit/core.d/01-common.sh | 469 ++++
precommit/core.d/builtin-bugsystem.sh | 149 +
precommit/core.d/builtin-personality.sh | 29 +
precommit/core.d/patchfiles.sh | 330 +++
precommit/personality/bigtop.sh | 72 +
precommit/personality/flink.sh | 115 +
precommit/personality/geode.sh | 18 +
precommit/personality/hadoop.sh | 376 +++
precommit/personality/hbase.sh | 236 ++
precommit/personality/kafka.sh | 63 +
precommit/personality/pig.sh | 64 +
precommit/personality/samza.sh | 32 +
precommit/personality/tajo.sh | 29 +
precommit/personality/tez.sh | 29 +
precommit/smart-apply-patch.sh | 251 ++
precommit/test-patch-docker/Dockerfile-endstub | 19 +
.../test-patch-docker/Dockerfile-startstub | 91 +
.../test-patch-docker/launch-test-patch.sh | 50 +
.../test-patch-docker/test-patch-docker.sh | 388 +++
precommit/test-patch.d/ant.sh | 201 ++
precommit/test-patch.d/asflicense.sh | 194 ++
precommit/test-patch.d/author.sh | 52 +
precommit/test-patch.d/cc.sh | 63 +
precommit/test-patch.d/checkstyle.sh | 237 ++
precommit/test-patch.d/findbugs.sh | 411 +++
precommit/test-patch.d/github.sh | 492 ++++
precommit/test-patch.d/gradle.sh | 263 ++
precommit/test-patch.d/java.sh | 168 ++
precommit/test-patch.d/jira.sh | 436 +++
precommit/test-patch.d/junit.sh | 68 +
precommit/test-patch.d/maven.sh | 440 +++
precommit/test-patch.d/nobuild.sh | 55 +
precommit/test-patch.d/perlcritic.sh | 151 +
precommit/test-patch.d/pylint.sh | 179 ++
precommit/test-patch.d/rubocop.sh | 151 +
precommit/test-patch.d/ruby-lint.sh | 151 +
precommit/test-patch.d/scala.sh | 77 +
precommit/test-patch.d/shellcheck.sh | 176 ++
precommit/test-patch.d/tap.sh | 80 +
precommit/test-patch.d/test4tests.sh | 58 +
precommit/test-patch.d/whitespace.sh | 92 +
precommit/test-patch.d/xml.sh | 74 +
precommit/test-patch.sh | 2647 ++++++++++++++++++
release-doc-maker/releasedocmaker.py | 642 +++++
shelldocs/shelldocs.py | 274 ++
93 files changed, 10788 insertions(+), 10737 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c9d16d3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,51 @@
+<!---
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+# Apache Yetus Source
+
+Apache Yetus is a collection of libraries and tools that enable
+contribution and release process for software projects.
+
+> :warning: **A Note About Repository Layout**
+> Yetus currently has no unified build tool, so individual components handle their own tooling. The current layout
+> is temporary until such time as we adopt a project-wide build system. For more information, watch
+> [YETUS-125](https://issues.apache.org/jira/browse/YETUS-125)
+
+The current repository is broken up by major component:
+
+* [Website source](asf-site-src/)
+Holds our documentation, which is presented via [our website](https://yetus.apache.org/).
+See the [guide to contributing](asf-site-src/source/contribute.html.md) for instructions on building the rendered
+version.
+* [Precommit](precommit/)
+Precommit provides robust tools to deal with contributions, including applying patches from a variety of project sources
+and evaluating them against project norms via a system of plugins. See the
+[precommit overview](asf-site-src/source/documentation/latest/precommit-architecture.md) to get started working with
+precommit. Note that even if the top level layout doesn't change, the layout of Precommit might when it adds in
+unit tests under [YETUS-15](https://issues.apache.org/jira/browse/YETUS-15).
+* [Yetus Project Pom](yetus-project/)
+Provides common configuration and dependency management for Yetus' java based component. Currently
+builds with Maven 3.2.0+.
+* [Audience Annotations](audience-annotations/)
+Audience Annotations allows projects to use Java Annotations to delineate public and non-public parts of their APIs.
+It also provides doclets to generate javadocs filtered by intended audience. Currently builds with Maven 3.2.0+.
+* [Shelldocs](shelldocs/)
+Shelldocs processes comments on Bash functions for a annotations similar to Javadoc. It also includes built in
+audience scoping functionality similar to the doclet from Audience Annotations.
+* [Release Doc Maker](release-doc-maker/)
+Release Doc Maker analyzes Jira and Git information to produce Markdown formatted release notes.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/core.d/00-yetuslib.sh
----------------------------------------------------------------------
diff --git a/dev-support/core.d/00-yetuslib.sh b/dev-support/core.d/00-yetuslib.sh
deleted file mode 100644
index 6ab6682..0000000
--- a/dev-support/core.d/00-yetuslib.sh
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-## @description Print a message to stderr
-## @audience public
-## @stability stable
-## @replaceable no
-## @param string
-function yetus_error
-{
- echo "$*" 1>&2
-}
-
-## @description Print a message to stderr if --debug is turned on
-## @audience public
-## @stability stable
-## @replaceable no
-## @param string
-function yetus_debug
-{
- if [[ "${YETUS_SHELL_SCRIPT_DEBUG}" = true ]]; then
- echo "[$(date) DEBUG]: $*" 1>&2
- fi
-}
-
-## @description Given variable $1 delete $2 from it
-## @audience public
-## @stability stable
-## @replaceable no
-function yetus_delete_entry
-{
- if [[ ${!1} =~ \ ${2}\ ]] ; then
- yetus_debug "Removing ${2} from ${1}"
- eval "${1}"=\""${!1// ${2} }"\"
- fi
-}
-
-## @description Given variable $1 add $2 to it
-## @audience public
-## @stability stable
-## @replaceable no
-function yetus_add_entry
-{
- if [[ ! ${!1} =~ \ ${2}\ ]] ; then
- yetus_debug "Adding ${2} to ${1}"
- #shellcheck disable=SC2140
- eval "${1}"=\""${!1} ${2} "\"
- fi
-}
-
-## @description Given variable $1 determine if $2 is in it
-## @audience public
-## @stability stable
-## @replaceable no
-## @returns 1 = yes, 0 = no
-function yetus_verify_entry
-{
- [[ ! ${!1} =~ \ ${2}\ ]]
-}
-
-## @description run the command, sending stdout and stderr to the given filename
-## @audience public
-## @stability stable
-## @param filename
-## @param command
-## @param [..]
-## @replaceable no
-## @returns $?
-function yetus_run_and_redirect
-{
- declare logfile=$1
- shift
-
- # to the log
- {
- date
- echo "cd $(pwd)"
- echo "${*}"
- } >> "${logfile}"
- # run the actual command
- "${@}" >> "${logfile}" 2>&1
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/core.d/01-common.sh
----------------------------------------------------------------------
diff --git a/dev-support/core.d/01-common.sh b/dev-support/core.d/01-common.sh
deleted file mode 100755
index 2110f75..0000000
--- a/dev-support/core.d/01-common.sh
+++ /dev/null
@@ -1,469 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-## @description Setup the default global variables
-## @audience public
-## @stability stable
-## @replaceable no
-function common_defaults
-{
- #shellcheck disable=SC2034
- BASEDIR=$(pwd)
- BUGSYSTEMS=""
- BUILDTOOLS=""
- LOAD_SYSTEM_PLUGINS=true
- #shellcheck disable=SC2034
- JENKINS=false
- #shellcheck disable=SC2034
- OFFLINE=false
- OSTYPE=$(uname -s)
- #shellcheck disable=SC2034
- PATCH_BRANCH=""
- PATCH_BRANCH_DEFAULT="master"
- #shellcheck disable=SC2034
- PATCH_DRYRUNMODE=false
- PATCH_DIR=/tmp
- while [[ -e ${PATCH_DIR} ]]; do
- PATCH_DIR=/tmp/yetus-${RANDOM}.${RANDOM}
- done
- #shellcheck disable=SC2034
- PATCH_METHOD=""
- #shellcheck disable=SC2034
- PATCH_METHODS=("gitapply" "patchcmd")
- #shellcheck disable=SC2034
- PATCH_LEVEL=0
- PROJECT_NAME=yetus
- RESULT=0
- #shellcheck disable=SC2034
- TESTTYPES=""
- TESTFORMATS=""
- USER_PLUGIN_DIR=""
-
- #shellcheck disable=SC2034
- YETUS_SHELL_SCRIPT_DEBUG=false
-
- # Solaris needs POSIX and GNU, not SVID
- case ${OSTYPE} in
- SunOS)
- AWK=${AWK:-/usr/xpg4/bin/awk}
- CURL=${CURL:-curl}
- DIFF=${DIFF:-/usr/gnu/bin/diff}
- FILE=${FILE:-file}
- GIT=${GIT:-git}
- GREP=${GREP:-/usr/xpg4/bin/grep}
- PATCH=${PATCH:-/usr/gnu/bin/patch}
- SED=${SED:-/usr/xpg4/bin/sed}
- ;;
- *)
- AWK=${AWK:-awk}
- CURL=${CURL:-curl}
- DIFF=${DIFF:-diff}
- FILE=${FILE:-file}
- GIT=${GIT:-git}
- GREP=${GREP:-grep}
- PATCH=${PATCH:-patch}
- SED=${SED:-sed}
- ;;
- esac
-}
-
-## @description Interpret the common command line parameters used by test-patch,
-## @description smart-apply-patch, and the bug system plugins
-## @audience private
-## @stability stable
-## @replaceable no
-## @params $@
-## @return May exit on failure
-function common_args
-{
- declare i
-
- for i in "$@"; do
- case ${i} in
- --awk-cmd=*)
- AWK=${i#*=}
- ;;
- --basedir=*)
- #shellcheck disable=SC2034
- BASEDIR=${i#*=}
- ;;
- --branch=*)
- #shellcheck disable=SC2034
- PATCH_BRANCH=${i#*=}
- ;;
- --branch-default=*)
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=${i#*=}
- ;;
- --curl-cmd=*)
- CURL=${i#*=}
- ;;
- --debug)
- #shellcheck disable=SC2034
- YETUS_SHELL_SCRIPT_DEBUG=true
- ;;
- --diff-cmd=*)
- DIFF=${i#*=}
- ;;
- --file-cmd=*)
- FILE=${i#*=}
- ;;
- --git-cmd=*)
- GIT=${i#*=}
- ;;
- --grep-cmd=*)
- GREP=${i#*=}
- ;;
- --help|-help|-h|help|--h|--\?|-\?|\?)
- yetus_usage
- exit 0
- ;;
- --list-plugins)
- list_plugins
- exit 0
- ;;
- --offline)
- #shellcheck disable=SC2034
- OFFLINE=true
- ;;
- --patch-cmd=*)
- PATCH=${i#*=}
- ;;
- --patch-dir=*)
- PATCH_DIR=${i#*=}
- ;;
- --plugins=*)
- ENABLED_PLUGINS=${i#*=}
- ENABLED_PLUGINS=${ENABLED_PLUGINS//,/ }
- ;;
- --project=*)
- PROJECT_NAME=${i#*=}
- ;;
- --skip-system-plugins)
- LOAD_SYSTEM_PLUGINS=false
- ;;
- --sed-cmd=*)
- SED=${i#*=}
- ;;
- --user-plugins=*)
- USER_PLUGIN_DIR=${i#*=}
- ;;
- *)
- ;;
- esac
- done
-}
-
-## @description List all installed plug-ins, regardless of whether
-## @description they have been enabled
-## @audience public
-## @stability evolving
-## @replaceable no
-function list_plugins
-{
- declare plugintype
- declare name
-
- ENABLED_PLUGINS="all"
- importplugins
-
- printf "Reminder: every plug-in may be enabled via 'all'.\n\n"
- for plugintype in BUILDTOOLS TESTTYPES BUGSYSTEMS TESTFORMATS; do
- printf "%s:\n\t" ${plugintype}
- for name in ${!plugintype}; do
- printf "%s " ${name}
- done
- echo ""
- done
-}
-
-## @description Let plugins also get a copy of the arguments
-## @audience private
-## @stability evolving
-## @replaceable no
-function parse_args_plugins
-{
- declare plugin
-
- for plugin in ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
- if declare -f ${plugin}_parse_args >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_parse_args"
- #shellcheck disable=SC2086
- ${plugin}_parse_args "$@"
- (( RESULT = RESULT + $? ))
- fi
- done
-}
-
-## @description Let plugins also get a copy of the arguments
-## @audience private
-## @stability evolving
-## @replaceable no
-function plugins_initialize
-{
- declare plugin
-
- for plugin in ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
- if declare -f ${plugin}_initialize >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_initialize"
- #shellcheck disable=SC2086
- ${plugin}_initialize
- (( RESULT = RESULT + $? ))
- fi
- done
-}
-
-## @description Determine if a plugin was enabeld by the user
-## @description ENABLED_PLUGINS must be defined
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param test
-function verify_plugin_enabled
-{
- declare toadd=$1
- declare bar
- declare idx
- declare strip
- declare stridx
-
- yetus_debug "Testing if $1 has been enabled by user"
-
- bar=""
- for idx in ${ENABLED_PLUGINS}; do
- stridx=${idx// }
- yetus_debug "verify_plugin_enabled: processing ${stridx}"
- case ${stridx} in
- all)
- bar=${toadd}
- ;;
- -*)
- strip=${stridx#-}
- if [[ ${strip} = "${toadd}" ]]; then
- bar=""
- fi
- ;;
- +*|*)
- strip=${stridx#+}
- if [[ ${strip} = "${toadd}" ]]; then
- bar=${toadd}
- fi
- ;;
- esac
- done
-
- if [[ -n ${bar} ]]; then
- yetus_debug "Post-parsing: checking ${bar} = ${toadd}"
- fi
- [[ ${bar} = "${toadd}" ]]
-}
-
-## @description Personality-defined plug-in list
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param plug-in list string
-function personality_plugins
-{
- if [[ -z "${ENABLED_PLUGINS}" ]]; then
- ENABLED_PLUGINS="$1"
- ENABLED_PLUGINS=${ENABLED_PLUGINS//,/ }
- yetus_debug "Using personality plug-in list: ${ENABLED_PLUGINS}"
- fi
-}
-
-## @description Add the given test type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param test
-function add_test
-{
- if verify_plugin_enabled "${1}"; then
- yetus_add_entry NEEDED_TESTS "${1}"
- fi
-}
-
-## @description Remove the given test type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param test
-function delete_test
-{
- yetus_delete_entry NEEDED_TESTS "${1}"
-}
-
-## @description Verify if a given test was requested
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param test
-## @return 1 = yes
-## @return 0 = no
-function verify_needed_test
-{
- yetus_verify_entry NEEDED_TESTS "${1}"
-}
-
-## @description Add the given test type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param plugin
-function add_test_type
-{
- if verify_plugin_enabled "${1}"; then
- yetus_add_entry TESTTYPES "${1}"
- fi
-}
-
-## @description Remove the given test type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param plugin
-function delete_test_type
-{
- yetus_delete_entry TESTTYPES "${1}"
-}
-
-## @description Add the given bugsystem type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param bugsystem
-function add_bugsystem
-{
- if verify_plugin_enabled "${1}"; then
- yetus_add_entry BUGSYSTEMS "${1}"
- fi
-}
-
-## @description Remove the given bugsystem type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param bugsystem
-function delete_bugsystem
-{
- yetus_delete_entry BUGSYSTEMS "${1}"
-}
-
-## @description Add the given test format type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param test format
-function add_test_format
-{
- if verify_plugin_enabled "${1}"; then
- yetus_add_entry TESTFORMATS "${1}"
- fi
-}
-
-## @description Remove the given test format type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param test format
-function delete_test_format
-{
- yetus_delete_entry TESTFORMATS "${1}"
-}
-
-## @description Add the given build tool type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param build tool
-function add_build_tool
-{
- if verify_plugin_enabled "${1}"; then
- yetus_add_entry BUILDTOOLS "${1}"
- fi
-}
-
-## @description Remove the given build tool type
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param build tool
-function delete_build_tool
-{
- yetus_delete_entry BUILDTOOLS "${1}"
-}
-
-## @description Import content from test-patch.d and optionally
-## @description from user provided plugin directory
-## @audience private
-## @stability evolving
-## @replaceable no
-## @description Import content from test-patch.d and optionally
-## @description from user provided plugin directory
-## @audience private
-## @stability evolving
-## @replaceable no
-function importplugins
-{
- local i
- local plugin
- local files=()
-
- if [[ ${LOAD_SYSTEM_PLUGINS} == "true" ]]; then
- if [[ -d "${BINDIR}/test-patch.d" ]]; then
- files=(${BINDIR}/test-patch.d/*.sh)
- fi
- fi
-
- if [[ -n "${USER_PLUGIN_DIR}" && -d "${USER_PLUGIN_DIR}" ]]; then
- yetus_debug "Loading user provided plugins from ${USER_PLUGIN_DIR}"
- files=("${files[@]}" ${USER_PLUGIN_DIR}/*.sh)
- fi
-
- if [[ -z ${PERSONALITY}
- && -f "${BINDIR}/personality/${PROJECT_NAME}.sh"
- && ${LOAD_SYSTEM_PLUGINS} = "true" ]]; then
- PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
- fi
-
- if [[ -n ${PERSONALITY} ]]; then
- if [[ ! -f ${PERSONALITY} ]]; then
- if [[ -f "${BINDIR}/personality/${PROJECT_NAME}.sh"
- && ${LOAD_SYSTEM_PLUGINS} = "true" ]]; then
- PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
- else
- yetus_debug "Can't find ${PERSONALITY} to import."
- return
- fi
- fi
- yetus_debug "Importing ${PERSONALITY}"
- # shellcheck disable=SC1090
- . "${PERSONALITY}"
- fi
-
- for i in "${files[@]}"; do
- if [[ -f ${i} ]]; then
- yetus_debug "Importing ${i}"
- #shellcheck disable=SC1090
- . "${i}"
- fi
- done
-
- if declare -f personality_globals > /dev/null; then
- personality_globals
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/core.d/builtin-bugsystem.sh
----------------------------------------------------------------------
diff --git a/dev-support/core.d/builtin-bugsystem.sh b/dev-support/core.d/builtin-bugsystem.sh
deleted file mode 100755
index f6e25f1..0000000
--- a/dev-support/core.d/builtin-bugsystem.sh
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-# This bug system handles the output on the screen.
-
-add_bugsystem console
-
-## @description Print out the finished details on the console
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param runresult
-## @return 0 on success
-## @return 1 on failure
-function console_finalreport
-{
- declare result=$1
- shift
- declare i=0
- declare ourstring
- declare vote
- declare subs
- declare ela
- declare comment
- declare commentfile1="${PATCH_DIR}/comment.1"
- declare commentfile2="${PATCH_DIR}/comment.2"
- declare normaltop
- declare line
- declare seccoladj=0
- declare spcfx=${PATCH_DIR}/spcl.txt
-
- if [[ ${result} == 0 ]]; then
- if [[ ${JENKINS} == false ]]; then
- if declare -f ${PROJECT_NAME}_console_success >/dev/null; then
- ${PROJECT_NAME}_console_success > "${spcfx}"
- else
- {
- printf "IF9fX18gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfIAovIF9fX3wg";
- printf "XyAgIF8gIF9fXyBfX18gX19fICBfX18gX19ffCB8ClxfX18gXHwgfCB8IHwv";
- printf "IF9fLyBfXy8gXyBcLyBfXy8gX198IHwKIF9fXykgfCB8X3wgfCAoX3wgKF98";
- printf "ICBfXy9cX18gXF9fIFxffAp8X19fXy8gXF9fLF98XF9fX1xfX19cX19ffHxf";
- printf "X18vX19fKF8pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg";
- printf "ICAK";
- } > "${spcfx}"
- fi
- fi
- printf "\n\n+1 overall\n\n"
- else
- if [[ ${JENKINS} == false ]]; then
- if declare -f ${PROJECT_NAME}_console_failure >/dev/null; then
- ${PROJECT_NAME}_console_failure > "${spcfx}"
- else
- {
- printf "IF9fX19fICAgICBfIF8gICAgICAgICAgICAgICAgXyAKfCAgX19ffF8gXyhf";
- printf "KSB8XyAgIF8gXyBfXyBfX198IHwKfCB8XyAvIF9gIHwgfCB8IHwgfCB8ICdf";
- printf "Xy8gXyBcIHwKfCAgX3wgKF98IHwgfCB8IHxffCB8IHwgfCAgX18vX3wKfF98";
- printf "ICBcX18sX3xffF98XF9fLF98X3wgIFxfX18oXykKICAgICAgICAgICAgICAg";
- printf "ICAgICAgICAgICAgICAgICAK"
- } > "${spcfx}"
- fi
- fi
- printf "\n\n-1 overall\n\n"
- fi
-
- if [[ -f ${spcfx} ]]; then
- if which base64 >/dev/null 2>&1; then
- base64 --decode "${spcfx}" 2>/dev/null
- elif which openssl >/dev/null 2>&1; then
- openssl enc -A -d -base64 -in "${spcfx}" 2>/dev/null
- fi
- echo
- echo
- rm "${spcfx}"
- fi
-
- seccoladj=$(findlargest 2 "${TP_VOTE_TABLE[@]}")
- if [[ ${seccoladj} -lt 10 ]]; then
- seccoladj=10
- fi
-
- seccoladj=$((seccoladj + 2 ))
- i=0
- until [[ $i -eq ${#TP_HEADER[@]} ]]; do
- printf "%s\n" "${TP_HEADER[${i}]}"
- ((i=i+1))
- done
-
- printf "| %s | %*s | %s | %s\n" "Vote" ${seccoladj} Subsystem Runtime "Comment"
- echo "============================================================================"
- i=0
- until [[ $i -eq ${#TP_VOTE_TABLE[@]} ]]; do
- ourstring=$(echo "${TP_VOTE_TABLE[${i}]}" | tr -s ' ')
- vote=$(echo "${ourstring}" | cut -f2 -d\|)
- subs=$(echo "${ourstring}" | cut -f3 -d\|)
- ela=$(echo "${ourstring}" | cut -f4 -d\|)
- comment=$(echo "${ourstring}" | cut -f5 -d\|)
-
- echo "${comment}" | fold -s -w $((78-seccoladj-22)) > "${commentfile1}"
- normaltop=$(head -1 "${commentfile1}")
- ${SED} -e '1d' "${commentfile1}" > "${commentfile2}"
-
- printf "| %4s | %*s | %-10s |%-s\n" "${vote}" ${seccoladj} \
- "${subs}" "${ela}" "${normaltop}"
- while read -r line; do
- printf "| | %*s | | %-s\n" ${seccoladj} " " "${line}"
- done < "${commentfile2}"
-
- ((i=i+1))
- rm "${commentfile2}" "${commentfile1}" 2>/dev/null
- done
-
- if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
- seccoladj=$(findlargest 1 "${TP_TEST_TABLE[@]}")
- printf "\n\n%*s | Tests\n" "${seccoladj}" "Reason"
- i=0
- until [[ $i -eq ${#TP_TEST_TABLE[@]} ]]; do
- ourstring=$(echo "${TP_TEST_TABLE[${i}]}" | tr -s ' ')
- vote=$(echo "${ourstring}" | cut -f2 -d\|)
- subs=$(echo "${ourstring}" | cut -f3 -d\|)
- printf "%*s | %s\n" "${seccoladj}" "${vote}" "${subs}"
- ((i=i+1))
- done
- fi
-
- printf "\n\n|| Subsystem || Report/Notes ||\n"
- echo "============================================================================"
- i=0
-
- until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
- comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
- ${SED} -e "s,@@BASE@@,${PATCH_DIR},g")
- printf "%s\n" "${comment}"
- ((i=i+1))
- done
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/core.d/builtin-personality.sh
----------------------------------------------------------------------
diff --git a/dev-support/core.d/builtin-personality.sh b/dev-support/core.d/builtin-personality.sh
deleted file mode 100755
index 1258d46..0000000
--- a/dev-support/core.d/builtin-personality.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-function personality_modules
-{
- if declare -f "${BUILDTOOL}_builtin_personality_modules" >/dev/null; then
- "${BUILDTOOL}_builtin_personality_modules" "$@"
- fi
-}
-
-function personality_file_tests
-{
- if declare -f "${BUILDTOOL}_builtin_personality_file_tests" >/dev/null; then
- "${BUILDTOOL}_builtin_personality_file_tests" "$@"
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/core.d/patchfiles.sh
----------------------------------------------------------------------
diff --git a/dev-support/core.d/patchfiles.sh b/dev-support/core.d/patchfiles.sh
deleted file mode 100755
index 7bb2f8b..0000000
--- a/dev-support/core.d/patchfiles.sh
+++ /dev/null
@@ -1,330 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-## @description Use curl to download the patch as a last resort
-## @audience private
-## @stability evolving
-## @param patchloc
-## @param output
-## @return 0 got something
-## @return 1 error
-function generic_locate_patch
-{
- declare input=$1
- declare output=$2
-
- if [[ "${OFFLINE}" == true ]]; then
- yetus_debug "generic_locate_patch: offline, skipping"
- return 1
- fi
-
- ${CURL} --silent \
- --output "${output}" \
- "${input}"
- if [[ $? != 0 ]]; then
- yetus_debug "generic_locate_patch: failed to download the patch."
- return 1
- fi
- return 0
-}
-
-## @description Given a possible patch file, guess if it's a patch file
-## @description only using the more intense verify if we really need to
-## @audience private
-## @stability evolving
-## @param path to patch file to test
-## @return 0 we think it's a patch file
-## @return 1 we think it's not a patch file
-function guess_patch_file
-{
- declare patch=$1
- declare fileOutput
-
- if [[ ! -f ${patch} ]]; then
- return 1
- fi
-
- yetus_debug "Trying to guess if ${patch} is a patch file."
- fileOutput=$("${FILE}" "${patch}")
- if [[ $fileOutput =~ \ diff\ ]]; then
- yetus_debug "file magic says it's a diff."
- return 0
- fi
-
- fileOutput=$(head -n 1 "${patch}" | "${GREP}" -E "^(From [a-z0-9]* Mon Sep 17 00:00:00 2001)|(diff .*)|(Index: .*)$")
- if [[ $? == 0 ]]; then
- yetus_debug "first line looks like a patch file."
- return 0
- fi
-
- patchfile_dryrun_driver "${patch}"
-}
-
-## @description Given ${PATCH_OR_ISSUE}, determine what type of patch file is in use,
-## @description and do the necessary work to place it into ${PATCH_DIR}/patch.
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure, may exit
-function locate_patch
-{
- declare bugsys
- declare patchfile=""
- declare gotit=false
-
- yetus_debug "locate patch"
-
- if [[ -z "${PATCH_OR_ISSUE}" ]]; then
- yetus_error "ERROR: No patch provided."
- cleanup_and_exit 1
- fi
-
- echo "Processing: ${PATCH_OR_ISSUE}"
- # it's a declarely provided file
- if [[ -f ${PATCH_OR_ISSUE} ]]; then
- patchfile="${PATCH_OR_ISSUE}"
- else
- # run through the bug systems. maybe they know?
- for bugsys in ${BUGSYSTEMS}; do
- if declare -f ${bugsys}_locate_patch >/dev/null 2>&1; then
- "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
- if [[ $? == 0 ]]; then
- gotit=true
- fi
- fi
- done
-
- # ok, none of the bug systems know. let's see how smart we are
- if [[ ${gotit} == false ]]; then
- generic_locate_patch "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: Unsure how to process ${PATCH_OR_ISSUE}."
- cleanup_and_exit 1
- fi
- fi
- fi
-
- if [[ ! -f "${PATCH_DIR}/patch"
- && -f "${patchfile}" ]]; then
- cp "${patchfile}" "${PATCH_DIR}/patch"
- if [[ $? == 0 ]] ; then
- echo "Patch file ${patchfile} copied to ${PATCH_DIR}"
- else
- yetus_error "ERROR: Could not copy ${patchfile} to ${PATCH_DIR}"
- cleanup_and_exit 1
- fi
- fi
-}
-
-## @description if patch-level zero, then verify we aren't
-## @description just adding files
-## @audience public
-## @stability stable
-## @param log filename
-## @replaceable no
-## @returns $?
-function patchfile_verify_zero
-{
- declare logfile=$1
- shift
- declare dir
- declare changed_files1
- declare changed_files2
- declare filename
-
- # don't return /dev/null
- # shellcheck disable=SC2016
- changed_files1=$(${AWK} 'function p(s){if(s!~"^/dev/null"){print s}}
- /^diff --git / { p($3); p($4) }
- /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
-
- # maybe we interpreted the patch wrong? check the log file
- # shellcheck disable=SC2016
- changed_files2=$(${GREP} -E '^[cC]heck' "${logfile}" \
- | ${AWK} '{print $3}' \
- | ${SED} -e 's,\.\.\.$,,g')
-
- for filename in ${changed_files1} ${changed_files2}; do
-
- # leading prefix = bad
- if [[ ${filename} =~ ^(a|b)/ ]]; then
- return 1
- fi
-
- # touching an existing file is proof enough
- # that pl=0 is good
- if [[ -f ${filename} ]]; then
- return 0
- fi
-
- dir=$(dirname "${filename}" 2>/dev/null)
- if [[ -n ${dir} && -d ${dir} ]]; then
- return 0
- fi
- done
-
- # ¯\_(ツ)_/¯ - no way for us to know, all new files with no prefix!
- yetus_error "WARNING: Patch only adds files; using patch level ${PATCH_LEVEL}"
- return 0
-}
-
-## @description git apply dryrun
-## @replaceable no
-## @audience private
-## @stability evolving
-## @param path to patch file to dryrun
-function gitapply_dryrun
-{
- declare patchfile=$1
- declare prefixsize=${2:-0}
-
- while [[ ${prefixsize} -lt 4
- && -z ${PATCH_METHOD} ]]; do
- yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
- "${GIT}" apply --binary -v --check "-p${prefixsize}" "${patchfile}"
- if [[ $? == 0 ]]; then
- PATCH_LEVEL=${prefixsize}
- PATCH_METHOD=gitapply
- break
- fi
- ((prefixsize=prefixsize+1))
- done
-
- if [[ ${prefixsize} -eq 0 ]]; then
- patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
- if [[ $? != 0 ]]; then
- PATCH_METHOD=""
- PATCH_LEVEL=""
- gitapply_dryrun "${patchfile}" 1
- fi
- fi
-}
-
-## @description patch patch dryrun
-## @replaceable no
-## @audience private
-## @stability evolving
-## @param path to patch file to dryrun
-function patchcmd_dryrun
-{
- declare patchfile=$1
- declare prefixsize=${2:-0}
-
- while [[ ${prefixsize} -lt 4
- && -z ${PATCH_METHOD} ]]; do
- # shellcheck disable=SC2153
- yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
- "${PATCH}" "-p${prefixsize}" -E --dry-run < "${patchfile}"
- if [[ $? == 0 ]]; then
- PATCH_LEVEL=${prefixsize}
- PATCH_METHOD=patchcmd
- break
- fi
- ((prefixsize=prefixsize+1))
- done
-
- if [[ ${prefixsize} -eq 0 ]]; then
- patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
- if [[ $? != 0 ]]; then
- PATCH_METHOD=""
- PATCH_LEVEL=""
- patchcmd_dryrun "${patchfile}" 1
- fi
- fi
-}
-
-## @description driver for dryrun methods
-## @replaceable no
-## @audience private
-## @stability evolving
-## @param path to patch file to dryrun
-function patchfile_dryrun_driver
-{
- declare patchfile=$1
- declare method
-
- #shellcheck disable=SC2153
- for method in "${PATCH_METHODS[@]}"; do
- if declare -f ${method}_dryrun >/dev/null; then
- "${method}_dryrun" "${patchfile}"
- fi
- if [[ -n ${PATCH_METHOD} ]]; then
- break
- fi
- done
-
- if [[ -n ${PATCH_METHOD} ]]; then
- return 0
- fi
- return 1
-}
-
-## @description git patch apply
-## @replaceable no
-## @audience private
-## @stability evolving
-## @param path to patch file to apply
-function gitapply_apply
-{
- declare patchfile=$1
- declare extraopts
-
- if [[ "${COMMITMODE}" = true ]]; then
- extraopts="--whitespace=fix"
- fi
-
- echo "Applying the patch:"
- yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-apply.log" \
- "${GIT}" apply --binary ${extraopts} -v --stat --apply "-p${PATCH_LEVEL}" "${patchfile}"
- ${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-apply.log"
-}
-
-## @description patch patch apply
-## @replaceable no
-## @audience private
-## @stability evolving
-## @param path to patch file to apply
-function patchcmd_apply
-{
- declare patchfile=$1
-
- echo "Applying the patch:"
- yetus_run_and_redirect "${PATCH_DIR}/apply-patch-patch-apply.log" \
- "${PATCH}" "-p${PATCH_LEVEL}" -E < "${patchfile}"
- cat "${PATCH_DIR}/apply-patch-patch-apply.log"
-}
-
-## @description driver for patch apply methods
-## @replaceable no
-## @audience private
-## @stability evolving
-## @param path to patch file to apply
-function patchfile_apply_driver
-{
- declare patchfile=$1
-
- if declare -f ${PATCH_METHOD}_apply >/dev/null; then
- "${PATCH_METHOD}_apply" "${patchfile}"
- if [[ $? -gt 0 ]]; then
- return 1
- fi
- else
- yetus_error "ERROR: Patching method ${PATCH_METHOD} does not have a way to apply patches!"
- return 1
- fi
- return 0
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/bigtop.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/bigtop.sh b/dev-support/personality/bigtop.sh
deleted file mode 100755
index 3854f6b..0000000
--- a/dev-support/personality/bigtop.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-personality_plugins "all,-checkstyle,-findbugs"
-
-function personality_globals
-{
- # shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=master
- # shellcheck disable=SC2034
- JIRA_ISSUE_RE='^BIGTOP-[0-9]+$'
- # shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE=""
- # shellcheck disable=SC2034
- BUILDTOOL=gradle
- # shellcheck disable=SC2034
- GITHUB_REPO="apache/bigtop"
- # shellcheck disable=SC2034
- BIGTOP_PUPPETSETUP=false
-}
-
-add_test_type bigtop
-
-function bigtop_usage
-{
- echo "Bigtop specific:"
- echo "--bigtop-puppet=[false|true] execute the bigtop puppet setup (needs sudo to root)"
-}
-
-function bigtop_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --bigtop-puppet=*)
- BIGTOP_PUPPETSETUP=${i#*=}
- ;;
- esac
- done
-}
-
-function bigtop_precheck_postinstall
-{
- if [[ ${BIGTOP_PUPPETSETUP} = "true" ]]; then
- pushd "${BASEDIR}" >/dev/null
- echo_and_redirect "${PATCH_DIR}/bigtop-branch-toolchain.txt" "${GRADLEW}" toolchain
- popd >/dev/null
- fi
-}
-
-function bigtop_postapply_postinstall
-{
- if [[ ${BIGTOP_PUPPETSETUP} = "true" ]]; then
- pushd "${BASEDIR}" >/dev/null
- echo_and_redirect "${PATCH_DIR}/bigtop-patch-toolchain.txt" "${GRADLEW}" toolchain
- popd >/dev/null
- fi
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/flink.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/flink.sh b/dev-support/personality/flink.sh
deleted file mode 100755
index 356c76b..0000000
--- a/dev-support/personality/flink.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-personality_plugins "all"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=master
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^FLINK-[0-9]+$'
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/flink"
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE=""
-}
-
-add_test_type flinklib
-
-function flinklib_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.java$
- || ${filename} =~ \.scala$
- || ${filename} =~ pom.xml$ ]]; then
- add_test flinklib
- fi
-}
-
-function flinklib_count
-{
- find "${BASEDIR}" \
- | ${GREP} "/lib/" \
- | ${GREP} -v "_qa_workdir" \
- | wc -l
-}
-
-function flinklib_preapply
-{
- start_clock
- big_console_header "${PATCH_BRANCH} flink library dependencies"
-
- verify_needed_test flinklib
- if [[ $? == 0 ]]; then
- echo "Patch does not need flinklib testing."
- return 0
- fi
-
- pushd "${BASEDIR}" >/dev/null
- echo_and_redirect "${PATCH_DIR}/branch-flinklib-root.txt" \
- "${MAVEN}" "${MAVEN_ARGS[@]}" package -DskipTests -Dmaven.javadoc.skip=true -Ptest-patch
- if [[ $? != 0 ]]; then
- add_vote_table -1 flinklib "Unable to determine flink libs in ${PATCH_BRANCH}."
- fi
- FLINK_PRE_LIB_FILES=$(flinklib_count)
- popd >/dev/null
-}
-
-function flinklib_postapply
-{
- start_clock
- big_console_header "Patch flink library dependencies"
-
- verify_needed_test flinklib
- if [[ $? == 0 ]]; then
- echo "Patch does not need flinklib testing."
- return 0
- fi
-
- pushd "${BASEDIR}" >/dev/null
- echo_and_redirect "${PATCH_DIR}/patch-flinklib-root.txt" \
- "${MAVEN}" "${MAVEN_ARGS[@]}" package -DskipTests -Dmaven.javadoc.skip=true -Ptest-patch
- FLINK_POST_LIB_FILES=$(flinklib_count)
- popd >/dev/null
-
-
- if [[ "${FLINK_POST_LIB_FILES}" -gt "${FLINK_PRE_LIB_FILES}" ]]; then
- add_vote_table -1 flinklib "Patch increases lib folder dependencies from " \
- "${FLINK_PRE_LIB_FILES} to ${FLINK_POST_LIB_FILES}"
- return 1
- elif [[ "${FLINK_POST_LIB_FILES}" -eq "${FLINK_PRE_LIB_FILES}" ]]; then
- add_vote_table 0 flinklib "Patch did not change lib dependencies" \
- " (still ${FLINK_PRE_LIB_FILES})"
- else
- add_vote_table +1 flinklib "Patch decreases lib folder dependencies by " \
- "$((FLINK_PRE_LIB_FILES-FLINK_POST_LIB_FILES))."
- fi
- return 0
-}
-
-function flinklib_rebuild
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- flinklib_preapply
- else
- flinklib_postinstall
- fi
-}
-
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/geode.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/geode.sh b/dev-support/personality/geode.sh
deleted file mode 100644
index f16e431..0000000
--- a/dev-support/personality/geode.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-personality_plugins "all,-ant,-javac,-scalac,-scaladoc"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=develop
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/GEODE/How+to+Contribute"
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^(GEODE)-[0-9]+$'
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/incubator-geode"
- #shellcheck disable=SC2034
- BUILDTOOL=gradle
-# PYLINT_OPTIONS="--indent-string=' '"
-
-# HADOOP_MODULES=""
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/hadoop.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/hadoop.sh b/dev-support/personality/hadoop.sh
deleted file mode 100755
index f958f0c..0000000
--- a/dev-support/personality/hadoop.sh
+++ /dev/null
@@ -1,376 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Override these to match Apache Hadoop's requirements
-
-personality_plugins "all,-ant,-gradle,-scalac,-scaladoc"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=trunk
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE="https://wiki.apache.org/hadoop/HowToContribute"
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^(HADOOP|YARN|MAPREDUCE|HDFS)-[0-9]+$'
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/hadoop"
- #shellcheck disable=SC2034
- PYLINT_OPTIONS="--indent-string=' '"
-
- HADOOP_MODULES=""
-}
-
-function hadoop_module_manipulation
-{
- local startingmodules=${1:-normal}
- local module
- local hdfs_modules
- local mapred_modules
- local yarn_modules
- local ordered_modules
- local tools_modules
- local passed_modules
- local flags
-
- yetus_debug "hmm in: ${startingmodules}"
-
- if [[ ${startingmodules} = normal ]]; then
- startingmodules=${CHANGED_MODULES}
- elif [[ ${startingmodules} = union ]]; then
- startingmodules=${CHANGED_UNION_MODULES}
- fi
-
- yetus_debug "hmm expanded to: ${startingmodules}"
-
- if [[ ${startingmodules} = "." ]]; then
- yetus_debug "hmm shortcut since ."
- HADOOP_MODULES=.
- return
- fi
-
- # ${startingmodules} is already sorted and uniq'd.
- # let's remove child modules if we're going to
- # touch their parent.
- passed_modules=${startingmodules}
- for module in ${startingmodules}; do
- yetus_debug "Stripping ${module}"
- # shellcheck disable=SC2086
- passed_modules=$(echo ${passed_modules} | tr ' ' '\n' | ${GREP} -v ${module}/ )
- done
-
- yetus_debug "hmm pre-ordering: ${startingmodules}"
-
- # Hadoop's compilation rules are complex
- # Precedence: common > [hdfs|yarn] > mapred > tools
- # - everything depends upon common
- # - hdfs needs common's native bits for unit tests
- # - mapred depends upon yarn since it is a yarn app
- # - tools can require anything
-
- for module in ${passed_modules}; do
- yetus_debug "Personality ordering ${module}"
- if [[ ${module} = "." ]]; then
- HADOOP_MODULES=.
- break
- fi
-
- if [[ ${module} = hadoop-hdfs-project* ]]; then
- hdfs_modules="${hdfs_modules} ${module}"
- elif [[ ${module} = hadoop-common-project/hadoop-common
- || ${module} = hadoop-common-project ]]; then
- ordered_modules="${ordered_modules} ${module}"
- elif [[ ${module} = hadoop-tools* ]]; then
- tools_modules="${tools_modules} ${module}"
- elif [[ ${module} = hadoop-mapreduce-project* ]]; then
- mapred_modules="${mapred_modules} ${module}"
- elif [[ ${module} = hadoop-yarn-project* ]]; then
- yarn_modules="${yarn_modules} ${module}"
- else
- ordered_modules="${ordered_modules} ${module}"
- fi
- done
-
- HADOOP_MODULES="${ordered_modules} ${hdfs_modules} ${yarn_modules} ${mapred_modules} ${tools_modules}"
-
- yetus_debug "hmm out: ${HADOOP_MODULES}"
-}
-
-function hadoop_unittest_prereqs
-{
- local need_common=0
- local building_common=0
- local module
- local flags
- local fn
-
- for module in ${HADOOP_MODULES}; do
- if [[ ${module} = hadoop-hdfs-project* ]]; then
- need_common=1
- elif [[ ${module} = hadoop-common-project/hadoop-common
- || ${module} = hadoop-common-project ]]; then
- building_common=1
- fi
- done
-
- if [[ ${need_common} -eq 1
- && ${building_common} -eq 0 ]]; then
- echo "unit test pre-reqs:"
- module="hadoop-common-project/hadoop-common"
- fn=$(module_file_fragment "${module}")
- flags=$(hadoop_native_flags)
- pushd "${BASEDIR}/${module}" >/dev/null
- # shellcheck disable=SC2086
- echo_and_redirect "${PATCH_DIR}/maven-unit-prereq-${fn}-install.txt" \
- "${MAVEN}" "${MAVEN_ARGS[@]}" install -DskipTests ${flags}
- popd >/dev/null
- fi
-}
-
-function hadoop_native_flags
-{
-
- if [[ ${BUILD_NATIVE} != true ]]; then
- return
- fi
-
- # Based upon HADOOP-11937
- #
- # Some notes:
- #
- # - getting fuse to compile on anything but Linux
- # is always tricky.
- # - Darwin assumes homebrew is in use.
- # - HADOOP-12027 required for bzip2 on OS X.
- # - bzip2 is broken in lots of places.
- # e.g, HADOOP-12027 for OS X. so no -Drequire.bzip2
- #
-
- # current build servers are pretty limited in
- # what they support
- if [[ ${JENKINS} = true
- && ${DOCKERSUPPORT} = false ]]; then
- # shellcheck disable=SC2086
- echo -Pnative \
- -Drequire.snappy -Drequire.openssl -Drequire.fuse \
- -Drequire.test.libhadoop
- return
- fi
-
- case ${OSTYPE} in
- Linux)
- # shellcheck disable=SC2086
- echo -Pnative -Drequire.libwebhdfs \
- -Drequire.snappy -Drequire.openssl -Drequire.fuse \
- -Drequire.test.libhadoop
- ;;
- Darwin)
- JANSSON_INCLUDE_DIR=/usr/local/opt/jansson/include
- JANSSON_LIBRARY=/usr/local/opt/jansson/lib
- export JANSSON_LIBRARY JANSSON_INCLUDE_DIR
- # shellcheck disable=SC2086
- echo \
- -Pnative -Drequire.snappy \
- -Drequire.openssl \
- -Dopenssl.prefix=/usr/local/opt/openssl/ \
- -Dopenssl.include=/usr/local/opt/openssl/include \
- -Dopenssl.lib=/usr/local/opt/openssl/lib \
- -Drequire.libwebhdfs -Drequire.test.libhadoop
- ;;
- *)
- # shellcheck disable=SC2086
- echo \
- -Pnative \
- -Drequire.snappy -Drequire.openssl \
- -Drequire.libwebhdfs -Drequire.test.libhadoop
- ;;
- esac
-}
-
-function personality_modules
-{
- local repostatus=$1
- local testtype=$2
- local extra=""
- local ordering="normal"
- local needflags=false
- local flags
- local fn
- local i
-
- yetus_debug "Personality: ${repostatus} ${testtype}"
-
- clear_personality_queue
-
- case ${testtype} in
- asflicense)
- # this is very fast and provides the full path if we do it from
- # the root of the source
- personality_enqueue_module .
- return
- ;;
- checkstyle)
- ordering="union"
- extra="-DskipTests"
- ;;
- compile)
- ordering="union"
- extra="-DskipTests"
- needflags=true
-
- # if something in common changed, we build the whole world
- if [[ ${CHANGED_MODULES} =~ hadoop-common ]]; then
- yetus_debug "hadoop personality: javac + hadoop-common = ordering set to . "
- ordering="."
- fi
- ;;
- distclean)
- ordering="."
- extra="-DskipTests"
- ;;
- javadoc)
- if [[ ${repostatus} = patch ]]; then
- echo "javadoc pre-reqs:"
- for i in hadoop-project \
- hadoop-common-project/hadoop-annotations; do
- fn=$(module_file_fragment "${i}")
- pushd "${BASEDIR}/${i}" >/dev/null
- echo "cd ${i}"
- echo_and_redirect "${PATCH_DIR}/maven-${fn}-install.txt" \
- "${MAVEN}" "${MAVEN_ARGS[@]}" install
- popd >/dev/null
- done
- fi
- extra="-Pdocs -DskipTests"
- ;;
- mvninstall)
- extra="-DskipTests"
- if [[ ${repostatus} = branch ]]; then
- ordering=.
- fi
- ;;
- unit)
- if [[ ${TEST_PARALLEL} = "true" ]] ; then
- extra="-Pparallel-tests"
- if [[ -n ${TEST_THREADS:-} ]]; then
- extra="${extra} -DtestsThreadCount=${TEST_THREADS}"
- fi
- fi
- needflags=true
- hadoop_unittest_prereqs
-
- verify_needed_test javac
- if [[ $? == 0 ]]; then
- yetus_debug "hadoop: javac not requested"
- verify_needed_test native
- if [[ $? == 0 ]]; then
- yetus_debug "hadoop: native not requested"
- yetus_debug "hadoop: adding -DskipTests to unit test"
- extra="-DskipTests"
- fi
- fi
-
- verify_needed_test shellcheck
- if [[ $? == 0
- && ! ${CHANGED_FILES} =~ \.bats ]]; then
- yetus_debug "hadoop: NO shell code change detected; disabling shelltest profile"
- extra="${extra} -P!shelltest"
- else
- extra="${extra} -Pshelltest"
- fi
- ;;
- *)
- extra="-DskipTests"
- ;;
- esac
-
- if [[ ${needflags} = true ]]; then
- flags=$(hadoop_native_flags)
- extra="${extra} ${flags}"
- fi
-
- hadoop_module_manipulation ${ordering}
-
- for module in ${HADOOP_MODULES}; do
- # shellcheck disable=SC2086
- personality_enqueue_module ${module} ${extra}
- done
-}
-
-function personality_file_tests
-{
- local filename=$1
-
- yetus_debug "Using Hadoop-specific personality_file_tests"
-
- if [[ ${filename} =~ src/main/webapp ]]; then
- yetus_debug "tests/webapp: ${filename}"
- elif [[ ${filename} =~ \.sh
- || ${filename} =~ \.cmd
- || ${filename} =~ src/scripts
- || ${filename} =~ src/test/scripts
- ]]; then
- yetus_debug "tests/shell: ${filename}"
- add_test unit
- elif [[ ${filename} =~ \.md$
- || ${filename} =~ \.md\.vm$
- || ${filename} =~ src/site
- ]]; then
- yetus_debug "tests/site: ${filename}"
- add_test site
- elif [[ ${filename} =~ \.c$
- || ${filename} =~ \.cc$
- || ${filename} =~ \.h$
- || ${filename} =~ \.hh$
- || ${filename} =~ \.proto$
- || ${filename} =~ \.cmake$
- || ${filename} =~ CMakeLists.txt
- ]]; then
- yetus_debug "tests/units: ${filename}"
- add_test cc
- add_test unit
- add_test javac
- elif [[ ${filename} =~ build.xml$
- || ${filename} =~ pom.xml$
- || ${filename} =~ \.java$
- || ${filename} =~ src/main
- ]]; then
- yetus_debug "tests/javadoc+units: ${filename}"
- add_test javac
- add_test javadoc
- add_test mvninstall
- add_test unit
- fi
-
- if [[ ${filename} =~ src/test ]]; then
- yetus_debug "tests"
- add_test unit
- fi
-
- if [[ ${filename} =~ \.java$ ]]; then
- add_test findbugs
- fi
-}
-
-function hadoop_console_success
-{
- printf "IF9fX19fX19fX18gCjwgU3VjY2VzcyEgPgogLS0tLS0tLS0tLSAKIFwgICAg";
- printf "IC9cICBfX18gIC9cCiAgXCAgIC8vIFwvICAgXC8gXFwKICAgICAoKCAgICBP";
- printf "IE8gICAgKSkKICAgICAgXFwgLyAgICAgXCAvLwogICAgICAgXC8gIHwgfCAg";
- printf "XC8gCiAgICAgICAgfCAgfCB8ICB8ICAKICAgICAgICB8ICB8IHwgIHwgIAog";
- printf "ICAgICAgIHwgICBvICAgfCAgCiAgICAgICAgfCB8ICAgfCB8ICAKICAgICAg";
- printf "ICB8bXwgICB8bXwgIAo"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/hbase.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/hbase.sh b/dev-support/personality/hbase.sh
deleted file mode 100755
index 8451f17..0000000
--- a/dev-support/personality/hbase.sh
+++ /dev/null
@@ -1,236 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-personality_plugins "all"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=master
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^HBASE-[0-9]+$'
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/hbase"
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE=""
-
- # All supported Hadoop versions that we want to test the compilation with
- HBASE_HADOOP_VERSIONS="2.4.1 2.5.2 2.6.0"
-
- # Override the maven options
- MAVEN_OPTS="${MAVEN_OPTS:-"-Xmx3100M"}"
-}
-
-function personality_modules
-{
- local repostatus=$1
- local testtype=$2
- local extra=""
-
- yetus_debug "Personality: ${repostatus} ${testtype}"
-
- clear_personality_queue
-
- extra="-DHBasePatchProcess"
-
- if [[ ${repostatus} == branch
- && ${testtype} == mvninstall ]];then
- personality_enqueue_module . ${extra}
- return
- fi
-
- if [[ ${testtype} = findbugs ]]; then
- for module in ${CHANGED_MODULES}; do
- # skip findbugs on hbase-shell
- if [[ ${module} == hbase-shell ]]; then
- continue
- else
- # shellcheck disable=SC2086
- personality_enqueue_module ${module} ${extra}
- fi
- done
- return
- fi
-
- for module in ${CHANGED_MODULES}; do
- # shellcheck disable=SC2086
- personality_enqueue_module ${module} ${extra}
- done
-}
-
-###################################################
-
-add_test_type hadoopcheck
-
-function hadoopcheck_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.java$ ]]; then
- add_test hadoopcheck
- fi
-}
-
-function hadoopcheck_rebuild
-{
- local repostatus=$1
- local hadoopver
- local logfile
- local count
- local result=0
-
- if [[ "${repostatus}" = branch ]]; then
- return 0
- fi
-
- big_console_header "Compiling against various Hadoop versions"
-
- export MAVEN_OPTS="${MAVEN_OPTS}"
- for hadoopver in ${HBASE_HADOOP_VERSIONS}; do
- logfile="${PATCH_DIR}/patch-javac-${hadoopver}.txt"
- echo_and_redirect "${logfile}" \
- "${MAVEN}" clean install \
- -DskipTests -DHBasePatchProcess \
- -Dhadoop-two.version="${hadoopver}"
- count=$(${GREP} -c ERROR "${logfile}")
- if [[ ${count} -gt 0 ]]; then
- add_vote_table -1 hadoopcheck "Patch causes ${count} errors with Hadoop v${hadoopver}."
- ((result=result+1))
- fi
- done
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
-
- add_vote_table +1 hadoopcheck "Patch does not cause any errors with Hadoop ${HBASE_HADOOP_VERSIONS}."
- return 0
-}
-
-######################################
-
-add_test_type hbaseprotoc
-
-function hbaseprotoc_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.proto$ ]]; then
- add_test hbaseprotoc
- fi
-}
-
-function hbaseprotoc_rebuild
-{
- local i=0
- local fn
- local module
- local logfile
- local count
- local result
-
- if [[ "${repostatus}" = branch ]]; then
- return 0
- fi
-
- verify_needed_test hbaseprotoc
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "Patch HBase protoc plugin"
-
- start_clock
-
-
- personality_modules patch hbaseprotoc
- modules_workers patch hbaseprotoc compile -DskipTests -Pcompile-protobuf -X -DHBasePatchProcess
-
- # shellcheck disable=SC2153
- until [[ $i -eq ${#MODULE[@]} ]]; do
- if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
- ((result=result+1))
- ((i=i+1))
- continue
- fi
- module=${MODULE[$i]}
- fn=$(module_file_fragment "${module}")
- logfile="${PATCH_DIR}/patch-hbaseprotoc-${fn}.txt"
-
- count=$(${GREP} -c ERROR "${logfile}")
-
- if [[ ${count} -gt 0 ]]; then
- module_status ${i} -1 "patch-hbaseprotoc-${fn}.txt" "Patch generated "\
- "${count} new protoc errors in ${module}."
- ((result=result+1))
- fi
- ((i=i+1))
- done
-
- modules_messages patch hbaseprotoc true
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-######################################
-
-add_test_type hbaseanti
-
-function hbaseanti_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.java$ ]]; then
- add_test hbaseanti
- fi
-}
-
-function hbaseanti_patchfile
-{
- local patchfile=$1
- local warnings
- local result
-
- verify_needed_test hbaseanti
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "Checking for known anti-patterns"
-
- start_clock
-
- warnings=$(${GREP} 'new TreeMap<byte.*()' "${patchfile}")
- if [[ ${warnings} -gt 0 ]]; then
- add_vote_table -1 hbaseanti "" "The patch appears to have anti-pattern where BYTES_COMPARATOR was omitted: ${warnings}."
- ((result=result+1))
- fi
-
- warnings=$(${GREP} 'import org.apache.hadoop.classification' "${patchfile}")
- if [[ ${warnings} -gt 0 ]]; then
- add_vote_table -1 hbaseanti "" "The patch appears use Hadoop classification instead of HBase: ${warnings}."
- ((result=result+1))
- fi
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
-
- add_vote_table +1 hbaseanti "" "Patch does not have any anti-patterns."
- return 0
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/kafka.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/kafka.sh b/dev-support/personality/kafka.sh
deleted file mode 100755
index cc4bf09..0000000
--- a/dev-support/personality/kafka.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-personality_plugins "all,-checkstyle,-asflicense"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=trunk
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^KAFKA-[0-9]+$'
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE="http://kafka.apache.org/contributing.html"
- # shellcheck disable=SC2034
- BUILDTOOL=gradle
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/kafka"
-}
-
-function personality_modules
-{
- declare repostatus=$1
- declare testtype=$2
- declare module
- declare extra=""
-
- yetus_debug "Using kafka personality_modules"
- yetus_debug "Personality: ${repostatus} ${testtype}"
-
- clear_personality_queue
-
- case ${testtype} in
- gradleboot)
- # kafka's bootstrap is broken
- if [[ ${testtype} == gradleboot ]]; then
- pushd "${BASEDIR}" >/dev/null
- echo_and_redirect "${PATCH_DIR}/kafka-configure-gradle.txt" gradle
- popd >/dev/null
- fi
- ;;
- compile)
- extra="clean jar"
- ;;
- esac
-
- for module in ${CHANGED_MODULES}; do
- # shellcheck disable=SC2086
- personality_enqueue_module ${module} ${extra}
- done
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/pig.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/pig.sh b/dev-support/personality/pig.sh
deleted file mode 100755
index 50ea52f..0000000
--- a/dev-support/personality/pig.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-personality_plugins "all"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=trunk
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^PIG-[0-9]+$'
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/pig"
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE=""
- #shellcheck disable=SC2034
- BUILDTOOL=ant
-}
-
-function personality_modules
-{
- local repostatus=$1
- local testtype=$2
- local extra=""
-
- yetus_debug "Personality: ${repostatus} ${testtype}"
-
- clear_personality_queue
-
- extra="-DPigPatchProcess= "
-
- case ${testtype} in
- findbugs)
- # shellcheck disable=SC2034
- ANT_FINDBUGSXML="${BASEDIR}/build/test/findbugs/pig-findbugs-report.xml"
- extra="-Dfindbugs.home=${FINDBUGS_HOME}"
- ;;
- compile)
- extra="${extra} -Djavac.args=-Xlint -Dcompile.c++=yes clean piggybank"
- ;;
- javadoc)
- extra="${extra} -Dforrest.home=${FORREST_HOME}"
- ;;
- unit)
- extra="${extra} -Dtest.junit.output.format=xml -Dcompile.c++=yes -Dtest.output=yes test-core"
- ;;
- esac
-
- # shellcheck disable=SC2086
- personality_enqueue_module . ${extra}
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/samza.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/samza.sh b/dev-support/personality/samza.sh
deleted file mode 100755
index 131e73e..0000000
--- a/dev-support/personality/samza.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-personality_plugins "all,-checkstyle"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=master
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^SAMZA-[0-9]+$'
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/SAMZA/Contributor's+Corner"
- # shellcheck disable=SC2034
- BUILDTOOL=gradle
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/samza"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/tajo.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/tajo.sh b/dev-support/personality/tajo.sh
deleted file mode 100755
index aa5fc48..0000000
--- a/dev-support/personality/tajo.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-personality_plugins "all"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=master
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^TAJO-[0-9]+$'
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/tajo"
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/TAJO/How+to+Contribute+to+Tajo"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/personality/tez.sh
----------------------------------------------------------------------
diff --git a/dev-support/personality/tez.sh b/dev-support/personality/tez.sh
deleted file mode 100755
index 584865e..0000000
--- a/dev-support/personality/tez.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-personality_plugins "all"
-
-function personality_globals
-{
- #shellcheck disable=SC2034
- PATCH_BRANCH_DEFAULT=master
- #shellcheck disable=SC2034
- JIRA_ISSUE_RE='^TEZ-[0-9]+$'
- #shellcheck disable=SC2034
- GITHUB_REPO="apache/tez"
- #shellcheck disable=SC2034
- HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/TEZ/How+to+Contribute+to+Tez"
-}
\ No newline at end of file
[03/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/rubocop.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/rubocop.sh b/precommit/test-patch.d/rubocop.sh
new file mode 100755
index 0000000..c0fa2ac
--- /dev/null
+++ b/precommit/test-patch.d/rubocop.sh
@@ -0,0 +1,151 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type rubocop
+
+RUBOCOP_TIMER=0
+
+RUBOCOP=${RUBOCOP:-$(which rubocop 2>/dev/null)}
+
+function rubocop_usage
+{
+ echo "Rubocop specific:"
+ echo "--rubocop=<path> path to rubocop executable"
+}
+
+function rubocop_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --rubocop=*)
+ RUBOCOP=${i#*=}
+ ;;
+ esac
+ done
+}
+
+function rubocop_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.rb$ ]]; then
+ add_test rubocop
+ fi
+}
+
+function rubocop_preapply
+{
+ local i
+
+ verify_needed_test rubocop
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "rubocop plugin: prepatch"
+
+ if [[ ! -x ${RUBOCOP} ]]; then
+ yetus_error "${RUBOCOP} does not exist."
+ return 0
+ fi
+
+ start_clock
+
+ echo "Running rubocop against modified ruby scripts."
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+ ${RUBOCOP} -f e "${i}" | ${AWK} '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/branch-rubocop-result.txt"
+ fi
+ done
+ popd >/dev/null
+ # keep track of how much as elapsed for us already
+ RUBOCOP_TIMER=$(stop_clock)
+ return 0
+}
+
+function rubocop_postapply
+{
+ local i
+ local numPrepatch
+ local numPostpatch
+ local diffPostpatch
+
+ verify_needed_test rubocop
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "rubocop plugin: postpatch"
+
+ if [[ ! -x ${RUBOCOP} ]]; then
+ yetus_error "${RUBOCOP} is not available."
+ add_vote_table 0 rubocop "Rubocop was not available."
+ return 0
+ fi
+
+ start_clock
+
+ # add our previous elapsed to our new timer
+ # by setting the clock back
+ offset_clock "${RUBOCOP_TIMER}"
+
+ echo "Running rubocop against modified ruby scripts."
+ # we re-check this in case one has been added
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+ ${RUBOCOP} -f e "${i}" | ${AWK} '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/patch-rubocop-result.txt"
+ fi
+ done
+ popd >/dev/null
+
+ # shellcheck disable=SC2016
+ RUBOCOP_VERSION=$(${RUBOCOP} -v | ${AWK} '{print $NF}')
+ add_footer_table rubocop "v${RUBOCOP_VERSION}"
+
+ calcdiffs "${PATCH_DIR}/branch-rubocop-result.txt" "${PATCH_DIR}/patch-rubocop-result.txt" > "${PATCH_DIR}/diff-patch-rubocop.txt"
+ diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-rubocop.txt")
+
+ if [[ ${diffPostpatch} -gt 0 ]] ; then
+ # shellcheck disable=SC2016
+ numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-rubocop-result.txt")
+
+ # shellcheck disable=SC2016
+ numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-rubocop-result.txt")
+
+ add_vote_table -1 rubocop "The applied patch generated "\
+ "${diffPostpatch} new rubocop issues (total was ${numPrepatch}, now ${numPostpatch})."
+ add_footer_table rubocop "@@BASE@@/diff-patch-rubocop.txt"
+ return 1
+ fi
+
+ add_vote_table +1 rubocop "There were no new rubocop issues."
+ return 0
+}
+
+function rubocop_postcompile
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ rubocop_preapply
+ else
+ rubocop_postapply
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/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
new file mode 100755
index 0000000..aa18f58
--- /dev/null
+++ b/precommit/test-patch.d/ruby-lint.sh
@@ -0,0 +1,151 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type ruby_lint
+
+RUBY_LINT_TIMER=0
+
+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"
+}
+
+function ruby_lint_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --ruby-lint=*)
+ RUBY_LINT=${i#*=}
+ ;;
+ esac
+ done
+}
+
+function ruby_lint_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.rb$ ]]; then
+ add_test ruby_lint
+ fi
+}
+
+function ruby_lint_preapply
+{
+ local i
+
+ verify_needed_test ruby_lint
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "ruby-lint plugin: prepatch"
+
+ if [[ ! -x ${RUBY_LINT} ]]; then
+ yetus_error "${RUBY_LINT} does not exist."
+ return 0
+ fi
+
+ start_clock
+
+ echo "Running ruby-lint against modified ruby scripts."
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+ ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/branch-ruby-lint-result.txt"
+ fi
+ done
+ popd >/dev/null
+ # keep track of how much as elapsed for us already
+ RUBY_LINT_TIMER=$(stop_clock)
+ return 0
+}
+
+function ruby_lint_postapply
+{
+ local i
+ local numPrepatch
+ local numPostpatch
+ local diffPostpatch
+
+ verify_needed_test ruby_lint
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "ruby-lint plugin: postpatch"
+
+ if [[ ! -x ${RUBY_LINT} ]]; then
+ yetus_error "${RUBY_LINT} is not available."
+ add_vote_table 0 ruby-lint "Ruby-lint was not available."
+ return 0
+ fi
+
+ start_clock
+
+ # add our previous elapsed to our new timer
+ # by setting the clock back
+ offset_clock "${RUBY_LINT_TIMER}"
+
+ echo "Running ruby-lint against modified ruby scripts."
+ # we re-check this in case one has been added
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+ ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/patch-ruby-lint-result.txt"
+ fi
+ done
+ popd >/dev/null
+
+ # shellcheck disable=SC2016
+ RUBY_LINT_VERSION=$(${RUBY_LINT} -v | ${AWK} '{print $2}')
+ add_footer_table ruby-lint "${RUBY_LINT_VERSION}"
+
+ calcdiffs "${PATCH_DIR}/branch-ruby-lint-result.txt" "${PATCH_DIR}/patch-ruby-lint-result.txt" > "${PATCH_DIR}/diff-patch-ruby-lint.txt"
+ diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.txt")
+
+ if [[ ${diffPostpatch} -gt 0 ]] ; then
+ # shellcheck disable=SC2016
+ numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-ruby-lint-result.txt")
+
+ # shellcheck disable=SC2016
+ numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
+
+ add_vote_table -1 ruby-lint "The applied patch generated "\
+ "${diffPostpatch} new ruby-lint issues (total was ${numPrepatch}, now ${numPostpatch})."
+ add_footer_table ruby-lint "@@BASE@@/diff-patch-ruby-lint.txt"
+ return 1
+ fi
+
+ add_vote_table +1 ruby-lint "There were no new ruby-lint issues."
+ return 0
+}
+
+function ruby_lint_postcompile
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ ruby_lint_preapply
+ else
+ ruby_lint_postapply
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/scala.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/scala.sh b/precommit/test-patch.d/scala.sh
new file mode 100755
index 0000000..06aa86f
--- /dev/null
+++ b/precommit/test-patch.d/scala.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type scalac
+add_test_type scaladoc
+
+function scalac_filefilter
+{
+ declare filename=$1
+
+ if [[ ${filename} =~ \.scala$ ]]; then
+ yetus_debug "tests/scalac: ${filename}"
+ add_test scalac
+ add_test compile
+ fi
+}
+
+function scaladoc_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.scala$ ]]; then
+ yetus_debug "tests/scaladoc: ${filename}"
+ add_test scaladoc
+ fi
+}
+
+## @description
+## @audience private
+## @stability stable
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function scalac_compile
+{
+ declare codebase=$1
+ declare multijdkmode=$2
+
+ verify_needed_test scalac
+ if [[ $? = 0 ]]; then
+ return 0
+ fi
+
+ if [[ ${codebase} = patch ]]; then
+ generic_postlog_compare compile scalac "${multijdkmode}"
+ fi
+}
+
+## @description Count and compare the number of ScalaDoc warnings pre- and post- patch
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function scaladoc_rebuild
+{
+ declare codebase=$1
+
+ if [[ "${codebase}" = branch ]]; then
+ generic_pre_handler scaladoc false
+ else
+ generic_post_handler scaladoc scaladoc false true
+ fi
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/shellcheck.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/shellcheck.sh b/precommit/test-patch.d/shellcheck.sh
new file mode 100755
index 0000000..d50d212
--- /dev/null
+++ b/precommit/test-patch.d/shellcheck.sh
@@ -0,0 +1,176 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type shellcheck
+
+SHELLCHECK_TIMER=0
+
+SHELLCHECK=${SHELLCHECK:-$(which shellcheck 2>/dev/null)}
+
+SHELLCHECK_SPECIFICFILES=""
+
+# if it ends in an explicit .sh, then this is shell code.
+# if it doesn't have an extension, we assume it is shell code too
+function shellcheck_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.sh$ ]]; then
+ add_test shellcheck
+ SHELLCHECK_SPECIFICFILES="${SHELLCHECK_SPECIFICFILES} ./${filename}"
+ fi
+
+ if [[ ! ${filename} =~ \. ]]; then
+ add_test shellcheck
+ fi
+}
+
+function shellcheck_private_findbash
+{
+ local i
+ local value
+ local list
+
+ while read line; do
+ value=$(find "${line}" ! -name '*.cmd' -type f \
+ | ${GREP} -E -v '(.orig$|.rej$)')
+
+ for i in ${value}; do
+ if [[ ! ${i} =~ \.sh(\.|$)
+ && ! $(head -n 1 "${i}") =~ ^#! ]]; then
+ yetus_debug "Shellcheck skipped: ${i}"
+ continue
+ fi
+ list="${list} ${i}"
+ done
+ done < <(find . -type d -name bin -o -type d -name sbin -o -type d -name scripts -o -type d -name libexec -o -type d -name shellprofile.d)
+ # shellcheck disable=SC2086
+ echo ${list} ${SHELLCHECK_SPECIFICFILES} | tr ' ' '\n' | sort -u
+}
+
+function shellcheck_preapply
+{
+ local i
+
+ verify_needed_test shellcheck
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "shellcheck plugin: prepatch"
+
+ if [[ ! -x "${SHELLCHECK}" ]]; then
+ yetus_error "shellcheck is not available."
+ return 0
+ fi
+
+ start_clock
+
+ echo "Running shellcheck against all identifiable shell scripts"
+ pushd "${BASEDIR}" >/dev/null
+ for i in $(shellcheck_private_findbash); do
+ if [[ -f ${i} ]]; then
+ ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/branch-shellcheck-result.txt"
+ fi
+ done
+ popd > /dev/null
+ # keep track of how much as elapsed for us already
+ SHELLCHECK_TIMER=$(stop_clock)
+ return 0
+}
+
+function shellcheck_postapply
+{
+ local i
+ local msg
+ local numPrepatch
+ local numPostpatch
+ local diffPostpatch
+
+ verify_needed_test shellcheck
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "shellcheck plugin: postpatch"
+
+ if [[ ! -x "${SHELLCHECK}" ]]; then
+ yetus_error "shellcheck is not available."
+ add_vote_table 0 shellcheck "Shellcheck was not available."
+ return 0
+ fi
+
+ start_clock
+
+ # add our previous elapsed to our new timer
+ # by setting the clock back
+ offset_clock "${SHELLCHECK_TIMER}"
+
+ echo "Running shellcheck against all identifiable shell scripts"
+ # we re-check this in case one has been added
+ for i in $(shellcheck_private_findbash); do
+ if [[ -f ${i} ]]; then
+ ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/patch-shellcheck-result.txt"
+ fi
+ done
+
+ if [[ ! -f "${PATCH_DIR}/branch-shellcheck-result.txt" ]]; then
+ touch "${PATCH_DIR}/branch-shellcheck-result.txt"
+ fi
+
+ # shellcheck disable=SC2016
+ SHELLCHECK_VERSION=$(${SHELLCHECK} --version | ${GREP} version: | ${AWK} '{print $NF}')
+ msg="v${SHELLCHECK_VERSION}"
+ if [[ ${SHELLCHECK_VERSION} =~ 0.[0-3].[0-5] ]]; then
+ msg="${msg} (This is an old version that has serious bugs. Consider upgrading.)"
+ fi
+ add_footer_table shellcheck "${msg}"
+
+ calcdiffs \
+ "${PATCH_DIR}/branch-shellcheck-result.txt" \
+ "${PATCH_DIR}/patch-shellcheck-result.txt" \
+ > "${PATCH_DIR}/diff-patch-shellcheck.txt"
+ # shellcheck disable=SC2016
+ diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shellcheck.txt" | ${AWK} '{print $1}')
+
+ if [[ ${diffPostpatch} -gt 0 ]] ; then
+ # shellcheck disable=SC2016
+ numPrepatch=$(wc -l "${PATCH_DIR}/branch-shellcheck-result.txt" | ${AWK} '{print $1}')
+
+ # shellcheck disable=SC2016
+ numPostpatch=$(wc -l "${PATCH_DIR}/patch-shellcheck-result.txt" | ${AWK} '{print $1}')
+
+ add_vote_table -1 shellcheck "The applied patch generated "\
+ "${diffPostpatch} new shellcheck issues (total was ${numPrepatch}, now ${numPostpatch})."
+ add_footer_table shellcheck "@@BASE@@/diff-patch-shellcheck.txt"
+ bugsystem_linecomments "shellcheck" "${PATCH_DIR}/diff-patch-shellcheck.txt"
+ return 1
+ fi
+
+ add_vote_table +1 shellcheck "There were no new shellcheck issues."
+ return 0
+}
+
+function shellcheck_postcompile
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ shellcheck_preapply
+ else
+ shellcheck_postapply
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/tap.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/tap.sh b/precommit/test-patch.d/tap.sh
new file mode 100755
index 0000000..7ced908
--- /dev/null
+++ b/precommit/test-patch.d/tap.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_format tap
+
+TAP_FAILED_TESTS=""
+TAP_LOG_DIR="target/tap"
+
+function tap_process_args
+{
+ declare i
+
+ for i in "$@"; do
+ case ${i} in
+ --tap-log-dir=*)
+ TAP_LOG_DIR=${i#=*}
+ ;;
+ esac
+ done
+}
+
+function tap_usage
+{
+ echo "TAP Options:"
+ echo "--tap-log-dir=<dir> Directory relative to the module for tap output (default: \"target/tap\")"
+}
+
+function tap_process_tests
+{
+ # shellcheck disable=SC2034
+ declare module=$1
+ # shellcheck disable=SC2034
+ declare buildlogfile=$2
+ declare filefrag=$3
+ declare result=0
+ declare module_failed_tests
+ declare filenames
+
+ filenames=$(find "${TAP_LOG_DIR}" -type f -exec "${GREP}" -l -E "^not ok" {} \;)
+
+ if [[ -n "${filenames}" ]]; then
+ module_failed_tests=$(echo "${filenames}" \
+ | ${SED} -e "s,${TAP_LOG_DIR},,g" -e s,^/,,g )
+ # shellcheck disable=SC2086
+ cat ${filenames} >> "${PATCH_DIR}/patch-${filefrag}.tap"
+ TAP_LOGS="${TAP_LOGS} @@BASE@@/patch-${filefrag}.tap"
+ TAP_FAILED_TESTS="${TAP_FAILED_TESTS} ${module_failed_tests}"
+ ((result=result+1))
+ fi
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function tap_finalize_results
+{
+ declare jdk=$1
+
+ if [[ -n "${TAP_FAILED_TESTS}" ]] ; then
+ # shellcheck disable=SC2086
+ populate_test_table "${jdk}Failed TAP tests" ${TAP_FAILED_TESTS}
+ TAP_FAILED_TESTS=""
+ add_footer_table "TAP logs" "${TAP_LOGS}"
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/test4tests.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/test4tests.sh b/precommit/test-patch.d/test4tests.sh
new file mode 100755
index 0000000..94b9b7f
--- /dev/null
+++ b/precommit/test-patch.d/test4tests.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type test4tests
+
+## @description Check the patch file for changed/new tests
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function test4tests_patchfile
+{
+ declare testReferences=0
+ declare i
+
+ big_console_header "Checking there are new or changed tests in the patch."
+
+ verify_needed_test unit
+
+ if [[ $? == 0 ]]; then
+ echo "Patch does not appear to need new or modified tests."
+ return 0
+ fi
+
+ start_clock
+
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ (^|/)test/ ]]; then
+ ((testReferences=testReferences + 1))
+ fi
+ done
+
+ echo "There appear to be ${testReferences} test file(s) referenced in the patch."
+ if [[ ${testReferences} == 0 ]] ; then
+ add_vote_table -1 "test4tests" \
+ "The patch doesn't appear to include any new or modified tests. " \
+ "Please justify why no new tests are needed for this patch." \
+ "Also please list what manual steps were performed to verify this patch."
+ return 1
+ fi
+ add_vote_table +1 "test4tests" \
+ "The patch appears to include ${testReferences} new or modified test files."
+ return 0
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/whitespace.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/whitespace.sh b/precommit/test-patch.d/whitespace.sh
new file mode 100755
index 0000000..32c5f42
--- /dev/null
+++ b/precommit/test-patch.d/whitespace.sh
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type whitespace
+
+function whitespace_linecomment_reporter
+{
+ declare file=$1
+ shift
+ declare comment=$*
+ declare tmpfile="${PATCH_DIR}/wlr.$$.${RANDOM}"
+
+ while read -r line; do
+ {
+ # shellcheck disable=SC2086
+ printf "%s" "$(echo ${line} | cut -f1-2 -d:)"
+ echo "${comment}"
+ } >> "${tmpfile}"
+ done < "${file}"
+
+ bugsystem_linecomments "whitespace:" "${tmpfile}"
+ rm "${tmpfile}"
+}
+
+function whitespace_postcompile
+{
+ declare repostatus=$1
+ declare count
+ declare result=0
+
+ if [[ "${repostatus}" = branch ]]; then
+ return 0
+ fi
+
+ big_console_header "Checking for whitespace at the end of lines"
+ start_clock
+
+ pushd "${BASEDIR}" >/dev/null
+ # shellcheck disable=SC2016
+ ${AWK} '/\t/ {print $0}' \
+ "${GITDIFFCONTENT}" \
+ | ${GREP} -v Makefile: >> "${PATCH_DIR}/whitespace-tabs.txt"
+
+ ${GREP} -E '[[:blank:]]$' \
+ "${GITDIFFCONTENT}" \
+ >> "${PATCH_DIR}/whitespace-eol.txt"
+
+ # shellcheck disable=SC2016
+ count=$(wc -l "${PATCH_DIR}/whitespace-eol.txt" | ${AWK} '{print $1}')
+
+ if [[ ${count} -gt 0 ]]; then
+ add_vote_table -1 whitespace "The patch has ${count}"\
+ " line(s) that end in whitespace. Use git apply --whitespace=fix."
+
+ whitespace_linecomment_reporter "${PATCH_DIR}/whitespace-eol.txt" "end of line"
+ add_footer_table whitespace "@@BASE@@/whitespace-eol.txt"
+ ((result=result+1))
+ fi
+
+ # shellcheck disable=SC2016
+ count=$(wc -l "${PATCH_DIR}/whitespace-tabs.txt" | ${AWK} '{print $1}')
+
+ if [[ ${count} -gt 0 ]]; then
+ add_vote_table -1 whitespace "The patch has ${count}"\
+ " line(s) with tabs."
+ add_footer_table whitespace "@@BASE@@/whitespace-tabs.txt"
+ whitespace_linecomment_reporter "${PATCH_DIR}/whitespace-tabs.txt" "tabs in line"
+ ((result=result+1))
+ fi
+
+ if [[ ${result} -gt 0 ]]; then
+ popd >/dev/null
+ return 1
+ fi
+
+ popd >/dev/null
+ add_vote_table +1 whitespace "Patch has no whitespace issues."
+ return 0
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/xml.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/xml.sh b/precommit/test-patch.d/xml.sh
new file mode 100755
index 0000000..b04a2f3
--- /dev/null
+++ b/precommit/test-patch.d/xml.sh
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type xml
+
+function xml_filefilter
+{
+ declare filename=$1
+
+ if [[ ${filename} =~ \.xml$ ]]; then
+ add_test xml
+ fi
+}
+
+function xml_postcompile
+{
+ declare repostatus=$1
+ declare js
+ declare i
+ declare count
+
+ verify_needed_test xml
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ if [[ "${repostatus}" = branch ]]; then
+ return 0
+ fi
+
+ big_console_header "Checking if XML files are well-formed"
+
+ js="${JAVA_HOME}/bin/jrunscript"
+ if [[ ! -x ${js} ]]; then
+ yetus_error "${js} does not exist"
+ return 0
+ fi
+
+ start_clock
+
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.xml$ && -f ${i} ]]; then
+ ${js} -e "XMLDocument(arguments[0])" "${i}" >> "${PATCH_DIR}/xml.txt" 2>&1
+ if [[ $? != 0 ]]; then
+ ((count=count+1))
+ fi
+ fi
+ done
+
+ if [[ ${count} -gt 0 ]]; then
+ add_vote_table -1 xml "The patch has ${count} ill-formed XML file(s)."
+ add_footer_table xml "@@BASE@@/xml.txt"
+ popd >/dev/null
+ return 1
+ fi
+
+ popd >/dev/null
+ add_vote_table +1 xml "The patch has no ill-formed XML file."
+ return 0
+}
[08/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/findbugs.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/findbugs.sh b/dev-support/test-patch.d/findbugs.sh
deleted file mode 100755
index ae18893..0000000
--- a/dev-support/test-patch.d/findbugs.sh
+++ /dev/null
@@ -1,411 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-FINDBUGS_HOME=${FINDBUGS_HOME:-}
-FINDBUGS_WARNINGS_FAIL_PRECHECK=false
-
-add_test_type findbugs
-
-function findbugs_filefilter
-{
- local filename=$1
-
- if [[ ${BUILDTOOL} == maven
- || ${BUILDTOOL} == ant ]]; then
- if [[ ${filename} =~ \.java$
- || ${filename} =~ (^|/)findbugs-exclude.xml$ ]]; then
- add_test findbugs
- fi
- fi
-}
-
-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"
-}
-
-function findbugs_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --findbugs-home=*)
- FINDBUGS_HOME=${i#*=}
- ;;
- --findbugs-strict-precheck)
- FINDBUGS_WARNINGS_FAIL_PRECHECK=true
- ;;
- esac
- done
-}
-
-## @description are the needed bits for findbugs present?
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 findbugs will work for our use
-## @return 1 findbugs is missing some component
-function findbugs_is_installed
-{
- declare exec
- declare status=0
-
- for exec in findbugs \
- computeBugHistory \
- convertXmlToText \
- filterBugs \
- setBugDatabaseInfo; do
- if [[ ! -x "${FINDBUGS_HOME}/bin/${exec}" ]]; then
- yetus_error "ERROR: ${FINDBUGS_HOME}/bin/${exec} is not executable."
- status=1
- fi
- done
- return ${status}
-}
-
-## @description Run the maven findbugs plugin and record found issues in a bug database
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function findbugs_runner
-{
- local name=$1
- local module
- local result=0
- local fn
- local warnings_file
- local i=0
- local savestop
-
- personality_modules "${name}" findbugs
- "${BUILDTOOL}_modules_worker" "${name}" findbugs
-
- if [[ ${UNSUPPORTED_TEST} = true ]]; then
- return 0
- fi
-
- #shellcheck disable=SC2153
- until [[ ${i} -eq ${#MODULE[@]} ]]; do
- if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
- ((result=result+1))
- ((i=i+1))
- continue
- fi
- start_clock
- offset_clock "${MODULE_STATUS_TIMER[${i}]}"
- module="${MODULE[${i}]}"
- fn=$(module_file_fragment "${module}")
-
- case ${BUILDTOOL} in
- maven)
- file="${module}/target/findbugsXml.xml"
- ;;
- ant)
- file="${ANT_FINDBUGSXML}"
- ;;
- esac
-
-
- if [[ ! -f ${file} ]]; then
- module_status ${i} -1 "" "${name}/${module} no findbugs output file (${file})"
- ((i=i+1))
- continue
- fi
-
- warnings_file="${PATCH_DIR}/${name}-findbugs-${fn}-warnings"
-
- cp -p "${file}" "${warnings_file}.xml"
-
- if [[ ${name} == branch ]]; then
- "${FINDBUGS_HOME}/bin/setBugDatabaseInfo" -name "${PATCH_BRANCH}" \
- "${warnings_file}.xml" "${warnings_file}.xml"
- else
- "${FINDBUGS_HOME}/bin/setBugDatabaseInfo" -name patch \
- "${warnings_file}.xml" "${warnings_file}.xml"
- fi
- if [[ $? != 0 ]]; then
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- module_status ${i} -1 "" "${name}/${module} cannot run setBugDatabaseInfo from findbugs"
- ((result=result+1))
- ((i=i+1))
- continue
- fi
-
- "${FINDBUGS_HOME}/bin/convertXmlToText" -html \
- "${warnings_file}.xml" \
- "${warnings_file}.html"
- if [[ $? != 0 ]]; then
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- module_status ${i} -1 "" "${name}/${module} cannot run convertXmlToText from findbugs"
- ((result=result+1))
- fi
-
- if [[ -z ${FINDBUGS_VERSION}
- && ${name} == branch ]]; then
- FINDBUGS_VERSION=$(${GREP} -i "BugCollection version=" "${warnings_file}.xml" \
- | cut -f2 -d\" \
- | cut -f1 -d\" )
- if [[ -n ${FINDBUGS_VERSION} ]]; then
- add_footer_table findbugs "v${FINDBUGS_VERSION}"
- fi
- fi
-
- ((i=i+1))
- done
- return ${result}
-}
-
-## @description Track pre-existing findbugs warnings
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function findbugs_preapply
-{
- local fn
- local module
- local i=0
- local warnings_file
- local module_findbugs_warnings
- local result=0
-
- verify_needed_test findbugs
-
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- findbugs_is_installed
- if [[ $? != 0 ]]; then
- add_vote_table 0 findbugs "findbugs executables are not available."
- return 0
- fi
-
- big_console_header "Pre-patch findbugs detection"
-
- findbugs_runner branch
- result=$?
-
- if [[ ${UNSUPPORTED_TEST} = true ]]; then
- return 0
- fi
-
- if [[ "${FINDBUGS_WARNINGS_FAIL_PRECHECK}" == "true" ]]; then
- until [[ $i -eq ${#MODULE[@]} ]]; do
- if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
- ((result=result+1))
- ((i=i+1))
- continue
- fi
- module=${MODULE[${i}]}
- start_clock
- offset_clock "${MODULE_STATUS_TIMER[${i}]}"
- fn=$(module_file_fragment "${module}")
- warnings_file="${PATCH_DIR}/branch-findbugs-${fn}-warnings"
- # shellcheck disable=SC2016
- module_findbugs_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -first \
- "${PATCH_BRANCH}" \
- "${warnings_file}.xml" \
- "${warnings_file}.xml" \
- | ${AWK} '{print $1}')
-
- if [[ ${module_findbugs_warnings} -gt 0 ]] ; then
- module_status ${i} -1 "branch-findbugs-${fn}.html" "${module} in ${PATCH_BRANCH} cannot run convertXmlToText from findbugs"
- ((result=result+1))
- fi
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- ((i=i+1))
- done
- modules_messages branch findbugs true
- fi
-
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Verify patch does not trigger any findbugs warnings
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function findbugs_postinstall
-{
- local module
- local fn
- local combined_xml
- local branchxml
- local patchxml
- local newbugsbase
- local fixedbugsbase
- local new_findbugs_warnings
- local fixed_findbugs_warnings
- local line
- local firstpart
- local secondpart
- local i=0
- local result=0
- local savestop
-
- verify_needed_test findbugs
-
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- findbugs_is_installed
- if [[ $? != 0 ]]; then
- return 0
- fi
-
- big_console_header "Patch findbugs detection"
-
- findbugs_runner patch
-
- if [[ ${UNSUPPORTED_TEST} = true ]]; then
- return 0
- fi
-
- until [[ $i -eq ${#MODULE[@]} ]]; do
- if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
- ((result=result+1))
- ((i=i+1))
- continue
- fi
- start_clock
- offset_clock "${MODULE_STATUS_TIMER[${i}]}"
- module="${MODULE[${i}]}"
-
- if [[ ${BUILDTOOLCWD} == true ]]; then
- pushd "${module}" >/dev/null
- fi
-
- fn=$(module_file_fragment "${module}")
-
- combined_xml="${PATCH_DIR}/combined-findbugs-${fn}.xml"
- branchxml="${PATCH_DIR}/branch-findbugs-${fn}-warnings.xml"
- patchxml="${PATCH_DIR}/patch-findbugs-${fn}-warnings.xml"
-
- if [[ ! -f "${branchxml}" ]]; then
- branchxml=${patchxml}
- fi
-
- newbugsbase="${PATCH_DIR}/new-findbugs-${fn}"
- fixedbugsbase="${PATCH_DIR}/fixed-findbugs-${fn}"
-
- "${FINDBUGS_HOME}/bin/computeBugHistory" -useAnalysisTimes -withMessages \
- -output "${combined_xml}" \
- "${branchxml}" \
- "${patchxml}"
- if [[ $? != 0 ]]; then
- if [[ ${BUILDTOOLCWD} == true ]]; then
- popd >/dev/null
- fi
- module_status ${i} -1 "" "${module} cannot run computeBugHistory from findbugs"
- ((result=result+1))
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- ((i=i+1))
- continue
- fi
-
- #shellcheck disable=SC2016
- new_findbugs_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -first patch \
- "${combined_xml}" "${newbugsbase}.xml" | ${AWK} '{print $1}')
- if [[ $? != 0 ]]; then
- popd >/dev/null
- module_status ${i} -1 "" "${module} cannot run filterBugs (#1) from findbugs"
- ((result=result+1))
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- ((i=i+1))
- continue
- fi
-
- #shellcheck disable=SC2016
- fixed_findbugs_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -fixed patch \
- "${combined_xml}" "${fixedbugsbase}.xml" | ${AWK} '{print $1}')
- if [[ $? != 0 ]]; then
- popd >/dev/null
- module_status ${i} -1 "" "${module} cannot run filterBugs (#2) from findbugs"
- ((result=result+1))
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- ((i=i+1))
- continue
- fi
-
- echo "Found ${new_findbugs_warnings} new Findbugs warnings and ${fixed_findbugs_warnings} newly fixed warnings."
-
- "${FINDBUGS_HOME}/bin/convertXmlToText" -html "${newbugsbase}.xml" \
- "${newbugsbase}.html"
- if [[ $? != 0 ]]; then
- popd >/dev/null
- module_status ${i} -1 "" "${module} cannot run convertXmlToText from findbugs"
- ((result=result+1))
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- ((i=i+1))
- continue
- fi
-
- if [[ ${new_findbugs_warnings} -gt 0 ]] ; then
- populate_test_table FindBugs "module:${module}"
- while read line; do
- firstpart=$(echo "${line}" | cut -f2 -d:)
- secondpart=$(echo "${line}" | cut -f9- -d' ')
- add_test_table "" "${firstpart}:${secondpart}"
- done < <("${FINDBUGS_HOME}/bin/convertXmlToText" "${newbugsbase}.xml")
-
- module_status ${i} -1 "new-findbugs-${fn}.html" "${module} introduced "\
- "${new_findbugs_warnings} new FindBugs issues."
- ((result=result+1))
- fi
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${i}]=${savestop}
- popd >/dev/null
- ((i=i+1))
- done
-
- modules_messages patch findbugs true
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
-
-function findbugs_rebuild
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- findbugs_preapply
- else
- findbugs_postinstall
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/github.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/github.sh b/dev-support/test-patch.d/github.sh
deleted file mode 100755
index 468a228..0000000
--- a/dev-support/test-patch.d/github.sh
+++ /dev/null
@@ -1,492 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# This bug system provides github integration
-
-add_bugsystem github
-
-# personalities can override the following settings:
-
-# Web interface URL.
-GITHUB_BASE_URL="https://github.com"
-
-# API interface URL.
-GITHUB_API_URL="https://api.github.com"
-
-# user/repo
-GITHUB_REPO=""
-
-# user settings
-GITHUB_PASSWD=""
-GITHUB_TOKEN=""
-GITHUB_USER=""
-GITHUB_ISSUE=""
-
-# private globals...
-GITHUB_BRIDGED=false
-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"
-}
-
-function github_parse_args
-{
- declare i
-
- for i in "$@"; do
- case ${i} in
- --github-api-url=*)
- GITHUB_API_URL=${i#*=}
- ;;
- --github-base-url=*)
- GITHUB_BASE_URL=${i#*=}
- ;;
- --github-repo=*)
- GITHUB_REPO=${i#*=}
- ;;
- --github-token=*)
- GITHUB_TOKEN=${i#*=}
- ;;
- --github-password=*)
- GITHUB_PASSWD=${i#*=}
- ;;
- --github-user=*)
- GITHUB_USER=${i#*=}
- ;;
- esac
- done
-}
-
-## @description this gets called when JIRA thinks this
-## @description issue is just a pointer to github
-## @description WARNING: Called from JIRA plugin!
-function github_jira_bridge
-{
- declare fileloc=$1
- declare urlfromjira
-
- # we use this to prevent loops later on
- GITHUB_BRIDGED=true
-
- # the JIRA issue has already been downloaded. So let's find the URL.
- # shellcheck disable=SC2016
- urlfromjira=$(${AWK} "match(\$0,\"${GITHUB_BASE_URL}/[^ ]*patch\"){print substr(\$0,RSTART,RLENGTH)}" "${PATCH_DIR}/jira" | tail -1)
- github_breakup_url "${urlfromjira}"
- github_locate_patch "${GITHUB_ISSUE}" "${fileloc}"
-}
-
-## @description given a URL, break it up into github plugin globals
-## @description this will *override* any personality or yetus defaults
-## @params url
-function github_breakup_url
-{
- declare url=$1
- declare count
- declare pos1
- declare pos2
-
- count=${url//[^\/]}
- count=${#count}
- ((pos2=count-3))
- ((pos1=pos2))
-
- GITHUB_BASE_URL=$(echo "${url}" | cut -f1-${pos2} -d/)
-
- ((pos1=pos1+1))
- ((pos2=pos1+1))
-
- GITHUB_REPO=$(echo "${url}" | cut -f${pos1}-${pos2} -d/)
-
- ((pos1=pos2+2))
- unset pos2
-
- GITHUB_ISSUE=$(echo "${url}" | cut -f${pos1}-${pos2} -d/ | cut -f1 -d.)
-}
-
-
-## @description based upon a github PR, attempt to link back to JIRA
-function github_find_jira_title
-{
- declare title
- declare maybe
- declare retval
-
- if [[ ! -f "${PATCH_DIR}/github-pull.json" ]]; then
- return 1
- fi
-
- title=$(${GREP} title "${PATCH_DIR}/github-pull.json" \
- | cut -f4 -d\")
-
- # people typically do two types: JIRA-ISSUE: and [JIRA-ISSUE]
- # JIRA_ISSUE_RE is pretty strict so we need to chop that stuff
- # out first
-
- maybe=$(echo "${title}" | cut -f2 -d\[ | cut -f1 -d\])
- jira_determine_issue "${maybe}"
- retval=$?
-
- if [[ ${retval} == 0 ]]; then
- return 0
- fi
-
- maybe=$(echo "${title}" | cut -f1 -d:)
- jira_determine_issue "${maybe}"
- retval=$?
-
- if [[ ${retval} == 0 ]]; then
- return 0
- fi
-
- return 1
-}
-
-function github_determine_issue
-{
- declare input=$1
-
- if [[ ${input} =~ ^[0-9]+$
- && -n ${GITHUB_REPO} ]]; then
- # shellcheck disable=SC2034
- ISSUE=${input}
- if [[ -z ${GITHUB_ISSUE} ]]; then
- GITHUB_ISSUE=${input}
- fi
- fi
-
- # if JIRA didn't call us, should we call it?
- if [[ ${GITHUB_BRIDGED} == false ]]; then
- github_find_jira_title
- if [[ $? == 0 ]]; then
- return 0
- fi
- fi
-
- if [[ -n ${GITHUB_ISSUE} ]]; then
- return 0
- fi
-
- return 1
-}
-
-## @description Try to guess the branch being tested using a variety of heuristics
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success, with PATCH_BRANCH updated appropriately
-## @return 1 on failure
-function github_determine_branch
-{
- if [[ ! -f "${PATCH_DIR}/github-pull.json" ]]; then
- return 1
- fi
-
- # shellcheck disable=SC2016
- PATCH_BRANCH=$(${AWK} 'match($0,"\"ref\": \""){print $2}' "${PATCH_DIR}/github-pull.json"\
- | cut -f2 -d\"\
- | tail -1 )
-
- yetus_debug "Github determine branch: starting with ${PATCH_BRANCH}"
-
- verify_valid_branch "${PATCH_BRANCH}"
- if [[ $? == 0 ]]; then
- return 0
- fi
- return 1
-}
-
-function github_locate_patch
-{
- declare input=$1
- declare output=$2
- declare githubauth
-
- if [[ "${OFFLINE}" == true ]]; then
- yetus_debug "github_locate_patch: offline, skipping"
- return 1
- fi
-
-
- # https://github.com/your/repo/pull/##
- if [[ ${input} =~ ^${GITHUB_BASE_URL}.*/pull/[0-9]+$ ]]; then
- github_breakup_url "${input}.patch"
- input=${GITHUB_ISSUE}
- fi
-
- # https://github.com/your/repo/pulls/##.patch
- if [[ ${input} =~ ^${GITHUB_BASE_URL}.*patch$ ]]; then
- github_breakup_url "${input}"
- input=${GITHUB_ISSUE}
- fi
-
- # https://github.com/your/repo/pulls/##.diff
- if [[ ${input} =~ ^${GITHUB_BASE_URL}.*diff$ ]]; then
- github_breakup_url "${input}"
- input=${GITHUB_ISSUE}
- fi
-
- # if it isn't a number at this point, no idea
- # how to process
- if [[ ! ${input} =~ ^[0-9]+$ ]]; then
- yetus_debug "github: ${input} is not a pull request #"
- return 1
- fi
-
- # we always pull the .patch version (even if .diff was given)
- # with the assumption that this way binary files work.
- # The downside of this is that the patch files are
- # significantly larger and therefore take longer to process
- PATCHURL="${GITHUB_BASE_URL}/${GITHUB_REPO}/pull/${input}.patch"
- echo "GITHUB PR #${input} is being downloaded at $(date) from"
- echo "${GITHUB_BASE_URL}/${GITHUB_REPO}/pull/${input}"
-
- if [[ -n "${GITHUB_USER}"
- && -n "${GITHUB_PASSWD}" ]]; then
- githubauth="${GITHUB_USER}:${GITHUB_PASSWD}"
- elif [[ -n "${GITHUB_TOKEN}" ]]; then
- githubauth="Authorization: token ${GITHUB_TOKEN}"
- else
- githubauth="X-ignore-me: fake"
- fi
-
- # Let's pull the PR JSON for later use
- ${CURL} --silent --fail \
- -H "Accept: application/vnd.github.v3.full+json" \
- -H "${githubauth}" \
- --output "${PATCH_DIR}/github-pull.json" \
- --location \
- "${GITHUB_API_URL}/repos/${GITHUB_REPO}/pulls/${input}"
-
- echo "Patch from GITHUB PR #${input} is being downloaded at $(date) from"
- echo "${PATCHURL}"
-
- # the actual patch file
- ${CURL} --silent --fail \
- --output "${output}" \
- --location \
- -H "${githubauth}" \
- "${PATCHURL}"
-
- if [[ $? != 0 ]]; then
- yetus_debug "github_locate_patch: not a github pull request."
- return 1
- fi
-
- GITHUB_ISSUE=${input}
-
- # github will translate this to be #(xx) !
- add_footer_table "GITHUB PR" "${GITHUB_BASE_URL}/${GITHUB_REPO}/pull/${input}"
-
- return 0
-}
-
-function github_linecomments
-{
- declare plugin=$1
- declare file=$2
- # shellcheck disable=SC2034
- declare realline=$3
- declare uniline=$4
- declare text=$5
- declare tempfile="${PATCH_DIR}/ghcomment.$$.${RANDOM}"
- declare githubauth
-
- if [[ "${file}" =~ ^./ ]]; then
- file=${file##./}
- fi
-
- if [[ -z "${GITHUB_COMMITSHA}" ]]; then
- GITHUB_COMMITSHA=$(${GREP} \"sha\" "${PATCH_DIR}/github-pull.json" 2>/dev/null \
- | head -1 \
- | cut -f4 -d\")
- fi
-
- if [[ -z "${uniline}" ]]; then
- return
- fi
-
- # build our REST post
- {
- printf "{\"body\":\""
- echo "${plugin}: ${text}" \
- | ${SED} -e 's,\\,\\\\,g' \
- -e 's,\",\\\",g' \
- -e 's,$,\\r\\n,g' \
- | tr -d '\n'
- echo "\","
- echo "\"commit_id\":\"${GITHUB_COMMITSHA}\","
- echo "\"path\":\"${file}\","
- echo "\"position\":${uniline}"
- echo "}"
- } > "${tempfile}"
-
- if [[ -n "${GITHUB_USER}"
- && -n "${GITHUB_PASSWD}" ]]; then
- githubauth="${GITHUB_USER}:${GITHUB_PASSWD}"
- elif [[ -n "${GITHUB_TOKEN}" ]]; then
- githubauth="Authorization: token ${GITHUB_TOKEN}"
- else
- return 0
- fi
-
- ${CURL} -X POST \
- -H "Accept: application/vnd.github.v3.full+json" \
- -H "Content-Type: application/json" \
- -H "${githubauth}" \
- -d @"${tempfile}" \
- --silent --location \
- "${GITHUB_API_URL}/repos/${GITHUB_REPO}/pulls/${GITHUB_ISSUE}/comments" \
- >/dev/null
- rm "${tempfile}"
-}
-
-## @description Write the contents of a file to github
-## @params filename
-## @stability stable
-## @audience public
-function github_write_comment
-{
- declare -r commentfile=${1}
- declare retval=0
- declare restfile="${PATCH_DIR}/ghcomment.$$"
- declare githubauth
-
- if [[ "${OFFLINE}" == true ]]; then
- echo "Github Plugin: Running in offline, comment skipped."
- return 0
- fi
-
- {
- printf "{\"body\":\""
- ${SED} -e 's,\\,\\\\,g' \
- -e 's,\",\\\",g' \
- -e 's,$,\\r\\n,g' "${commentfile}" \
- | tr -d '\n'
- echo "\"}"
- } > "${restfile}"
-
- if [[ -n "${GITHUB_USER}"
- && -n "${GITHUB_PASSWD}" ]]; then
- githubauth="${GITHUB_USER}:${GITHUB_PASSWD}"
- elif [[ -n "${GITHUB_TOKEN}" ]]; then
- githubauth="Authorization: token ${GITHUB_TOKEN}"
- else
- echo "Github Plugin: no credentials provided to write a comment."
- return 0
- fi
-
- ${CURL} -X POST \
- -H "Accept: application/vnd.github.v3.full+json" \
- -H "Content-Type: application/json" \
- -H "${githubauth}" \
- -d @"${restfile}" \
- --silent --location \
- "${GITHUB_API_URL}/repos/${GITHUB_REPO}/issues/${GITHUB_ISSUE}/comments" \
- >/dev/null
-
- retval=$?
- rm "${restfile}"
- return ${retval}
-}
-
-## @description Print out the finished details to the Github PR
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param runresult
-function github_finalreport
-{
- declare result=$1
- declare i
- declare commentfile=${PATCH_DIR}/gitcommentfile.$$
- declare comment
-
- rm "${commentfile}" 2>/dev/null
-
- if [[ ${JENKINS} != "true"
- || -z ${GITHUB_ISSUE} ]] ; then
- return 0
- fi
-
- big_console_header "Adding comment to Github"
-
- add_footer_table "Console output" "${BUILD_URL}console"
-
- if [[ ${result} == 0 ]]; then
- echo ":confetti_ball: **+1 overall**" >> "${commentfile}"
- else
- echo ":broken_heart: **-1 overall**" >> "${commentfile}"
- fi
-
- printf "\n\n\n\n" >> "${commentfile}"
-
- i=0
- until [[ ${i} -eq ${#TP_HEADER[@]} ]]; do
- printf "%s\n\n" "${TP_HEADER[${i}]}" >> "${commentfile}"
- ((i=i+1))
- done
-
- {
- printf "\n\n"
- echo "| Vote | Subsystem | Runtime | Comment |"
- echo "|:----:|----------:|--------:|:--------|"
- } >> "${commentfile}"
-
- i=0
- until [[ ${i} -eq ${#TP_VOTE_TABLE[@]} ]]; do
- echo "${TP_VOTE_TABLE[${i}]}" >> "${commentfile}"
- ((i=i+1))
- done
-
- if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
- {
- printf "\n\n"
- echo "| Reason | Tests |"
- echo "|-------:|:------|"
- } >> "${commentfile}"
- i=0
- until [[ ${i} -eq ${#TP_TEST_TABLE[@]} ]]; do
- echo "${TP_TEST_TABLE[${i}]}" >> "${commentfile}"
- ((i=i+1))
- done
- fi
-
- {
- printf "\n\n"
- echo "| Subsystem | Report/Notes |"
- echo "|----------:|:-------------|"
- } >> "${commentfile}"
-
- i=0
- until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
- comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
- ${SED} -e "s,@@BASE@@,${BUILD_URL}artifact/patchprocess,g")
- printf "%s\n" "${comment}" >> "${commentfile}"
- ((i=i+1))
- done
-
- printf "\n\nThis message was automatically generated.\n\n" >> "${commentfile}"
-
- github_write_comment "${commentfile}"
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/gradle.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/gradle.sh b/dev-support/test-patch.d/gradle.sh
deleted file mode 100755
index 56da8d5..0000000
--- a/dev-support/test-patch.d/gradle.sh
+++ /dev/null
@@ -1,263 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_build_tool gradle
-
-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')"
-}
-
-function gradle_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --gradle-cmd=*)
- GRADLE=${i#*=}
- ;;
- --gradlew-cmd=*)
- GRADLEW=${i#*=}
- ;;
- esac
- done
-
- # if we requested offline, pass that to mvn
- if [[ ${OFFLINE} == "true" ]]; then
- GRADLE_ARGS=("${GRADLE_ARGS[@]}" --offline)
- fi
-
- GRADLE=${GRADLE:-gradle}
- GRADLEW=${GRADLEW:-"${BASEDIR}/gradlew"}
-}
-
-function gradle_initialize
-{
- if [[ "${BUILDTOOL}" = gradle ]]; then
- # shellcheck disable=SC2034
- BUILDTOOLCWD=false
- fi
-
- # we need to do this before docker kicks in
- if [[ -e "${HOME}/.gradle"
- && ! -d "${HOME}/.gradle" ]]; then
- yetus_error "ERROR: ${HOME}/.gradle is not a directory."
- return 1
- elif [[ ! -e "${HOME}/.gradle" ]]; then
- yetus_debug "Creating ${HOME}/.gradle"
- mkdir -p "${HOME}/.gradle"
- fi
-}
-
-function gradle_buildfile
-{
- echo "gradlew"
-}
-
-function gradle_executor
-{
- echo "${GRADLEW}" "${GRADLE_ARGS[@]}"
-}
-
-## @description Bootstrap gradle
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function gradle_precompile
-{
- declare repostatus=$1
- declare result=0
-
- if [[ ${BUILDTOOL} != gradle ]]; then
- return 0
- fi
-
- if [[ "${repostatus}" = branch ]]; then
- # shellcheck disable=SC2153
- big_console_header "${PATCH_BRANCH} gradle bootstrap"
- else
- big_console_header "Patch gradle bootstrap"
- fi
-
- personality_modules "${repostatus}" gradleboot
-
- pushd "${BASEDIR}" >/dev/null
- echo_and_redirect "${PATCH_DIR}/${repostatus}-gradle-bootstrap.txt" gradle -b bootstrap.gradle
- popd >/dev/null
-
- modules_workers "${repostatus}" gradleboot
- result=$?
- modules_messages "${repostatus}" gradleboot true
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
-
-function gradle_scalac_count_probs
-{
- local warningfile=$1
-
- #shellcheck disable=SC2016,SC2046
- ${GREP} "^/.*.scala:[0-9]*:" "${warningfile}" | wc -l
-}
-
-function gradle_javac_count_probs
-{
- echo 0
-}
-
-function gradle_javadoc_count_probs
-{
- echo 0
-}
-
-## @description Helper for check_patch_javadoc
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function gradle_scaladoc_count_probs
-{
- local warningfile=$1
-
- #shellcheck disable=SC2016,SC2046
- ${GREP} "^\[ant:scaladoc\]" "${warningfile}" | wc -l
-}
-
-function gradle_modules_worker
-{
- declare repostatus=$1
- declare tst=$2
- shift 2
-
- # shellcheck disable=SC2034
- UNSUPPORTED_TEST=false
-
- case ${tst} in
- checkstyle)
- modules_workers "${repostatus}" "${tst}" checkstyleMain checkstyleTest
- ;;
- compile)
- modules_workers "${repostatus}" "${tst}"
- ;;
- distclean)
- modules_workers "${repostatus}" clean
- ;;
- javadoc)
- modules_workers "${repostatus}" "${tst}" javadoc
- ;;
- scaladoc)
- modules_workers "${repostatus}" "${tst}" scaladoc
- ;;
- unit)
- modules_workers "${repostatus}" "${tst}" test
- ;;
- *)
- # shellcheck disable=SC2034
- UNSUPPORTED_TEST=true
- if [[ ${repostatus} = patch ]]; then
- add_footer_table "${tst}" "not supported by the ${BUILDTOOL} plugin"
- fi
- yetus_error "WARNING: ${tst} is unsupported by ${BUILDTOOL}"
- return 1
- ;;
- esac
-}
-
-function gradle_builtin_personality_modules
-{
- local repostatus=$1
- local testtype=$2
-
- local module
-
- yetus_debug "Using builtin personality_modules"
- yetus_debug "Personality: ${repostatus} ${testtype}"
-
- clear_personality_queue
-
- for module in ${CHANGED_MODULES}; do
- # shellcheck disable=SC2086
- personality_enqueue_module ${module}
- done
-}
-
-function gradle_builtin_personality_file_tests
-{
- local filename=$1
-
- yetus_debug "Using builtin gradle personality_file_tests"
-
- if [[ ${filename} =~ src/main/webapp ]]; then
- yetus_debug "tests/webapp: ${filename}"
- elif [[ ${filename} =~ \.sh
- || ${filename} =~ \.cmd
- || ${filename} =~ src/main/scripts
- || ${filename} =~ src/test/scripts
- ]]; then
- yetus_debug "tests/shell: ${filename}"
- elif [[ ${filename} =~ \.c$
- || ${filename} =~ \.cc$
- || ${filename} =~ \.h$
- || ${filename} =~ \.hh$
- || ${filename} =~ \.proto$
- || ${filename} =~ \.cmake$
- || ${filename} =~ CMakeLists.txt
- ]]; then
- yetus_debug "tests/units: ${filename}"
- add_test cc
- add_test unit
- elif [[ ${filename} =~ \.scala$ ]]; then
- add_test scalac
- add_test scaladoc
- add_test unit
- elif [[ ${filename} =~ build.xml$
- || ${filename} =~ pom.xml$
- || ${filename} =~ \.java$
- ]]; then
- yetus_debug "tests/javadoc+units: ${filename}"
- add_test javac
- add_test javadoc
- add_test unit
- elif [[ ${filename} =~ src/main ]]; then
- yetus_debug "tests/generic+units: ${filename}"
- add_test compile
- add_test unit
- fi
-
- if [[ ${filename} =~ src/test ]]; then
- yetus_debug "tests"
- add_test unit
- fi
-
- if [[ ${filename} =~ \.java$ ]]; then
- add_test findbugs
- fi
-}
-
-function gradle_docker_support
-{
- echo "-v ${HOME}/.gradle:${HOME}/.gradle" > "${PATCH_DIR}/buildtool-docker-params.txt"
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/java.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/java.sh b/dev-support/test-patch.d/java.sh
deleted file mode 100755
index e1a73c7..0000000
--- a/dev-support/test-patch.d/java.sh
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type javac
-add_test_type javadoc
-
-function javac_initialize
-{
- local i
- local jdkdir
- local tmplist
-
- # if we are in pre-docker mode, don't do any of
- # this work since it's all going to be wrong anyway
- if [[ "${DOCKERSUPPORT}" = "true" ]]; then
- return 0
- fi
-
- if [[ -z ${JAVA_HOME:-} ]]; then
- case ${OSTYPE} in
- Darwin)
- if [[ -z "${JAVA_HOME}" ]]; then
- if [[ -x /usr/libexec/java_home ]]; then
- JAVA_HOME="$(/usr/libexec/java_home)"
- export JAVA_HOME
- else
- export JAVA_HOME=/Library/Java/Home
- fi
- fi
- ;;
- *)
- yetus_error "WARNING: JAVA_HOME not defined. Disabling java tests."
- delete_test javac
- delete_test javadoc
- return 1
- ;;
- esac
- fi
-
- JAVA_HOME=$(cd -P -- "${JAVA_HOME}" >/dev/null && pwd -P)
-
- for i in ${JDK_DIR_LIST}; do
- if [[ -d "${i}" ]]; then
- jdkdir=$(cd -P -- "${i}" >/dev/null && pwd -P)
- if [[ ${jdkdir} != "${JAVA_HOME}" ]]; then
- tmplist="${tmplist} ${jdkdir}"
- fi
- else
- yetus_error "WARNING: Cannot locate JDK directory ${i}: ignoring"
- fi
- done
-
- JDK_DIR_LIST="${tmplist} ${JAVA_HOME}"
- JDK_DIR_LIST=${JDK_DIR_LIST/ }
-}
-
-## @description Verify that ${JAVA_HOME} is defined
-## @audience public
-## @stability stable
-## @replaceable no
-## @return 1 - no JAVA_HOME
-## @return 0 - JAVA_HOME defined
-function javac_precheck
-{
- declare javaversion
- declare listofjdks
- declare i
-
- start_clock
-
- if [[ -z ${JAVA_HOME:-} ]]; then
- yetus_error "ERROR: JAVA_HOME is not defined."
- add_vote_table -1 pre-patch "JAVA_HOME is not defined."
- return 1
- fi
-
- javaversion=$(report_jvm_version "${JAVA_HOME}")
- add_footer_table "Default Java" "${javaversion}"
-
- if [[ -n ${JDK_DIR_LIST}
- && ${JDK_DIR_LIST} != "${JAVA_HOME}" ]]; then
- for i in ${JDK_DIR_LIST}; do
- javaversion=$(report_jvm_version "${i}")
- listofjdks="${listofjdks} ${i}:${javaversion}"
- done
- add_footer_table "Multi-JDK versions" "${listofjdks}"
- fi
- return 0
-}
-
-function javac_filefilter
-{
- declare filename=$1
-
- if [[ ${filename} =~ \.java$ ]]; then
- yetus_debug "tests/javac: ${filename}"
- add_test javac
- add_test compile
- fi
-}
-
-function javadoc_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.java$ ]]; then
- yetus_debug "tests/javadoc: ${filename}"
- add_test javadoc
- fi
-}
-
-## @description
-## @audience private
-## @stability stable
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function javac_compile
-{
- declare codebase=$1
- declare multijdkmode=$2
-
- verify_needed_test javac
- if [[ $? = 0 ]]; then
- return 0
- fi
-
- if [[ ${codebase} = patch ]]; then
- yetus_debug "javac: calling generic_postlog_compare compile javac ${multijdkmode}"
- generic_postlog_compare compile javac "${multijdkmode}"
- fi
-}
-
-## @description Count and compare the number of JavaDoc warnings pre- and post- patch
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function javadoc_rebuild
-{
- declare codebase=$1
- declare multijdkmode
-
- verify_multijdk_test javadoc
- if [[ $? == 1 ]]; then
- multijdkmode=true
- fi
-
- if [[ "${codebase}" = branch ]]; then
- generic_pre_handler javadoc "${multijdkmode}"
- else
- generic_post_handler javadoc javadoc "${multijdkmode}" true
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/jira.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/jira.sh b/dev-support/test-patch.d/jira.sh
deleted file mode 100755
index e5fd550..0000000
--- a/dev-support/test-patch.d/jira.sh
+++ /dev/null
@@ -1,436 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# this bug system handles JIRA. Personalities
-# can override the following variables:
-
-# base JIRA URL
-JIRA_URL=${JIRA_URL:-"https://issues.apache.org/jira"}
-
-# Issue regex to help identify the project
-JIRA_ISSUE_RE=''
-
-# If the issue status is matched with this pattern, the attached patch is regarded as ready to be applied
-JIRA_STATUS_RE='Patch Available'
-
-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"
-}
-
-function jira_parse_args
-{
- declare i
-
- for i in "$@"; do
- case ${i} in
- --jira-base-url=*)
- JIRA_URL=${i#*=}
- ;;
- --jira-issue-re=*)
- JIRA_ISSUE_RE=${i#*=}
- ;;
- --jira-password=*)
- JIRA_PASSWD=${i#*=}
- ;;
- --jira-status-re=*)
- JIRA_STATUS_RE=${i#*=}
- ;;
- --jira-user=*)
- JIRA_USER=${i#*=}
- ;;
- esac
- done
-}
-
-## @description provides issue determination based upon the URL and more.
-## @description WARNING: called from the github plugin!
-function jira_determine_issue
-{
- declare input=$1
- declare patchnamechunk
- declare maybeissue
-
- if [[ -n ${JIRA_ISSUE} ]]; then
- return 0
- fi
-
- # shellcheck disable=SC2016
- patchnamechunk=$(echo "${input}" | ${AWK} -F/ '{print $NF}')
-
- maybeissue=$(echo "${patchnamechunk}" | cut -f1,2 -d-)
-
- if [[ ${maybeissue} =~ ${JIRA_ISSUE_RE} ]]; then
- # shellcheck disable=SC2034
- ISSUE=${maybeissue}
- JIRA_ISSUE=${maybeissue}
- add_footer_table "JIRA Issue" "${JIRA_ISSUE}"
- return 0
- fi
-
- return 1
-}
-
-function jira_http_fetch
-{
- declare input=$1
- declare output=$2
-
- if [[ -n "${JIRA_USER}"
- && -n "${JIRA_PASSWD}" ]]; then
- ${CURL} --silent --fail \
- --user "${JIRA_USER}:${JIRA_PASSWD}" \
- --output "${output}" \
- --location \
- "${JIRA_URL}/${input}"
- else
- ${CURL} --silent --fail \
- --output "${output}" \
- --location \
- "${JIRA_URL}/${input}"
- fi
-}
-
-function jira_locate_patch
-{
- declare input=$1
- declare fileloc=$2
- declare relativeurl
-
- yetus_debug "jira_locate_patch: trying ${JIRA_URL}/browse/${input}"
-
- if [[ "${OFFLINE}" == true ]]; then
- yetus_debug "jira_locate_patch: offline, skipping"
- return 1
- fi
-
- jira_http_fetch "browse/${input}" "${PATCH_DIR}/jira"
-
- if [[ $? != 0 ]]; then
- yetus_debug "jira_locate_patch: not a JIRA."
- return 1
- fi
-
- # if github is configured and we see what looks like a URL,
- # send this to the github plugin to process.
- if [[ -n "${GITHUB_BASE_URL}"
- && $(${GREP} -c "${GITHUB_BASE_URL}"'[^ ]*patch' "${PATCH_DIR}/jira") != 0 ]]; then
- jira_determine_issue "${input}"
- echo "${input} appears to be a Github PR. Switching Modes."
- github_jira_bridge "${fileloc}"
- return $?
- elif [[ $(${GREP} -c "${JIRA_STATUS_RE}" "${PATCH_DIR}/jira") == 0 ]]; then
- if [[ ${JENKINS} == true ]]; then
- yetus_error "ERROR: ${input} issue status is not matched with \"${JIRA_STATUS_RE}\"."
- cleanup_and_exit 1
- else
- yetus_error "WARNING: ${input} issue status is not matched with \"${JIRA_STATUS_RE}\"."
- fi
- fi
-
- #shellcheck disable=SC2016
- relativeurl=$(${AWK} 'match($0,"/secure/attachment/[0-9]*/[^\"]*"){print substr($0,RSTART,RLENGTH)}' "${PATCH_DIR}/jira" |
- ${GREP} -v -e 'htm[l]*$' | sort | tail -1 | ${SED} -e 's,[ ]*$,,g')
- PATCHURL="${JIRA_URL}${relativeurl}"
- if [[ ! ${PATCHURL} =~ \.patch$ ]]; then
- guess_patch_file "${PATCH_DIR}/patch"
- if [[ $? == 0 ]]; then
- yetus_debug "The patch ${PATCHURL} was not named properly, but it looks like a patch file. Proceeding, but issue/branch matching might go awry."
- add_vote_table 0 patch "The patch file was not named according to ${PROJECT_NAME}'s naming conventions. Please see ${HOW_TO_CONTRIBUTE} for instructions."
- fi
- fi
- echo "${input} patch is being downloaded at $(date) from"
- echo "${PATCHURL}"
- add_footer_table "JIRA Patch URL" "${PATCHURL}"
- jira_http_fetch "${relativeurl}" "${fileloc}"
- if [[ $? != 0 ]];then
- yetus_error "ERROR: ${input}/${PATCHURL} could not be downloaded."
- cleanup_and_exit 1
- fi
- return 0
-}
-
-## @description Try to guess the branch being tested using a variety of heuristics
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success, with PATCH_BRANCH updated appropriately
-function jira_determine_branch
-{
- declare patchnamechunk
- declare total
- declare count
- declare hinttype
-
- for hinttype in "${PATCHURL}" "${PATCH_OR_ISSUE}"; do
- if [[ -z "${hinttype}" ]]; then
- continue
- fi
-
- # If one of these matches the JIRA issue regex
- # then we don't want it to trigger the branch
- # detection since that's almost certainly not
- # intended. In other words, if ISSUE-99 is the
- # name of a branch, you want to test ISSUE-99
- # against master, not ISSUE-99's branch
- if [[ ${hinttype} =~ ${JIRA_ISSUE_RE} ]]; then
- continue
- fi
-
- yetus_debug "Determine branch: starting with ${hinttype}"
- patchnamechunk=$(echo "${hinttype}" \
- | ${SED} -e 's,.*/\(.*\)$,\1,' \
- -e 's,\.txt,.,' \
- -e 's,.patch,.,g' \
- -e 's,.diff,.,g' \
- -e 's,\.\.,.,g' \
- -e 's,\.$,,g' )
-
- # ISSUE-branch-##
- PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1,2 -d-)
- yetus_debug "Determine branch: ISSUE-branch-## = ${PATCH_BRANCH}"
- if [[ -n "${PATCH_BRANCH}" ]]; then
- verify_valid_branch "${PATCH_BRANCH}"
- if [[ $? == 0 ]]; then
- return 0
- fi
- fi
-
- # ISSUE-##[.##].branch
- PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d. )
- count="${PATCH_BRANCH//[^.]}"
- total=${#count}
- ((total = total + 3 ))
- until [[ ${total} -lt 3 ]]; do
- PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3-${total} -d.)
- yetus_debug "Determine branch: ISSUE[.##].branch = ${PATCH_BRANCH}"
- ((total=total-1))
- if [[ -n "${PATCH_BRANCH}" ]]; then
- verify_valid_branch "${PATCH_BRANCH}"
- if [[ $? == 0 ]]; then
- return 0
- fi
- fi
- done
-
- # ISSUE.branch.##
- PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f2- -d. )
- count="${PATCH_BRANCH//[^.]}"
- total=${#count}
- ((total = total + 3 ))
- until [[ ${total} -lt 2 ]]; do
- PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f2-${total} -d.)
- yetus_debug "Determine branch: ISSUE.branch[.##] = ${PATCH_BRANCH}"
- ((total=total-1))
- if [[ -n "${PATCH_BRANCH}" ]]; then
- verify_valid_branch "${PATCH_BRANCH}"
- if [[ $? == 0 ]]; then
- return 0
- fi
- fi
- done
-
- # ISSUE-branch.##
- PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1- -d. )
- count="${PATCH_BRANCH//[^.]}"
- total=${#count}
- ((total = total + 1 ))
- until [[ ${total} -lt 1 ]]; do
- PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1-${total} -d. )
- yetus_debug "Determine branch: ISSUE-branch[.##] = ${PATCH_BRANCH}"
- ((total=total-1))
- if [[ -n "${PATCH_BRANCH}" ]]; then
- verify_valid_branch "${PATCH_BRANCH}"
- if [[ $? == 0 ]]; then
- return 0
- fi
- fi
- done
- done
-
- return 1
-}
-
-## @description Write the contents of a file to JIRA
-## @params filename
-## @stability stable
-## @audience public
-## @returns exit code from posting to jira
-function jira_write_comment
-{
- declare -r commentfile=${1}
- declare retval=0
-
- if [[ "${OFFLINE}" == true ]]; then
- echo "JIRA Plugin: Running in offline, comment skipped."
- return 0
- fi
-
- if [[ -n ${JIRA_PASSWD}
- && -n ${JIRA_USER} ]]; then
-
- # RESTify the comment
- {
- echo "{\"body\":\""
- ${SED} -e 's,\\,\\\\,g' \
- -e 's,\",\\\",g' \
- -e 's,$,\\r\\n,g' "${commentfile}" \
- | tr -d '\n'
- echo "\"}"
- } > "${PATCH_DIR}/jiracomment.$$"
-
- ${CURL} -X POST \
- -H "Accept: application/json" \
- -H "Content-Type: application/json" \
- -u "${JIRA_USER}:${JIRA_PASSWD}" \
- -d @"${PATCH_DIR}/jiracomment.$$" \
- --silent --location \
- "${JIRA_URL}/rest/api/2/issue/${JIRA_ISSUE}/comment" \
- >/dev/null
- retval=$?
- rm "${PATCH_DIR}/jiracomment.$$"
- else
- echo "JIRA Plugin: no credentials provided to write a comment."
- fi
- return ${retval}
-}
-
-## @description Print out the finished details to the JIRA issue
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param runresult
-function jira_finalreport
-{
- declare result=$1
- declare i
- declare commentfile=${PATCH_DIR}/jiracommentfile
- declare comment
- declare vote
- declare ourstring
- declare ela
- declare subs
- declare color
- declare comment
-
- rm "${commentfile}" 2>/dev/null
-
- if [[ ${JENKINS} == "false"
- || ${OFFLINE} == true ]] ; then
- return 0
- fi
-
- if [[ -z "${JIRA_ISSUE}" ]]; then
- return 0
- fi
-
- big_console_header "Adding comment to JIRA"
-
- add_footer_table "Console output" "${BUILD_URL}console"
-
- if [[ ${result} == 0 ]]; then
- echo "| (/) *{color:green}+1 overall{color}* |" >> "${commentfile}"
- else
- echo "| (x) *{color:red}-1 overall{color}* |" >> "${commentfile}"
- fi
-
- echo "\\\\" >> "${commentfile}"
-
- i=0
- until [[ $i -eq ${#TP_HEADER[@]} ]]; do
- printf "%s\n" "${TP_HEADER[${i}]}" >> "${commentfile}"
- ((i=i+1))
- done
-
- echo "\\\\" >> "${commentfile}"
-
- echo "|| Vote || Subsystem || Runtime || Comment ||" >> "${commentfile}"
-
- i=0
- until [[ $i -eq ${#TP_VOTE_TABLE[@]} ]]; do
- ourstring=$(echo "${TP_VOTE_TABLE[${i}]}" | tr -s ' ')
- vote=$(echo "${ourstring}" | cut -f2 -d\| | tr -d ' ')
- subs=$(echo "${ourstring}" | cut -f3 -d\|)
- ela=$(echo "${ourstring}" | cut -f4 -d\|)
- comment=$(echo "${ourstring}" | cut -f5 -d\|)
-
- # summary line
- if [[ -z ${vote}
- && -n ${ela} ]]; then
- color="black"
- elif [[ -z ${vote} ]]; then
- # keep same color
- true
- else
- # new vote line
- case ${vote} in
- 1|"+1")
- color="green"
- ;;
- -1)
- color="red"
- ;;
- 0)
- color="blue"
- ;;
- *)
- color="black"
- ;;
- esac
- fi
-
- printf "| {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} |\n" \
- "${color}" "${vote}" \
- "${color}" "${subs}" \
- "${color}" "${ela}" \
- "${color}" "${comment}" \
- >> "${commentfile}"
- ((i=i+1))
- done
-
- if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
- { echo "\\\\" ; echo "\\\\"; } >> "${commentfile}"
-
- echo "|| Reason || Tests ||" >> "${commentfile}"
- i=0
- until [[ $i -eq ${#TP_TEST_TABLE[@]} ]]; do
- printf "%s\n" "${TP_TEST_TABLE[${i}]}" >> "${commentfile}"
- ((i=i+1))
- done
- fi
-
- { echo "\\\\" ; echo "\\\\"; } >> "${commentfile}"
-
- echo "|| Subsystem || Report/Notes ||" >> "${commentfile}"
- i=0
- until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
- comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
- ${SED} -e "s,@@BASE@@,${BUILD_URL}artifact/patchprocess,g")
- printf "%s\n" "${comment}" >> "${commentfile}"
- ((i=i+1))
- done
-
- printf "\n\nThis message was automatically generated.\n\n" >> "${commentfile}"
-
- jira_write_comment "${commentfile}"
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/junit.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/junit.sh b/dev-support/test-patch.d/junit.sh
deleted file mode 100755
index 4393511..0000000
--- a/dev-support/test-patch.d/junit.sh
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_format junit
-
-JUNIT_TEST_TIMEOUTS=""
-JUNIT_FAILED_TESTS=""
-
-function junit_process_tests
-{
- # shellcheck disable=SC2034
- declare module=$1
- declare buildlogfile=$2
- declare result=0
- declare module_test_timeouts
- declare module_failed_tests
-
- # shellcheck disable=SC2016
- module_test_timeouts=$(${AWK} '/^Running / { array[$NF] = 1 } /^Tests run: .* in / { delete array[$NF] } END { for (x in array) { print x } }' "${buildlogfile}")
- if [[ -n "${module_test_timeouts}" ]] ; then
- JUNIT_TEST_TIMEOUTS="${JUNIT_TEST_TIMEOUTS} ${module_test_timeouts}"
- ((result=result+1))
- fi
-
- #shellcheck disable=SC2026,SC2038,SC2016
- module_failed_tests=$(find . -name 'TEST*.xml'\
- | xargs "${GREP}" -l -E "<failure|<error"\
- | ${AWK} -F/ '{sub("TEST-org.apache.",""); sub(".xml",""); print $NF}')
-
- if [[ -n "${module_failed_tests}" ]] ; then
- JUNIT_FAILED_TESTS="${JUNIT_FAILED_TESTS} ${module_failed_tests}"
- ((result=result+1))
- fi
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-function junit_finalize_results
-{
- declare jdk=$1
-
- if [[ -n "${JUNIT_FAILED_TESTS}" ]] ; then
- # shellcheck disable=SC2086
- populate_test_table "${jdk}Failed junit tests" ${JUNIT_FAILED_TESTS}
- JUNIT_FAILED_TESTS=""
- fi
- if [[ -n "${JUNIT_TEST_TIMEOUTS}" ]] ; then
- # shellcheck disable=SC2086
- populate_test_table "${jdk}Timed out junit tests" ${JUNIT_TEST_TIMEOUTS}
- JUNIT_TEST_TIMEOUTS=""
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/maven.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/maven.sh b/dev-support/test-patch.d/maven.sh
deleted file mode 100755
index 019b64d..0000000
--- a/dev-support/test-patch.d/maven.sh
+++ /dev/null
@@ -1,440 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-declare -a MAVEN_ARGS=("--batch-mode")
-
-if [[ -z "${MAVEN_HOME:-}" ]]; then
- MAVEN=mvn
-else
- MAVEN=${MAVEN_HOME}/bin/mvn
-fi
-
-MAVEN_CUSTOM_REPOS=false
-MAVEN_CUSTOM_REPOS_DIR="${HOME}/yetus-m2"
-
-add_test_type mvnsite
-add_test_type mvneclipse
-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"
-}
-
-function maven_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --mvn-cmd=*)
- MAVEN=${i#*=}
- ;;
- --mvn-custom-repos)
- MAVEN_CUSTOM_REPOS=true
- ;;
- --mvn-custom-repos-dir=*)
- MAVEN_CUSTOM_REPOS_DIR=${i#*=}
- ;;
- --mvn-settings=*)
- MAVEN_SETTINGS=${i#*=}
- if [[ -f ${MAVEN_SETTINGS} ]]; then
- MAVEN_ARGS=("${MAVEN_ARGS[@]}" "--settings=${MAVEN_SETTINGS}")
- else
- yetus_error "WARNING: ${MAVEN_SETTINGS} not found. Ignorning."
- fi
- ;;
- esac
- done
-
- if [[ ${OFFLINE} == "true" ]]; then
- MAVEN_ARGS=("${MAVEN_ARGS[@]}" --offline)
- fi
-}
-
-function maven_initialize
-{
- # we need to do this before docker does it as root
-
- if [[ ! ${MAVEN_CUSTOM_REPOS_DIR} =~ ^/ ]]; then
- yetus_error "ERROR: --mvn-custom-repos-dir must be an absolute path."
- return 1
- fi
-
- if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
- MAVEN_LOCAL_REPO="${MAVEN_CUSTOM_REPOS_DIR}"
- if [[ -e "${MAVEN_CUSTOM_REPOS_DIR}"
- && ! -d "${MAVEN_CUSTOM_REPOS_DIR}" ]]; then
- yetus_error "ERROR: ${MAVEN_CUSTOM_REPOS_DIR} is not a directory."
- return 1
- elif [[ ! -d "${MAVEN_CUSTOM_REPOS_DIR}" ]]; then
- yetus_debug "Creating ${MAVEN_CUSTOM_REPOS_DIR}"
- mkdir -p "${MAVEN_CUSTOM_REPOS_DIR}"
- fi
- fi
-
- if [[ -e "${HOME}/.m2"
- && ! -d "${HOME}/.m2" ]]; then
- yetus_error "ERROR: ${HOME}/.m2 is not a directory."
- return 1
- elif [[ ! -e "${HOME}/.m2" ]]; then
- yetus_debug "Creating ${HOME}/.m2"
- mkdir -p "${HOME}/.m2"
- fi
-}
-
-function maven_precheck
-{
- declare logfile="${PATCH_DIR}/mvnrepoclean.log"
- declare line
-
- if [[ ! ${MAVEN_CUSTOM_REPOS_DIR} =~ ^/ ]]; then
- yetus_error "ERROR: --mvn-custom-repos-dir must be an absolute path."
- return 1
- fi
-
- if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
- MAVEN_LOCAL_REPO="${MAVEN_CUSTOM_REPOS_DIR}/${PROJECT_NAME}-${PATCH_BRANCH}-${INSTANCE}"
- if [[ -e "${MAVEN_LOCAL_REPO}"
- && ! -d "${MAVEN_LOCAL_REPO}" ]]; then
- yetus_error "ERROR: ${MAVEN_LOCAL_REPO} is not a directory."
- return 1
- fi
-
- if [[ ! -d "${MAVEN_LOCAL_REPO}" ]]; then
- yetus_debug "Creating ${MAVEN_LOCAL_REPO}"
- mkdir -p "${MAVEN_LOCAL_REPO}"
- if [[ $? -ne 0 ]]; then
- yetus_error "ERROR: Unable to create ${MAVEN_LOCAL_REPO}"
- return 1
- fi
- fi
- touch "${MAVEN_LOCAL_REPO}"
-
- # if we have a local settings.xml file, we copy it.
- if [[ -f "${HOME}/.m2/settings.xml" ]]; then
- cp -p "${HOME}/.m2/settings.xml" "${MAVEN_LOCAL_REPO}"
- fi
- MAVEN_ARGS=("${MAVEN_ARGS[@]}" "-Dmaven.repo.local=${MAVEN_LOCAL_REPO}")
-
- # let's do some cleanup while we're here
-
- find "${MAVEN_CUSTOM_REPOS_DIR}" \
- -name '*-*-*' \
- -type d \
- -mtime +30 \
- -maxdepth 1 \
- -print \
- > "${logfile}"
-
- while read -r line; do
- echo "Removing old maven repo ${line}"
- rm -rf "${line}"
- done < "${logfile}"
- fi
-}
-
-function maven_buildfile
-{
- echo "pom.xml"
-}
-
-function maven_executor
-{
- echo "${MAVEN}" "${MAVEN_ARGS[@]}"
-}
-
-function mvnsite_filefilter
-{
- local filename=$1
-
- if [[ ${BUILDTOOL} = maven ]]; then
- if [[ ${filename} =~ src/site ]]; then
- yetus_debug "tests/mvnsite: ${filename}"
- add_test mvnsite
- fi
- fi
-}
-
-function maven_modules_worker
-{
- declare repostatus=$1
- declare tst=$2
-
- # shellcheck disable=SC2034
- UNSUPPORTED_TEST=false
-
- case ${tst} in
- findbugs)
- modules_workers "${repostatus}" findbugs test-compile findbugs:findbugs -DskipTests=true
- ;;
- compile)
- modules_workers "${repostatus}" compile clean test-compile -DskipTests=true
- ;;
- distclean)
- modules_workers "${repostatus}" distclean clean -DskipTests=true
- ;;
- javadoc)
- modules_workers "${repostatus}" javadoc clean javadoc:javadoc -DskipTests=true
- ;;
- scaladoc)
- modules_workers "${repostatus}" scaladoc clean scala:doc -DskipTests=true
- ;;
- unit)
- modules_workers "${repostatus}" unit clean test -fae
- ;;
- *)
- # shellcheck disable=SC2034
- UNSUPPORTED_TEST=true
- if [[ ${repostatus} = patch ]]; then
- add_footer_table "${tst}" "not supported by the ${BUILDTOOL} plugin"
- fi
- yetus_error "WARNING: ${tst} is unsupported by ${BUILDTOOL}"
- return 1
- ;;
- esac
-}
-
-function maven_javac_count_probs
-{
- local warningfile=$1
-
- #shellcheck disable=SC2016,SC2046
- ${GREP} '\[WARNING\]' "${warningfile}" | ${AWK} '{sum+=1} END {print sum}'
-}
-
-function maven_scalac_count_probs
-{
- echo 0
-}
-
-## @description Helper for check_patch_javadoc
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function maven_javadoc_count_probs
-{
- local warningfile=$1
-
- #shellcheck disable=SC2016,SC2046
- ${GREP} -E "^[0-9]+ warnings?$" "${warningfile}" | ${AWK} '{sum+=$1} END {print sum}'
-}
-
-function maven_builtin_personality_modules
-{
- local repostatus=$1
- local testtype=$2
-
- local module
-
- yetus_debug "Using builtin personality_modules"
- yetus_debug "Personality: ${repostatus} ${testtype}"
-
- clear_personality_queue
-
- # this always makes sure the local repo has a fresh
- # copy of everything per pom rules.
- if [[ ${repostatus} == branch
- && ${testtype} == mvninstall ]];then
- personality_enqueue_module .
- return
- fi
-
- for module in ${CHANGED_MODULES}; do
- # shellcheck disable=SC2086
- personality_enqueue_module ${module}
- done
-}
-
-function maven_builtin_personality_file_tests
-{
- local filename=$1
-
- yetus_debug "Using builtin mvn personality_file_tests"
-
- if [[ ${filename} =~ src/main/webapp ]]; then
- yetus_debug "tests/webapp: ${filename}"
- elif [[ ${filename} =~ \.sh
- || ${filename} =~ \.cmd
- || ${filename} =~ src/main/scripts
- || ${filename} =~ src/test/scripts
- ]]; then
- yetus_debug "tests/shell: ${filename}"
- elif [[ ${filename} =~ \.c$
- || ${filename} =~ \.cc$
- || ${filename} =~ \.h$
- || ${filename} =~ \.hh$
- || ${filename} =~ \.proto$
- || ${filename} =~ \.cmake$
- || ${filename} =~ CMakeLists.txt
- ]]; then
- yetus_debug "tests/units: ${filename}"
- add_test cc
- add_test unit
- elif [[ ${filename} =~ \.scala$
- || ${filename} =~ src/scala ]]; then
- add_test scalac
- add_test scaladoc
- add_test unit
- elif [[ ${filename} =~ build.xml$
- || ${filename} =~ pom.xml$
- || ${filename} =~ \.java$
- || ${filename} =~ src/main
- ]]; then
- yetus_debug "tests/javadoc+units: ${filename}"
- add_test javac
- add_test javadoc
- add_test unit
- fi
-
- if [[ ${filename} =~ src/test ]]; then
- yetus_debug "tests"
- add_test unit
- fi
-
- if [[ ${filename} =~ \.java$ ]]; then
- add_test findbugs
- fi
-}
-
-## @description Confirm site pre-patch
-## @audience private
-## @stability stable
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function mvnsite_postcompile
-{
- declare repostatus=$1
- declare result=0
-
- if [[ ${BUILDTOOL} != maven ]]; then
- return 0
- fi
-
- verify_needed_test mvnsite
- if [[ $? == 0 ]];then
- return 0
- fi
-
- if [[ "${repostatus}" = branch ]]; then
- big_console_header "Pre-patch ${PATCH_BRANCH} maven site verification"
- else
- big_console_header "Patch maven site verification"
- fi
-
-
- personality_modules "${repostatus}" mvnsite
- modules_workers "${repostatus}" mvnsite clean site site:stage
- result=$?
- modules_messages "${repostatus}" mvnsite true
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Make sure Maven's eclipse generation works.
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function mvneclipse_postcompile
-{
- declare repostatus=$1
- declare result=0
-
- if [[ ${BUILDTOOL} != maven ]]; then
- return 0
- fi
-
- verify_needed_test javac
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- if [[ "${repostatus}" = branch ]]; then
- big_console_header "Pre-patch ${PATCH_BRANCH} maven eclipse verification"
- else
- big_console_header "Patch maven eclipse verification"
- fi
-
- personality_modules "${repostatus}" mvneclipse
- modules_workers "${repostatus}" mvneclipse eclipse:clean eclipse:eclipse
- result=$?
- modules_messages "${repostatus}" mvneclipse true
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Verify mvn install works
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function maven_precompile
-{
- declare repostatus=$1
- declare result=0
-
- if [[ ${BUILDTOOL} != maven ]]; then
- return 0
- fi
-
- verify_needed_test javadoc
- result=$?
-
- verify_needed_test javac
- ((result = result + $? ))
- if [[ ${result} == 0 ]]; then
- return 0
- fi
-
- if [[ "${repostatus}" = branch ]]; then
- big_console_header "Pre-patch ${PATCH_BRANCH} maven install"
- else
- big_console_header "Patch maven install"
- fi
-
- personality_modules "${repostatus}" mvninstall
- modules_workers "${repostatus}" mvninstall -fae clean install -DskipTests=true -Dmaven.javadoc.skip=true
- result=$?
- modules_messages "${repostatus}" mvninstall true
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
-
-function maven_docker_support
-{
- echo "-v ${HOME}/.m2:${HOME}/.m2" > "${PATCH_DIR}/buildtool-docker-params.txt"
-
- if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
- echo "-v ${MAVEN_CUSTOM_REPOS_DIR}:${MAVEN_CUSTOM_REPOS_DIR}" \
- >> "${PATCH_DIR}/buildtool-docker-params.txt"
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/nobuild.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/nobuild.sh b/dev-support/test-patch.d/nobuild.sh
deleted file mode 100644
index 74d35aa..0000000
--- a/dev-support/test-patch.d/nobuild.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_build_tool nobuild
-
-function nobuild_buildfile
-{
- echo
-}
-
-function nobuild_executor
-{
- echo "true"
-}
-
-function nobuild_modules_worker
-{
- local status=$1
- local testtype=$2
- modules_workers "${status}" "${testtype}"
-}
-
-function nobuild_builtin_personality_modules
-{
- local status=$1
- local testtype=$2
- yetus_debug "built-in personality for no build system: ${status} ${testtype}"
-
- clear_personality_queue
- for module in ${CHANGED_MODULES}; do
- # shellcheck disable=SC2086
- personality_enqueue_module ${module}
- done
-}
-
-function nobuild_builtin_personality_file_tests
-{
- local filename=$1
-
- yetus_debug "Using built-in no build system personality_file_tests."
- yetus_debug " given file ${filename}"
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/perlcritic.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/perlcritic.sh b/dev-support/test-patch.d/perlcritic.sh
deleted file mode 100755
index c55f01a..0000000
--- a/dev-support/test-patch.d/perlcritic.sh
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type perlcritic
-
-PERLCRITIC_TIMER=0
-
-PERLCRITIC=${PERLCRITIC:-$(which perlcritic 2>/dev/null)}
-
-function perlcritic_usage
-{
- echo "Perl::Critic specific:"
- echo "--perlcritic=<path> path to perlcritic executable"
-}
-
-function perlcritic_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --perlcritic=*)
- PERLCRITIC=${i#*=}
- ;;
- esac
- done
-}
-
-function perlcritic_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.p[lm]$ ]]; then
- add_test perlcritic
- fi
-}
-
-function perlcritic_preapply
-{
- local i
-
- verify_needed_test perlcritic
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "Perl::Critic plugin: prepatch"
-
- if [[ ! -x ${PERLCRITIC} ]]; then
- yetus_error "${PERLCRITIC} does not exist."
- return 0
- fi
-
- start_clock
-
- echo "Running perlcritic against modified perl scripts/modules."
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
- ${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/branch-perlcritic-result.txt"
- fi
- done
- popd >/dev/null
- # keep track of how much as elapsed for us already
- PERLCRITIC_TIMER=$(stop_clock)
- return 0
-}
-
-function perlcritic_postapply
-{
- local i
- local numPrepatch
- local numPostpatch
- local diffPostpatch
-
- verify_needed_test perlcritic
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "Perl::Critic plugin: postpatch"
-
- if [[ ! -x ${PERLCRITIC} ]]; then
- yetus_error "${PERLCRITIC} is not available."
- add_vote_table 0 perlcritic "Perl::Critic was not available."
- return 0
- fi
-
- start_clock
-
- # add our previous elapsed to our new timer
- # by setting the clock back
- offset_clock "${PERLCRITIC_TIMER}"
-
- echo "Running perlcritic against modified perl scripts/modules."
- # we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
- ${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/patch-perlcritic-result.txt"
- fi
- done
- popd >/dev/null
-
- PERLCRITIC_VERSION=$(${PERLCRITIC} --version 2>/dev/null)
- add_footer_table perlcritic "v${PERLCRITIC_VERSION}"
-
- calcdiffs "${PATCH_DIR}/branch-perlcritic-result.txt" "${PATCH_DIR}/patch-perlcritic-result.txt" > "${PATCH_DIR}/diff-patch-perlcritic.txt"
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-perlcritic.txt" | ${AWK} '{print $1}')
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-perlcritic-result.txt" | ${AWK} '{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-perlcritic-result.txt" | ${AWK} '{print $1}')
-
- add_vote_table -1 perlcritic "The applied patch generated "\
- "${diffPostpatch} new Perl::Critic issues (total was ${numPrepatch}, now ${numPostpatch})."
- add_footer_table perlcritic "@@BASE@@/diff-patch-perlcritic.txt"
- return 1
- fi
-
- add_vote_table +1 perlcritic "There were no new perlcritic issues."
- return 0
-}
-
-function perlcritic_postcompile
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- perlcritic_preapply
- else
- perlcritic_postapply
- fi
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/pylint.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/pylint.sh b/dev-support/test-patch.d/pylint.sh
deleted file mode 100755
index d5af000..0000000
--- a/dev-support/test-patch.d/pylint.sh
+++ /dev/null
@@ -1,179 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type pylint
-
-PYLINT_TIMER=0
-
-PYLINT=${PYLINT:-$(which pylint 2>/dev/null)}
-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"
-}
-
-function pylint_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --pylint=*)
- PYLINT=${i#*=}
- ;;
- --pylint-options=*)
- PYLINT_OPTIONS=${i#*=}
- ;;
- esac
- done
-}
-
-function pylint_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.py$ ]]; then
- add_test pylint
- fi
-}
-
-function pylint_preapply
-{
- local i
- local count
- local tmp=${PATCH_DIR}/pylint.$$.${RANDOM}
-
- verify_needed_test pylint
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "pylint plugin: prepatch"
-
- if [[ ! -x ${PYLINT} ]]; then
- yetus_error "${PYLINT} does not exist."
- return 0
- fi
-
- start_clock
-
- echo "Running pylint against modified python scripts."
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.py$ && -f ${i} ]]; then
- # shellcheck disable=SC2086
- eval "${PYLINT} ${PYLINT_OPTIONS} --output-format=parseable --reports=n ${i}" 2>${tmp} |
- ${AWK} '1<NR' >> "${PATCH_DIR}/branch-pylint-result.txt"
- fi
- # shellcheck disable=SC2016
- count=$(${GREP} -v "^No config file found" "${tmp}" | wc -l | ${AWK} '{print $1}')
- if [[ ${count} -gt 0 ]]; then
- add_footer_table pylint "prepatch stderr: ${tmp}"
- return 1
- fi
- done
- rm "${tmp}" 2>/dev/null
- popd >/dev/null
- # keep track of how much as elapsed for us already
- PYLINT_TIMER=$(stop_clock)
- return 0
-}
-
-function pylint_postapply
-{
- local i
- local count
- local numPrepatch
- local numPostpatch
- local diffPostpatch
- local tmp=${PATCH_DIR}/pylint.$$.${RANDOM}
-
- verify_needed_test pylint
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "pylint plugin: postpatch"
-
- if [[ ! -x ${PYLINT} ]]; then
- yetus_error "${PYLINT} is not available."
- add_vote_table 0 pylint "Pylint was not available."
- return 0
- fi
-
- start_clock
-
- # add our previous elapsed to our new timer
- # by setting the clock back
- offset_clock "${PYLINT_TIMER}"
-
- echo "Running pylint against modified python scripts."
- # we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.py$ && -f ${i} ]]; then
- # shellcheck disable=SC2086
- eval "${PYLINT} ${PYLINT_OPTIONS} --output-format=parseable --reports=n ${i}" 2>${tmp} |
- ${AWK} '1<NR' >> "${PATCH_DIR}/patch-pylint-result.txt"
- fi
- # shellcheck disable=SC2016
- count=$(${GREP} -v "^No config file found" "${tmp}" | wc -l | ${AWK} '{print $1}')
- if [[ ${count} -gt 0 ]]; then
- add_vote_table -1 pylint "Something bad seems to have happened in running pylint. Please check pylint stderr files."
- add_footer_table pylint "postpatch stderr: ${tmp}"
- return 1
- fi
- done
- rm "${tmp}" 2>/dev/null
- popd >/dev/null
-
- # shellcheck disable=SC2016
- PYLINT_VERSION=$(${PYLINT} --version 2>/dev/null | ${GREP} pylint | ${AWK} '{print $NF}')
- add_footer_table pylint "v${PYLINT_VERSION%,}"
-
- calcdiffs "${PATCH_DIR}/branch-pylint-result.txt" "${PATCH_DIR}/patch-pylint-result.txt" > "${PATCH_DIR}/diff-patch-pylint.txt"
- diffPostpatch=$(${GREP} -c "^.*:.*: \[.*\] " "${PATCH_DIR}/diff-patch-pylint.txt")
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- # shellcheck disable=SC2016
- numPrepatch=$(${GREP} -c "^.*:.*: \[.*\] " "${PATCH_DIR}/branch-pylint-result.txt")
-
- # shellcheck disable=SC2016
- numPostpatch=$(${GREP} -c "^.*:.*: \[.*\] " "${PATCH_DIR}/patch-pylint-result.txt")
-
- add_vote_table -1 pylint "The applied patch generated "\
- "${diffPostpatch} new pylint issues (total was ${numPrepatch}, now ${numPostpatch})."
- add_footer_table pylint "@@BASE@@/diff-patch-pylint.txt"
- return 1
- fi
-
- add_vote_table +1 pylint "There were no new pylint issues."
- return 0
-}
-
-function pylint_postcompile
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- pylint_preapply
- else
- pylint_postapply
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/rubocop.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/rubocop.sh b/dev-support/test-patch.d/rubocop.sh
deleted file mode 100755
index c0fa2ac..0000000
--- a/dev-support/test-patch.d/rubocop.sh
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type rubocop
-
-RUBOCOP_TIMER=0
-
-RUBOCOP=${RUBOCOP:-$(which rubocop 2>/dev/null)}
-
-function rubocop_usage
-{
- echo "Rubocop specific:"
- echo "--rubocop=<path> path to rubocop executable"
-}
-
-function rubocop_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --rubocop=*)
- RUBOCOP=${i#*=}
- ;;
- esac
- done
-}
-
-function rubocop_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.rb$ ]]; then
- add_test rubocop
- fi
-}
-
-function rubocop_preapply
-{
- local i
-
- verify_needed_test rubocop
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "rubocop plugin: prepatch"
-
- if [[ ! -x ${RUBOCOP} ]]; then
- yetus_error "${RUBOCOP} does not exist."
- return 0
- fi
-
- start_clock
-
- echo "Running rubocop against modified ruby scripts."
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBOCOP} -f e "${i}" | ${AWK} '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/branch-rubocop-result.txt"
- fi
- done
- popd >/dev/null
- # keep track of how much as elapsed for us already
- RUBOCOP_TIMER=$(stop_clock)
- return 0
-}
-
-function rubocop_postapply
-{
- local i
- local numPrepatch
- local numPostpatch
- local diffPostpatch
-
- verify_needed_test rubocop
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "rubocop plugin: postpatch"
-
- if [[ ! -x ${RUBOCOP} ]]; then
- yetus_error "${RUBOCOP} is not available."
- add_vote_table 0 rubocop "Rubocop was not available."
- return 0
- fi
-
- start_clock
-
- # add our previous elapsed to our new timer
- # by setting the clock back
- offset_clock "${RUBOCOP_TIMER}"
-
- echo "Running rubocop against modified ruby scripts."
- # we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBOCOP} -f e "${i}" | ${AWK} '!/[0-9]* files? inspected/' >> "${PATCH_DIR}/patch-rubocop-result.txt"
- fi
- done
- popd >/dev/null
-
- # shellcheck disable=SC2016
- RUBOCOP_VERSION=$(${RUBOCOP} -v | ${AWK} '{print $NF}')
- add_footer_table rubocop "v${RUBOCOP_VERSION}"
-
- calcdiffs "${PATCH_DIR}/branch-rubocop-result.txt" "${PATCH_DIR}/patch-rubocop-result.txt" > "${PATCH_DIR}/diff-patch-rubocop.txt"
- diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-rubocop.txt")
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- # shellcheck disable=SC2016
- numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-rubocop-result.txt")
-
- # shellcheck disable=SC2016
- numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-rubocop-result.txt")
-
- add_vote_table -1 rubocop "The applied patch generated "\
- "${diffPostpatch} new rubocop issues (total was ${numPrepatch}, now ${numPostpatch})."
- add_footer_table rubocop "@@BASE@@/diff-patch-rubocop.txt"
- return 1
- fi
-
- add_vote_table +1 rubocop "There were no new rubocop issues."
- return 0
-}
-
-function rubocop_postcompile
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- rubocop_preapply
- else
- rubocop_postapply
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/ruby-lint.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/ruby-lint.sh b/dev-support/test-patch.d/ruby-lint.sh
deleted file mode 100755
index aa18f58..0000000
--- a/dev-support/test-patch.d/ruby-lint.sh
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type ruby_lint
-
-RUBY_LINT_TIMER=0
-
-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"
-}
-
-function ruby_lint_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --ruby-lint=*)
- RUBY_LINT=${i#*=}
- ;;
- esac
- done
-}
-
-function ruby_lint_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.rb$ ]]; then
- add_test ruby_lint
- fi
-}
-
-function ruby_lint_preapply
-{
- local i
-
- verify_needed_test ruby_lint
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "ruby-lint plugin: prepatch"
-
- if [[ ! -x ${RUBY_LINT} ]]; then
- yetus_error "${RUBY_LINT} does not exist."
- return 0
- fi
-
- start_clock
-
- echo "Running ruby-lint against modified ruby scripts."
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/branch-ruby-lint-result.txt"
- fi
- done
- popd >/dev/null
- # keep track of how much as elapsed for us already
- RUBY_LINT_TIMER=$(stop_clock)
- return 0
-}
-
-function ruby_lint_postapply
-{
- local i
- local numPrepatch
- local numPostpatch
- local diffPostpatch
-
- verify_needed_test ruby_lint
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "ruby-lint plugin: postpatch"
-
- if [[ ! -x ${RUBY_LINT} ]]; then
- yetus_error "${RUBY_LINT} is not available."
- add_vote_table 0 ruby-lint "Ruby-lint was not available."
- return 0
- fi
-
- start_clock
-
- # add our previous elapsed to our new timer
- # by setting the clock back
- offset_clock "${RUBY_LINT_TIMER}"
-
- echo "Running ruby-lint against modified ruby scripts."
- # we re-check this in case one has been added
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
- ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/patch-ruby-lint-result.txt"
- fi
- done
- popd >/dev/null
-
- # shellcheck disable=SC2016
- RUBY_LINT_VERSION=$(${RUBY_LINT} -v | ${AWK} '{print $2}')
- add_footer_table ruby-lint "${RUBY_LINT_VERSION}"
-
- calcdiffs "${PATCH_DIR}/branch-ruby-lint-result.txt" "${PATCH_DIR}/patch-ruby-lint-result.txt" > "${PATCH_DIR}/diff-patch-ruby-lint.txt"
- diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.txt")
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- # shellcheck disable=SC2016
- numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-ruby-lint-result.txt")
-
- # shellcheck disable=SC2016
- numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
-
- add_vote_table -1 ruby-lint "The applied patch generated "\
- "${diffPostpatch} new ruby-lint issues (total was ${numPrepatch}, now ${numPostpatch})."
- add_footer_table ruby-lint "@@BASE@@/diff-patch-ruby-lint.txt"
- return 1
- fi
-
- add_vote_table +1 ruby-lint "There were no new ruby-lint issues."
- return 0
-}
-
-function ruby_lint_postcompile
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- ruby_lint_preapply
- else
- ruby_lint_postapply
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/scala.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/scala.sh b/dev-support/test-patch.d/scala.sh
deleted file mode 100755
index 06aa86f..0000000
--- a/dev-support/test-patch.d/scala.sh
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type scalac
-add_test_type scaladoc
-
-function scalac_filefilter
-{
- declare filename=$1
-
- if [[ ${filename} =~ \.scala$ ]]; then
- yetus_debug "tests/scalac: ${filename}"
- add_test scalac
- add_test compile
- fi
-}
-
-function scaladoc_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.scala$ ]]; then
- yetus_debug "tests/scaladoc: ${filename}"
- add_test scaladoc
- fi
-}
-
-## @description
-## @audience private
-## @stability stable
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function scalac_compile
-{
- declare codebase=$1
- declare multijdkmode=$2
-
- verify_needed_test scalac
- if [[ $? = 0 ]]; then
- return 0
- fi
-
- if [[ ${codebase} = patch ]]; then
- generic_postlog_compare compile scalac "${multijdkmode}"
- fi
-}
-
-## @description Count and compare the number of ScalaDoc warnings pre- and post- patch
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function scaladoc_rebuild
-{
- declare codebase=$1
-
- if [[ "${codebase}" = branch ]]; then
- generic_pre_handler scaladoc false
- else
- generic_post_handler scaladoc scaladoc false true
- fi
-}
\ No newline at end of file
[06/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
deleted file mode 100755
index 93874a2..0000000
--- a/dev-support/test-patch.sh
+++ /dev/null
@@ -1,2647 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Make sure that bash version meets the pre-requisite
-
-if [[ -z "${BASH_VERSINFO}" ]] \
- || [[ "${BASH_VERSINFO[0]}" -lt 3 ]] \
- || [[ "${BASH_VERSINFO[0]}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then
- echo "bash v3.2+ is required. Sorry."
- exit 1
-fi
-
-this="${BASH_SOURCE-$0}"
-BINDIR=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
-STARTINGDIR=$(pwd)
-USER_PARAMS=("$@")
-GLOBALTIMER=$(date +"%s")
-#shellcheck disable=SC2034
-QATESTMODE=false
-
-# global arrays
-declare -a TP_HEADER
-declare -a TP_VOTE_TABLE
-declare -a TP_TEST_TABLE
-declare -a TP_FOOTER_TABLE
-declare -a MODULE_STATUS
-declare -a MODULE_STATUS_TIMER
-declare -a MODULE_STATUS_MSG
-declare -a MODULE_STATUS_LOG
-declare -a MODULE_COMPILE_LOG
-declare -a MODULE
-
-TP_HEADER_COUNTER=0
-TP_VOTE_COUNTER=0
-TP_TEST_COUNTER=0
-TP_FOOTER_COUNTER=0
-
-## @description Setup the default global variables
-## @audience public
-## @stability stable
-## @replaceable no
-function setup_defaults
-{
- common_defaults
-
- DOCKERFILE="${BINDIR}/test-patch-docker/Dockerfile-startstub"
- HOW_TO_CONTRIBUTE="https://yetus.apache.org/documentation/latest/precommit-patchnames"
- INSTANCE=${RANDOM}
- RELOCATE_PATCH_DIR=false
-
- ALLOWSUMMARIES=true
-
- DOCKERSUPPORT=false
- BUILD_NATIVE=${BUILD_NATIVE:-true}
-
- BUILDTOOLCWD=true
-
- # shellcheck disable=SC2034
- CHANGED_MODULES=""
- # shellcheck disable=SC2034
- CHANGED_UNFILTERED_MODULES=""
- # shellcheck disable=SC2034
- CHANGED_UNION_MODULES=""
- USER_MODULE_LIST=""
- CHANGED_FILES=""
- REEXECED=false
- RESETREPO=false
- ISSUE=""
- TIMER=$(date +"%s")
- BUILDTOOL=maven
- JDK_TEST_LIST="compile javadoc unit"
-}
-
-## @description Convert the given module name to a file fragment
-## @audience public
-## @stability stable
-## @replaceable no
-## @param module
-function module_file_fragment
-{
- local mod=$1
- if [[ ${mod} == . ]]; then
- echo root
- else
- echo "$1" | tr '/' '_' | tr '\\' '_'
- fi
-}
-
-## @description Convert time in seconds to m + s
-## @audience public
-## @stability stable
-## @replaceable no
-## @param seconds
-function clock_display
-{
- local -r elapsed=$1
-
- if [[ ${elapsed} -lt 0 ]]; then
- echo "N/A"
- else
- printf "%3sm %02ss" $((elapsed/60)) $((elapsed%60))
- fi
-}
-
-## @description Activate the local timer
-## @audience public
-## @stability stable
-## @replaceable no
-function start_clock
-{
- yetus_debug "Start clock"
- TIMER=$(date +"%s")
-}
-
-## @description Print the elapsed time in seconds since the start of the local timer
-## @audience public
-## @stability stable
-## @replaceable no
-function stop_clock
-{
- local -r stoptime=$(date +"%s")
- local -r elapsed=$((stoptime-TIMER))
- yetus_debug "Stop clock"
-
- echo ${elapsed}
-}
-
-## @description Print the elapsed time in seconds since the start of the global timer
-## @audience private
-## @stability stable
-## @replaceable no
-function stop_global_clock
-{
- local -r stoptime=$(date +"%s")
- local -r elapsed=$((stoptime-GLOBALTIMER))
- yetus_debug "Stop global clock"
-
- echo ${elapsed}
-}
-
-## @description Add time to the local timer
-## @audience public
-## @stability stable
-## @replaceable no
-## @param seconds
-function offset_clock
-{
- declare off=$1
-
- yetus_debug "offset clock by ${off}"
-
- if [[ -n ${off} ]]; then
- ((TIMER=TIMER-off))
- else
- yetus_error "ASSERT: no offset passed to offset_clock: ${index}"
- generate_stack
- fi
-}
-
-## @description generate a stack trace when in debug mode
-## @audience public
-## @stability stable
-## @replaceable no
-## @return exits
-function generate_stack
-{
- declare frame
-
- if [[ "${YETUS_SHELL_SCRIPT_DEBUG}" = true ]]; then
- while caller "${frame}"; do
- ((frame++));
- done
- fi
- exit 1
-}
-
-## @description Add to the header of the display
-## @audience public
-## @stability stable
-## @replaceable no
-## @param string
-function add_header_line
-{
- # shellcheck disable=SC2034
- TP_HEADER[${TP_HEADER_COUNTER}]="$*"
- ((TP_HEADER_COUNTER=TP_HEADER_COUNTER+1 ))
-}
-
-## @description Add to the output table. If the first parameter is a number
-## @description that is the vote for that column and calculates the elapsed time
-## @description based upon the last start_clock(). If it the string null, then it is
-## @description a special entry that signifies extra
-## @description content for the final column. The second parameter is the reporting
-## @description subsystem (or test) that is providing the vote. The second parameter
-## @description is always required. The third parameter is any extra verbage that goes
-## @description with that subsystem.
-## @audience public
-## @stability stable
-## @replaceable no
-## @param +1/0/-1/null
-## @param subsystem
-## @param string
-## @return Elapsed time display
-function add_vote_table
-{
- local value=$1
- local subsystem=$2
- shift 2
-
- local calctime
- local -r elapsed=$(stop_clock)
-
- yetus_debug "add_vote_table ${value} ${subsystem} ${*}"
-
- calctime=$(clock_display "${elapsed}")
-
- if [[ ${value} == "1" ]]; then
- value="+1"
- fi
-
- if [[ -z ${value} ]]; then
- # shellcheck disable=SC2034
- TP_VOTE_TABLE[${TP_VOTE_COUNTER}]="| | ${subsystem} | | ${*:-} |"
- else
- # shellcheck disable=SC2034
- TP_VOTE_TABLE[${TP_VOTE_COUNTER}]="| ${value} | ${subsystem} | ${calctime} | $* |"
- fi
- ((TP_VOTE_COUNTER=TP_VOTE_COUNTER+1))
-}
-
-## @description Report the JVM version of the given directory
-## @stability stable
-## @audience private
-## @replaceable yes
-## @params directory
-## @returns version
-function report_jvm_version
-{
- #shellcheck disable=SC2016
- "${1}/bin/java" -version 2>&1 | head -1 | ${AWK} '{print $NF}' | tr -d \"
-}
-
-## @description Verify if a given test is multijdk
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param test
-## @return 1 = yes
-## @return 0 = no
-function verify_multijdk_test
-{
- local i=$1
-
- if [[ "${JDK_DIR_LIST}" == "${JAVA_HOME}" ]]; then
- yetus_debug "MultiJDK not configured."
- return 0
- fi
-
- if [[ ${JDK_TEST_LIST} =~ $i ]]; then
- yetus_debug "${i} is in ${JDK_TEST_LIST} and MultiJDK configured."
- return 1
- fi
- return 0
-}
-
-## @description Put the opening environment information at the bottom
-## @description of the footer table
-## @stability stable
-## @audience private
-## @replaceable yes
-function prepopulate_footer
-{
- # shellcheck disable=SC2155
- declare -r unamea=$(uname -a)
-
- add_footer_table "uname" "${unamea}"
- add_footer_table "Build tool" "${BUILDTOOL}"
-
- if [[ -n ${REEXECPERSONALITY} ]]; then
- add_footer_table "Personality" "${REEXECPERSONALITY}"
- elif [[ -n ${PERSONALITY} ]]; then
- add_footer_table "Personality" "${PERSONALITY}"
- fi
-
- gitrev=$(${GIT} rev-parse --verify --short HEAD)
-
- add_footer_table "git revision" "${PATCH_BRANCH} / ${gitrev}"
-}
-
-## @description Put docker stats in various tables
-## @stability stable
-## @audience private
-## @replaceable yes
-function finish_docker_stats
-{
- if [[ ${DOCKERMODE} == true ]]; then
- # DOCKER_VERSION is set by our creator.
- add_footer_table "Docker" "${DOCKER_VERSION}"
- fi
-}
-
-## @description Put the max memory consumed by maven at the bottom of the table.
-## @audience private
-## @stability stable
-## @replaceable no
-function finish_footer_table
-{
- local maxmem
-
- # `sort | head` can cause a broken pipe error, but we can ignore it just like compute_gitdiff.
- # shellcheck disable=SC2016,SC2086
- maxmem=$(find "${PATCH_DIR}" -type f -exec ${AWK} 'match($0, /^\[INFO\] Final Memory: [0-9]+/)
- { print substr($0, 22, RLENGTH-21) }' {} \; | sort -nr 2>/dev/null | head -n 1)
-
- if [[ -n ${maxmem} ]]; then
- add_footer_table "Max memory used" "${maxmem}MB"
- fi
-}
-
-## @description Put the final elapsed time at the bottom of the table.
-## @audience private
-## @stability stable
-## @replaceable no
-function finish_vote_table
-{
-
- local -r elapsed=$(stop_global_clock)
- local calctime
-
- calctime=$(clock_display "${elapsed}")
-
- echo ""
- echo "Total Elapsed time: ${calctime}"
- echo ""
-
- # shellcheck disable=SC2034
- TP_VOTE_TABLE[${TP_VOTE_COUNTER}]="| | | ${calctime} | |"
- ((TP_VOTE_COUNTER=TP_VOTE_COUNTER+1 ))
-}
-
-## @description Add to the footer of the display. @@BASE@@ will get replaced with the
-## @description correct location for the local filesystem in dev mode or the URL for
-## @description Jenkins mode.
-## @audience public
-## @stability stable
-## @replaceable no
-## @param subsystem
-## @param string
-function add_footer_table
-{
- local subsystem=$1
- shift 1
-
- # shellcheck disable=SC2034
- TP_FOOTER_TABLE[${TP_FOOTER_COUNTER}]="| ${subsystem} | $* |"
- ((TP_FOOTER_COUNTER=TP_FOOTER_COUNTER+1 ))
-}
-
-## @description Special table just for unit test failures
-## @audience public
-## @stability stable
-## @replaceable no
-## @param failurereason
-## @param testlist
-function add_test_table
-{
- local failure=$1
- shift 1
-
- # shellcheck disable=SC2034
- TP_TEST_TABLE[${TP_TEST_COUNTER}]="| ${failure} | $* |"
- ((TP_TEST_COUNTER=TP_TEST_COUNTER+1 ))
-}
-
-## @description Large display for the user console
-## @audience public
-## @stability stable
-## @replaceable no
-## @param string
-## @return large chunk of text
-function big_console_header
-{
- local text="$*"
- local spacing=$(( (75+${#text}) /2 ))
- printf "\n\n"
- echo "============================================================================"
- echo "============================================================================"
- printf "%*s\n" ${spacing} "${text}"
- echo "============================================================================"
- echo "============================================================================"
- printf "\n\n"
-}
-
-## @description Find the largest size of a column of an array
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return size
-function findlargest
-{
- local column=$1
- shift
- local a=("$@")
- local sizeofa=${#a[@]}
- local i=0
- local string
- local maxlen=0
-
- until [[ ${i} -eq ${sizeofa} ]]; do
- # shellcheck disable=SC2086
- string=$( echo ${a[$i]} | cut -f$((column + 1)) -d\| )
- if [[ ${#string} -gt ${maxlen} ]]; then
- maxlen=${#string}
- fi
- i=$((i+1))
- done
- echo "${maxlen}"
-}
-
-## @description Write the contents of a file to all of the bug systems
-## @description (so content should avoid special formatting)
-## @params filename
-## @stability stable
-## @audience public
-function write_comment
-{
- local -r commentfile=${1}
- declare bug
-
- for bug in ${BUGCOMMENTS}; do
- if declare -f ${bug}_write_comment >/dev/null; then
- "${bug}_write_comment" "${commentfile}"
- fi
- done
-}
-
-## @description Verify that the patch directory is still in working order
-## @description since bad actors on some systems wipe it out. If not,
-## @description recreate it and then exit
-## @audience private
-## @stability evolving
-## @replaceable yes
-## @returns may exit on failure
-function verify_patchdir_still_exists
-{
- local -r commentfile=/tmp/testpatch.$$.${RANDOM}
- local extra=""
-
- if [[ ! -d ${PATCH_DIR} ]]; then
- rm "${commentfile}" 2>/dev/null
-
- echo "(!) The patch artifact directory has been removed! " > "${commentfile}"
- echo "This is a fatal error for test-patch.sh. Aborting. " >> "${commentfile}"
- echo
- cat ${commentfile}
- echo
- if [[ ${JENKINS} == true ]]; then
- if [[ -n ${NODE_NAME} ]]; then
- extra=" (node ${NODE_NAME})"
- fi
- echo "Jenkins${extra} information at ${BUILD_URL} may provide some hints. " >> "${commentfile}"
-
- write_comment ${commentfile}
- fi
-
- rm "${commentfile}"
- cleanup_and_exit "${RESULT}"
- fi
-}
-
-## @description generate a list of all files and line numbers in $GITDIFFLINES that
-## @description that were added/changed in the source repo. $GITDIFFCONTENT
-## @description is same file, but also includes the content of those lines
-## @audience private
-## @stability stable
-## @replaceable no
-function compute_gitdiff
-{
- local file
- local line
- local startline
- local counter
- local numlines
- local actual
- local content
- local outfile="${PATCH_DIR}/computegitdiff.${RANDOM}"
-
- pushd "${BASEDIR}" >/dev/null
- ${GIT} add --all --intent-to-add
- while read -r line; do
- if [[ ${line} =~ ^\+\+\+ ]]; then
- file="./"$(echo "${line}" | cut -f2- -d/)
- continue
- elif [[ ${line} =~ ^@@ ]]; then
- startline=$(echo "${line}" | cut -f3 -d' ' | cut -f1 -d, | tr -d + )
- numlines=$(echo "${line}" | cut -f3 -d' ' | cut -s -f2 -d, )
- # if this is empty, then just this line
- # if it is 0, then no lines were added and this part of the patch
- # is strictly a delete
- if [[ ${numlines} == 0 ]]; then
- continue
- elif [[ -z ${numlines} ]]; then
- numlines=1
- fi
- counter=0
- # it isn't obvious, but on MOST platforms under MOST use cases,
- # this is faster than using sed, and definitely faster than using
- # awk.
- # http://unix.stackexchange.com/questions/47407/cat-line-x-to-line-y-on-a-huge-file
- # has a good discussion w/benchmarks
- #
- # note that if tail is still sending data through the pipe, but head gets enough
- # to do what was requested, head will exit, leaving tail with a broken pipe.
- # we're going to send stderr to /dev/null and ignore the error since head's
- # output is really what we're looking for
- tail -n "+${startline}" "${file}" 2>/dev/null | head -n ${numlines} > "${outfile}"
- oldifs=${IFS}
- IFS=''
- while read -r content; do
- ((actual=counter+startline))
- echo "${file}:${actual}:" >> "${GITDIFFLINES}"
- printf "%s:%s:%s\n" "${file}" "${actual}" "${content}" >> "${GITDIFFCONTENT}"
- ((counter=counter+1))
- done < "${outfile}"
- rm "${outfile}"
- IFS=${oldifs}
- fi
- done < <("${GIT}" diff --unified=0 --no-color)
-
- if [[ ! -f "${GITDIFFLINES}" ]]; then
- touch "${GITDIFFLINES}"
- fi
-
- if [[ ! -f "${GITDIFFCONTENT}" ]]; then
- touch "${GITDIFFCONTENT}"
- fi
-
- if [[ -s "${GITDIFFLINES}" ]]; then
- compute_unidiff
- else
- touch "${GITUNIDIFFLINES}"
- fi
-
- popd >/dev/null
-}
-
-## @description generate an index of unified diff lines vs. modified/added lines
-## @description ${GITDIFFLINES} must exist.
-## @audience private
-## @stability stable
-## @replaceable no
-function compute_unidiff
-{
- declare fn
- declare filen
- declare tmpfile="${PATCH_DIR}/tmp.$$.${RANDOM}"
-
- # now that we know what lines are where, we can deal
- # with github's pain-in-the-butt API. It requires
- # that the client provides the line number of the
- # unified diff on a per file basis.
-
- # First, build a per-file unified diff, pulling
- # out the 'extra' lines, grabbing the adds with
- # the line number in the diff file along the way,
- # finally rewriting the line so that it is in
- # './filename:diff line:content' format
-
- for fn in ${CHANGED_FILES}; do
- filen=${fn##./}
-
- if [[ -f "${filen}" ]]; then
- ${GIT} diff ${filen} \
- | tail -n +6 \
- | ${GREP} -n '^+' \
- | ${GREP} -vE '^[0-9]*:\+\+\+' \
- | ${SED} -e 's,^\([0-9]*:\)\+,\1,g' \
- -e s,^,./${filen}:,g \
- >> "${tmpfile}"
- fi
- done
-
- # at this point, tmpfile should be in the same format
- # as gitdiffcontent, just with different line numbers.
- # let's do a merge (using gitdifflines because it's easier)
-
- # ./filename:real number:diff number
- # shellcheck disable=SC2016
- paste -d: "${GITDIFFLINES}" "${tmpfile}" \
- | ${AWK} -F: '{print $1":"$2":"$5":"$6}' \
- >> "${GITUNIDIFFLINES}"
-
- rm "${tmpfile}"
-}
-
-## @description Print the command to be executing to the screen. Then
-## @description run the command, sending stdout and stderr to the given filename
-## @description This will also ensure that any directories in ${BASEDIR} have
-## @description the exec bit set as a pre-exec step.
-## @audience public
-## @stability stable
-## @param filename
-## @param command
-## @param [..]
-## @replaceable no
-## @returns $?
-function echo_and_redirect
-{
- local logfile=$1
- shift
-
- verify_patchdir_still_exists
-
- find "${BASEDIR}" -type d -exec chmod +x {} \;
- # to the screen
- echo "cd $(pwd)"
- echo "${*} > ${logfile} 2>&1"
- yetus_run_and_redirect "${logfile}" "${@}"
-}
-
-## @description is a given directory relative to BASEDIR?
-## @audience public
-## @stability stable
-## @replaceable yes
-## @param path
-## @returns 1 - no, path
-## @returns 0 - yes, path - BASEDIR
-function relative_dir
-{
- local p=${1#${BASEDIR}}
-
- if [[ ${#p} -eq ${#1} ]]; then
- echo "${p}"
- return 1
- fi
- p=${p#/}
- echo "${p}"
- return 0
-}
-
-## @description Print the usage information
-## @audience public
-## @stability stable
-## @replaceable no
-function yetus_usage
-{
- local -r up=$(echo "${PROJECT_NAME}" | tr '[:lower:]' '[:upper:]')
-
- echo "Usage: 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 "--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')"
- # 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: ${HOW_TO_CONTRIBUTE} )"
- 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 "--dockerfile=<file> Dockerfile fragment to use as the base"
- 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 ""
- 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
- 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."
-
- importplugins
-
- for plugin in ${BUILDTOOLS} ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS}; do
- if declare -f ${plugin}_usage >/dev/null 2>&1; then
- echo
- "${plugin}_usage"
- fi
- done
-}
-
-## @description Interpret the command line parameters
-## @audience private
-## @stability stable
-## @replaceable no
-## @params $@
-## @return May exit on failure
-function parse_args
-{
- local i
- local j
-
- common_args "$@"
-
- for i in "$@"; do
- case ${i} in
- --bugcomments=*)
- BUGCOMMENTS=${i#*=}
- BUGCOMMENTS=${BUGCOMMENTS//,/ }
- ;;
- --build-native=*)
- BUILD_NATIVE=${i#*=}
- ;;
- --build-tool=*)
- BUILDTOOL=${i#*=}
- ;;
- --build-url=*)
- BUILD_URL=${i#*=}
- ;;
- --contrib-guide=*)
- HOW_TO_CONTRIBUTE=${i#*=}
- ;;
- --dirty-workspace)
- DIRTY_WORKSPACE=true
- ;;
- --docker)
- DOCKERSUPPORT=true
- ;;
- --dockerfile=*)
- DOCKERFILE=${i#*=}
- ;;
- --dockermode)
- DOCKERMODE=true
- ;;
- --java-home=*)
- JAVA_HOME=${i#*=}
- ;;
- --jenkins)
- JENKINS=true
- TEST_PARALLEL=${TEST_PARALLEL:-true}
- INSTANCE=${EXECUTOR_NUMBER:-RANDOM}
- ;;
- --linecomments=*)
- BUGLINECOMMENTS=${i#*=}
- BUGLINECOMMENTS=${BUGLINECOMMENTS//,/ }
- ;;
- --modulelist=*)
- USER_MODULE_LIST=${i#*=}
- USER_MODULE_LIST=${USER_MODULE_LIST//,/ }
- yetus_debug "Manually forcing modules ${USER_MODULE_LIST}"
- ;;
- --multijdkdirs=*)
- JDK_DIR_LIST=${i#*=}
- JDK_DIR_LIST=${JDK_DIR_LIST//,/ }
- yetus_debug "Multi-JVM mode activated with ${JDK_DIR_LIST}"
- ;;
- --multijdktests=*)
- JDK_TEST_LIST=${i#*=}
- JDK_TEST_LIST=${JDK_TEST_LIST//,/ }
- yetus_debug "Multi-JVM test list: ${JDK_TEST_LIST}"
- ;;
- --mv-patch-dir)
- RELOCATE_PATCH_DIR=true;
- ;;
- --personality=*)
- PERSONALITY=${i#*=}
- ;;
- --reexec)
- REEXECED=true
- ;;
- --resetrepo)
- RESETREPO=true
- ;;
- --run-tests)
- RUN_TESTS=true
- ;;
- --skip-dirs=*)
- MODULE_SKIPDIRS=${i#*=}
- MODULE_SKIPDIRS=${MODULE_SKIPDIRS//,/ }
- yetus_debug "Setting skipdirs to ${MODULE_SKIPDIRS}"
- ;;
- --summarize=*)
- ALLOWSUMMARIES=${i#*=}
- ;;
- --test-parallel=*)
- TEST_PARALLEL=${i#*=}
- ;;
- --test-threads=*)
- # shellcheck disable=SC2034
- TEST_THREADS=${i#*=}
- ;;
- --tpglobaltimer=*)
- GLOBALTIMER=${i#*=}
- ;;
- --tpinstance=*)
- INSTANCE=${i#*=}
- EXECUTOR_NUMBER=${INSTANCE}
- ;;
- --tpperson=*)
- REEXECPERSONALITY=${i#*=}
- ;;
- --tpreexectimer=*)
- REEXECLAUNCHTIMER=${i#*=}
- ;;
- --*)
- ## PATCH_OR_ISSUE can't be a --. So this is probably
- ## a plugin thing.
- continue
- ;;
- *)
- PATCH_OR_ISSUE=${i}
- ;;
- esac
- done
-
- if [[ -n ${REEXECLAUNCHTIMER} ]]; then
- TIMER=${REEXECLAUNCHTIMER};
- else
- start_clock
- fi
-
- if [[ ${REEXECED} == true
- && ${DOCKERMODE} == true ]]; then
- add_vote_table 0 reexec "docker + precommit patch detected."
- elif [[ ${REEXECED} == true ]]; then
- add_vote_table 0 reexec "precommit patch detected."
- elif [[ ${DOCKERMODE} == true ]]; then
- add_vote_table 0 reexec "docker mode."
- fi
-
- if [[ -z "${PATCH_OR_ISSUE}" ]]; then
- yetus_usage
- exit 1
- fi
-
- # we need absolute dir for ${BASEDIR}
- cd "${STARTINGDIR}"
- BASEDIR=$(cd -P -- "${BASEDIR}" >/dev/null && pwd -P)
-
- if [[ -n ${USER_PATCH_DIR} ]]; then
- PATCH_DIR="${USER_PATCH_DIR}"
- fi
-
- cd "${STARTINGDIR}"
- if [[ ! -d ${PATCH_DIR} ]]; then
- mkdir -p "${PATCH_DIR}"
- if [[ $? == 0 ]] ; then
- echo "${PATCH_DIR} has been created"
- else
- echo "Unable to create ${PATCH_DIR}"
- cleanup_and_exit 1
- fi
- fi
-
- # we need absolute dir for PATCH_DIR
- PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
-
- if [[ ${JENKINS} == "true" ]]; then
- echo "Running in Jenkins mode"
- ISSUE=${PATCH_OR_ISSUE}
- RESETREPO=true
- else
- if [[ ${RESETREPO} == "true" ]] ; then
- echo "Running in destructive (--resetrepo) developer mode"
- else
- echo "Running in developer mode"
- fi
- JENKINS=false
- fi
-
- if [[ -n "${USER_PLUGIN_DIR}" ]]; then
- USER_PLUGIN_DIR=$(cd -P -- "${USER_PLUGIN_DIR}" >/dev/null && pwd -P)
- fi
-
- GITDIFFLINES="${PATCH_DIR}/gitdifflines.txt"
- GITDIFFCONTENT="${PATCH_DIR}/gitdiffcontent.txt"
- GITUNIDIFFLINES="${PATCH_DIR}/gitdiffunilines.txt"
-
-}
-
-## @description Locate the build file for a given directory
-## @audience private
-## @stability stable
-## @replaceable no
-## @return directory containing the buildfile. Nothing returned if not found.
-## @params buildfile
-## @params directory
-function find_buildfile_dir
-{
- local buildfile=$1
- local dir=$2
-
- yetus_debug "Find ${buildfile} dir for: ${dir}"
-
- while builtin true; do
- if [[ -f "${dir}/${buildfile}" ]];then
- echo "${dir}"
- yetus_debug "Found: ${dir}"
- return 0
- elif [[ ${dir} == "." || ${dir} == "/" ]]; then
- yetus_debug "ERROR: ${buildfile} is not found."
- return 1
- else
- dir=$(dirname "${dir}")
- fi
- done
-}
-
-## @description List of files that ${PATCH_DIR}/patch modifies
-## @audience private
-## @stability stable
-## @replaceable no
-## @return None; sets ${CHANGED_FILES}
-function find_changed_files
-{
- # get a list of all of the files that have been changed,
- # except for /dev/null (which would be present for new files).
- # Additionally, remove any a/ b/ patterns at the front of the patch filenames.
- # shellcheck disable=SC2016
- CHANGED_FILES=$(${AWK} 'function p(s){sub("^[ab]/","",s); if(s!~"^/dev/null"){print s}}
- /^diff --git / { p($3); p($4) }
- /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
-}
-
-## @description Check for directories to skip during
-## @description changed module calcuation
-## @audience private
-## @stability stable
-## @replaceable no
-## @params directory
-## @returns 0 for use
-## @returns 1 for skip
-function module_skipdir
-{
- local dir=${1}
- local i
-
- yetus_debug "Checking skipdirs for ${dir}"
-
- if [[ -z ${MODULE_SKIPDIRS} ]]; then
- yetus_debug "Skipping skipdirs"
- return 0
- fi
-
- while builtin true; do
- for i in ${MODULE_SKIPDIRS}; do
- if [[ ${dir} = "${i}" ]];then
- yetus_debug "Found a skip: ${dir}"
- return 1
- fi
- done
- if [[ ${dir} == "." || ${dir} == "/" ]]; then
- return 0
- else
- dir=$(dirname "${dir}")
- yetus_debug "Trying to skip: ${dir}"
- fi
- done
-}
-
-## @description Find the modules of the build that ${PATCH_DIR}/patch modifies
-## @audience private
-## @stability stable
-## @replaceable no
-## @return None; sets ${CHANGED_MODULES} and ${CHANGED_UNFILTERED_MODULES}
-function find_changed_modules
-{
- local i
- local changed_dirs
- local builddirs
- local builddir
- local module
- local buildmods
- local prev_builddir
- local i=1
- local dir
- local buildfile
-
- buildfile=$("${BUILDTOOL}_buildfile")
-
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: Unsupported build tool."
- bugsystem_finalreport 1
- cleanup_and_exit 1
- fi
-
- changed_dirs=$(for i in ${CHANGED_FILES}; do dirname "${i}"; done | sort -u)
-
- # Empty string indicates the build system wants to disable module detection
- if [[ -z ${buildfile} ]]; then
- buiddirs="."
- else
- # Now find all the modules that were changed
- for i in ${changed_dirs}; do
-
- module_skipdir "${i}"
- if [[ $? != 0 ]]; then
- continue
- fi
-
- builddir=$(find_buildfile_dir "${buildfile}" "${i}")
- if [[ -z ${builddir} ]]; then
- yetus_error "ERROR: ${buildfile} is not found. Make sure the target is a ${BUILDTOOL}-based project."
- bugsystem_finalreport 1
- cleanup_and_exit 1
- fi
- builddirs="${builddirs} ${builddir}"
- done
- fi
-
- #shellcheck disable=SC2086,SC2034
- CHANGED_UNFILTERED_MODULES=$(echo ${builddirs} ${USER_MODULE_LIST} | tr ' ' '\n' | sort -u)
- #shellcheck disable=SC2086,SC2116
- CHANGED_UNFILTERED_MODULES=$(echo ${CHANGED_UNFILTERED_MODULES})
-
- if [[ ${BUILDTOOL} = maven ]]; then
- # Filter out modules without code
- for module in ${builddirs}; do
- ${GREP} "<packaging>pom</packaging>" "${module}/pom.xml" > /dev/null
- if [[ "$?" != 0 ]]; then
- buildmods="${buildmods} ${module}"
- fi
- done
- else
- buildmods=${CHANGED_UNFILTERED_MODULES}
- fi
-
- #shellcheck disable=SC2086,SC2034
- CHANGED_MODULES=$(echo ${buildmods} ${USER_MODULE_LIST} | tr ' ' '\n' | sort -u)
-
- # turn it back into a list so that anyone printing doesn't
- # generate multiline output
- #shellcheck disable=SC2086,SC2116
- CHANGED_MODULES=$(echo ${CHANGED_MODULES})
-
- yetus_debug "Locate the union of ${CHANGED_MODULES}"
- # shellcheck disable=SC2086
- count=$(echo ${CHANGED_MODULES} | wc -w)
- if [[ ${count} -lt 2 ]]; then
- yetus_debug "Only one entry, so keeping it ${CHANGED_MODULES}"
- # shellcheck disable=SC2034
- CHANGED_UNION_MODULES=${CHANGED_MODULES}
- return
- fi
-
- i=1
- while [[ ${i} -lt 100 ]]
- do
- module=$(echo "${CHANGED_MODULES}" | tr ' ' '\n' | cut -f1-${i} -d/ | uniq)
- count=$(echo "${module}" | wc -w)
- if [[ ${count} -eq 1
- && -f ${module}/${buildfile} ]]; then
- prev_builddir=${module}
- elif [[ ${count} -gt 1 ]]; then
- builddir=${prev_builddir}
- break
- fi
- ((i=i+1))
- done
-
- if [[ -z ${builddir} ]]; then
- builddir="."
- fi
-
- yetus_debug "Finding union of ${builddir}"
- builddir=$(find_buildfile_dir "${buildfile}" "${builddir}" || true)
-
- #shellcheck disable=SC2034
- CHANGED_UNION_MODULES="${builddir}"
-}
-
-## @description git checkout the appropriate branch to test. Additionally, this calls
-## @description 'determine_branch' based upon the context provided
-## @description in ${PATCH_DIR} and in git after checkout.
-## @audience private
-## @stability stable
-## @replaceable no
-## @return 0 on success. May exit on failure.
-function git_checkout
-{
- local currentbranch
- local exemptdir
- local status
-
- big_console_header "Confirming git environment"
-
- cd "${BASEDIR}"
- if [[ ! -d .git ]]; then
- yetus_error "ERROR: ${BASEDIR} is not a git repo."
- cleanup_and_exit 1
- fi
-
- if [[ ${RESETREPO} == "true" ]] ; then
-
- if [[ -d .git/rebase-apply ]]; then
- yetus_error "ERROR: a previous rebase failed. Aborting it."
- ${GIT} rebase --abort
- fi
-
- ${GIT} reset --hard
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: git reset is failing"
- cleanup_and_exit 1
- fi
-
- # if PATCH_DIR is in BASEDIR, then we don't want
- # git wiping it out.
- exemptdir=$(relative_dir "${PATCH_DIR}")
- if [[ $? == 1 ]]; then
- ${GIT} clean -xdf
- else
- # we do, however, want it emptied of all _files_.
- # we need to leave _directories_ in case we are in
- # re-exec mode (which places a directory full of stuff in it)
- yetus_debug "Exempting ${exemptdir} from clean"
- rm "${PATCH_DIR}/*" 2>/dev/null
- ${GIT} clean -xdf -e "${exemptdir}"
- fi
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: git clean is failing"
- cleanup_and_exit 1
- fi
-
- ${GIT} checkout --force "${PATCH_BRANCH_DEFAULT}"
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: git checkout --force ${PATCH_BRANCH_DEFAULT} is failing"
- cleanup_and_exit 1
- fi
-
- determine_branch
-
- # we need to explicitly fetch in case the
- # git ref hasn't been brought in tree yet
- if [[ ${OFFLINE} == false ]]; then
-
- ${GIT} pull --rebase
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: git pull is failing"
- cleanup_and_exit 1
- fi
- fi
- # forcibly checkout this branch or git ref
- ${GIT} checkout --force "${PATCH_BRANCH}"
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: git checkout ${PATCH_BRANCH} is failing"
- cleanup_and_exit 1
- fi
-
- # if we've selected a feature branch that has new changes
- # since our last build, we'll need to rebase to see those changes.
- if [[ ${OFFLINE} == false ]]; then
- ${GIT} pull --rebase
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: git pull is failing"
- cleanup_and_exit 1
- fi
- fi
-
- else
-
- status=$(${GIT} status --porcelain)
- if [[ "${status}" != "" && -z ${DIRTY_WORKSPACE} ]] ; then
- yetus_error "ERROR: --dirty-workspace option not provided."
- yetus_error "ERROR: can't run in a workspace that contains the following modifications"
- yetus_error "${status}"
- cleanup_and_exit 1
- fi
-
- determine_branch
-
- currentbranch=$(${GIT} rev-parse --abbrev-ref HEAD)
- if [[ "${currentbranch}" != "${PATCH_BRANCH}" ]];then
- echo "WARNING: Current git branch is ${currentbranch} but patch is built for ${PATCH_BRANCH}."
- echo "WARNING: Continuing anyway..."
- PATCH_BRANCH=${currentbranch}
- fi
- fi
-
- return 0
-}
-
-## @description Confirm the given branch is a git reference
-## @descriptoin or a valid gitXYZ commit hash
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param branch
-## @return 0 on success, if gitXYZ was passed, PATCH_BRANCH=xyz
-## @return 1 on failure
-function verify_valid_branch
-{
- local check=$1
- local i
- local hash
-
- # shortcut some common
- # non-resolvable names
- if [[ -z ${check} ]]; then
- return 1
- fi
-
- if [[ ${check} =~ ^git ]]; then
- hash=$(echo "${check}" | cut -f2- -dt)
- if [[ -n ${hash} ]]; then
- ${GIT} cat-file -t "${hash}" >/dev/null 2>&1
- if [[ $? -eq 0 ]]; then
- PATCH_BRANCH=${hash}
- return 0
- fi
- return 1
- else
- return 1
- fi
- fi
-
- ${GIT} show-ref "${check}" >/dev/null 2>&1
- return $?
-}
-
-## @description Try to guess the branch being tested using a variety of heuristics
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success, with PATCH_BRANCH updated appropriately
-## @return 1 on failure, with PATCH_BRANCH updated to PATCH_BRANCH_DEFAULT
-function determine_branch
-{
- declare bugs
- declare retval=1
-
- # something has already set this, so move on
- if [[ -n ${PATCH_BRANCH} ]]; then
- return
- fi
-
- pushd "${BASEDIR}" > /dev/null
-
- yetus_debug "Determine branch"
-
- # something has already set this, so move on
- if [[ -n ${PATCH_BRANCH} ]]; then
- return
- fi
-
- # developer mode, existing checkout, whatever
- if [[ "${DIRTY_WORKSPACE}" == true ]];then
- PATCH_BRANCH=$(${GIT} rev-parse --abbrev-ref HEAD)
- echo "dirty workspace mode; applying against existing branch"
- return
- fi
-
- for bugs in ${BUGSYSTEMS}; do
- if declare -f ${bugs}_determine_branch >/dev/null;then
- "${bugs}_determine_branch"
- retval=$?
- if [[ ${retval} == 0 ]]; then
- break
- fi
- fi
- done
-
- if [[ ${retval} != 0 ]]; then
- PATCH_BRANCH="${PATCH_BRANCH_DEFAULT}"
- fi
- popd >/dev/null
-}
-
-## @description Try to guess the issue being tested using a variety of heuristics
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success, with ISSUE updated appropriately
-## @return 1 on failure, with ISSUE updated to "Unknown"
-function determine_issue
-{
- declare bugsys
-
- yetus_debug "Determine issue"
-
- for bugsys in ${BUGSYSTEMS}; do
- if declare -f ${bugsys}_determine_issue >/dev/null; then
- "${bugsys}_determine_issue" "${PATCH_OR_ISSUE}"
- if [[ $? == 0 ]]; then
- yetus_debug "${bugsys} says ${ISSUE}"
- return 0
- fi
- fi
- done
- return 1
-}
-
-## @description Use some heuristics to determine which long running
-## @description tests to run
-## @audience private
-## @stability stable
-## @replaceable no
-function determine_needed_tests
-{
- local i
- local plugin
-
- for i in ${CHANGED_FILES}; do
- yetus_debug "Determining needed tests for ${i}"
- personality_file_tests "${i}"
-
- for plugin in ${TESTTYPES}; do
- if declare -f ${plugin}_filefilter >/dev/null 2>&1; then
- "${plugin}_filefilter" "${i}"
- fi
- done
- done
-
- add_footer_table "Optional Tests" "${NEEDED_TESTS}"
-}
-
-## @description Given ${PATCH_DIR}/patch, apply the patch
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return exit on failure
-function apply_patch_file
-{
- big_console_header "Applying patch to ${PATCH_BRANCH}"
-
- patchfile_apply_driver "${PATCH_DIR}/patch"
- if [[ $? != 0 ]] ; then
- echo "PATCH APPLICATION FAILED"
- ((RESULT = RESULT + 1))
- add_vote_table -1 patch "The patch command could not apply the patch."
- bugsystem_finalreport 1
- cleanup_and_exit 1
- fi
- return 0
-}
-
-## @description copy the test-patch binary bits to a new working dir,
-## @description setting USER_PLUGIN_DIR and PERSONALITY to the new
-## @description locations.
-## @description this is used for test-patch in docker and reexec mode
-## @audience private
-## @stability evolving
-## @replaceable no
-function copytpbits
-{
- local dockerdir
- local dockfile
- local person
- # we need to copy/consolidate all the bits that might have changed
- # that are considered part of test-patch. This *might* break
- # things that do off-path includes, but there isn't much we can
- # do about that, I don't think.
-
- # if we've already copied, then don't bother doing it again
- if [[ ${STARTINGDIR} == ${PATCH_DIR}/precommit ]]; then
- yetus_debug "Skipping copytpbits; already copied once"
- return
- fi
-
- pushd "${STARTINGDIR}" >/dev/null
- mkdir -p "${PATCH_DIR}/precommit/user-plugins"
- mkdir -p "${PATCH_DIR}/precommit/personality"
- mkdir -p "${PATCH_DIR}/precommit/test-patch-docker"
-
- # copy our entire universe, preserving links, etc.
- yetus_debug "copying '${BINDIR}' over to '${PATCH_DIR}/precommit'"
- (cd "${BINDIR}"; tar cpf - . ) | (cd "${PATCH_DIR}/precommit"; tar xpf - )
-
- if [[ -n "${USER_PLUGIN_DIR}"
- && -d "${USER_PLUGIN_DIR}" ]]; then
- yetus_debug "copying '${USER_PLUGIN_DIR}' over to ${PATCH_DIR}/precommit/user-plugins"
- cp -pr "${USER_PLUGIN_DIR}/*" \
- "${PATCH_DIR}/precommit/user-plugins"
- fi
- # Set to be relative to ${PATCH_DIR}/precommit
- USER_PLUGIN_DIR="${PATCH_DIR}/precommit/user-plugins"
-
- if [[ -n ${PERSONALITY}
- && -f ${PERSONALITY} ]]; then
- yetus_debug "copying '${PERSONALITY}' over to '${PATCH_DIR}/precommit/personality/provided.sh'"
- cp -pr "${PERSONALITY}" "${PATCH_DIR}/precommit/personality/provided.sh"
- fi
-
- if [[ -n ${DOCKERFILE}
- && -f ${DOCKERFILE} ]]; then
- yetus_debug "copying '${DOCKERFILE}' over to '${PATCH_DIR}/precommit/test-patch-docker/Dockerfile'"
- dockerdir=$(dirname "${DOCKERFILE}")
- dockfile=$(basename "${DOCKERFILE}")
- pushd "${dockerdir}" >/dev/null
- gitfilerev=$("${GIT}" log -n 1 --pretty=format:%h -- "${dockfile}" 2>/dev/null)
- popd >/dev/null
- if [[ -z ${gitfilerev} ]]; then
- gitfilerev=$(date "+%F")
- gitfilerev="date${gitfilerev}"
- fi
- (
- echo "### TEST_PATCH_PRIVATE: dockerfile=${DOCKERFILE}"
- echo "### TEST_PATCH_PRIVATE: gitrev=${gitfilerev}"
- cat "${DOCKERFILE}"
- # make sure we put some space between, just in case last
- # line isn't an empty line or whatever
- printf "\n\n"
- cat "${BINDIR}/test-patch-docker/Dockerfile-endstub"
-
- printf "\n\n"
- ) > "${PATCH_DIR}/precommit/test-patch-docker/Dockerfile"
- DOCKERFILE="${PATCH_DIR}/precommit/test-patch-docker/Dockerfile"
- fi
-
- popd >/dev/null
-}
-
-## @description If this patches actually patches test-patch.sh, then
-## @description run with the patched version for the test.
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return none; otherwise relaunches
-function check_reexec
-{
- local commentfile=${PATCH_DIR}/tp.${RANDOM}
- local tpdir
- local copy=false
- local testdir
- local person
- local debugflag
-
- if [[ ${REEXECED} == true ]]; then
- big_console_header "Re-exec mode detected. Continuing."
- return
- fi
-
- for testdir in "${BINDIR}" \
- "${PERSONALITY}" \
- "${USER_PLUGIN_DIR}" \
- "${DOCKERFILE}"; do
- tpdir=$(relative_dir "${testdir}")
- if [[ $? == 0
- && ${CHANGED_FILES} =~ ${tpdir} ]]; then
- copy=true
- fi
- done
-
- if [[ ${copy} == true ]]; then
- big_console_header "precommit patch detected"
-
- if [[ ${RESETREPO} == false ]]; then
- ((RESULT = RESULT + 1))
- yetus_debug "can't destructively change the working directory. run with '--resetrepo' please. :("
- add_vote_table -1 precommit "Couldn't test precommit changes because we aren't configured to destructively change the working directory."
- else
-
- apply_patch_file
-
- if [[ ${JENKINS} == true ]]; then
- rm "${commentfile}" 2>/dev/null
- echo "(!) A patch to the testing environment has been detected. " > "${commentfile}"
- echo "Re-executing against the patched versions to perform further tests. " >> "${commentfile}"
- echo "The console is at ${BUILD_URL}console in case of problems." >> "${commentfile}"
- write_comment "${commentfile}"
- rm "${commentfile}"
- fi
- fi
- fi
-
- if [[ ${DOCKERSUPPORT} == false
- && ${copy} == false ]]; then
- return
- fi
-
- if [[ ${DOCKERSUPPORT} == true
- && ${copy} == false ]]; then
- big_console_header "Re-execing under Docker"
- fi
-
- # copy our universe
- copytpbits
-
- if [[ ${DOCKERSUPPORT} == true ]]; then
- # if we are doing docker, then we re-exec, but underneath the
- # container
-
- if declare -f ${BUILDTOOL}_docker_support >/dev/null; then
- "${BUILDTOOL}_docker_support"
- fi
-
- client=$(docker version | grep 'Client version' | cut -f2 -d: | tr -d ' ')
- server=$(docker version | grep 'Server version' | cut -f2 -d: | tr -d ' ')
-
- dockerversion="Client=${client} Server=${server}"
-
- TESTPATCHMODE="${USER_PARAMS[*]}"
- if [[ -n "${BUILD_URL}" ]]; then
- TESTPATCHMODE="--build-url=${BUILD_URL} ${TESTPATCHMODE}"
- fi
- TESTPATCHMODE="--tpglobaltimer=${GLOBALTIMER} ${TESTPATCHMODE}"
- TESTPATCHMODE="--tpreexectimer=${TIMER} ${TESTPATCHMODE}"
- TESTPATCHMODE="--tpinstance=${INSTANCE} ${TESTPATCHMODE}"
- TESTPATCHMODE="--tpperson=${PERSONALITY} ${TESTPATCHMODE}"
- TESTPATCHMODE="--plugins=${ENABLED_PLUGINS// /,} ${TESTPATCHMODE}"
- TESTPATCHMODE=" ${TESTPATCHMODE}"
- export TESTPATCHMODE
-
- patchdir=$(relative_dir "${PATCH_DIR}")
-
- if [[ ${TP_SHELL_SCRIPT_DEBUG} = true ]]; then
- debugflag="--debug"
- fi
-
- cd "${BASEDIR}"
- #shellcheck disable=SC2093
- exec bash "${PATCH_DIR}/precommit/test-patch-docker/test-patch-docker.sh" \
- ${debugflag} \
- --dockerversion="${dockerversion}" \
- --java-home="${JAVA_HOME}" \
- --patch-dir="${patchdir}" \
- --project="${PROJECT_NAME}"
-
- else
-
- # if we aren't doing docker, then just call ourselves
- # but from the new path with the new flags
- #shellcheck disable=SC2093
- cd "${PATCH_DIR}/precommit/"
- exec "${PATCH_DIR}/precommit/test-patch.sh" \
- "${USER_PARAMS[@]}" \
- --reexec \
- --basedir="${BASEDIR}" \
- --branch="${PATCH_BRANCH}" \
- --patch-dir="${PATCH_DIR}" \
- --tpglobaltimer="${GLOBALTIMER}" \
- --tpreexectimer="${TIMER}" \
- --personality="${PERSONALITY}" \
- --tpinstance="${INSTANCE}" \
- --user-plugins="${USER_PLUGIN_DIR}"
- fi
-}
-
-## @description Reset the test results
-## @audience public
-## @stability evolving
-## @replaceable no
-function modules_reset
-{
- MODULE_STATUS=()
- MODULE_STATUS_TIMER=()
- MODULE_STATUS_MSG=()
- MODULE_STATUS_LOG=()
- MODULE_COMPILE_LOG=()
-}
-
-## @description Utility to print standard module errors
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param repostatus
-## @param testtype
-## @param mvncmdline
-function modules_messages
-{
- local repostatus=$1
- local testtype=$2
- local summarymode=$3
- shift 2
- local modindex=0
- local repo
- local goodtime=0
- local failure=false
- local oldtimer
- local statusjdk
- local multijdkmode=false
-
- if [[ ${repostatus} == branch ]]; then
- repo=${PATCH_BRANCH}
- else
- repo="the patch"
- fi
-
- verify_multijdk_test "${testtype}"
- if [[ $? == 1 ]]; then
- multijdkmode=true
- fi
-
- oldtimer=${TIMER}
-
- if [[ ${summarymode} == true
- && ${ALLOWSUMMARIES} == true ]]; then
-
- until [[ ${modindex} -eq ${#MODULE[@]} ]]; do
-
- if [[ ${multijdkmode} == true ]]; then
- statusjdk=${MODULE_STATUS_JDK[${modindex}]}
- fi
-
- if [[ "${MODULE_STATUS[${modindex}]}" == '+1' ]]; then
- ((goodtime=goodtime + ${MODULE_STATUS_TIMER[${modindex}]}))
- else
- failure=true
- start_clock
- echo ""
- echo "${MODULE_STATUS_MSG[${modindex}]}"
- echo ""
- offset_clock "${MODULE_STATUS_TIMER[${modindex}]}"
- add_vote_table "${MODULE_STATUS[${modindex}]}" "${testtype}" "${MODULE_STATUS_MSG[${modindex}]}"
- if [[ ${MODULE_STATUS[${modindex}]} == -1
- && -n "${MODULE_STATUS_LOG[${modindex}]}" ]]; then
- add_footer_table "${testtype}" "@@BASE@@/${MODULE_STATUS_LOG[${modindex}]}"
- fi
- fi
- ((modindex=modindex+1))
- done
-
- if [[ ${failure} == false ]]; then
- start_clock
- offset_clock "${goodtime}"
- add_vote_table +1 "${testtype}" "${repo} passed${statusjdk}"
- fi
- else
- until [[ ${modindex} -eq ${#MODULE[@]} ]]; do
- start_clock
- echo ""
- echo "${MODULE_STATUS_MSG[${modindex}]}"
- echo ""
- offset_clock "${MODULE_STATUS_TIMER[${modindex}]}"
- add_vote_table "${MODULE_STATUS[${modindex}]}" "${testtype}" "${MODULE_STATUS_MSG[${modindex}]}"
- if [[ ${MODULE_STATUS[${modindex}]} == -1
- && -n "${MODULE_STATUS_LOG[${modindex}]}" ]]; then
- add_footer_table "${testtype}" "@@BASE@@/${MODULE_STATUS_LOG[${modindex}]}"
- fi
- ((modindex=modindex+1))
- done
- fi
- TIMER=${oldtimer}
-}
-
-## @description Add a test result
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param module
-## @param runtime
-function module_status
-{
- local index=$1
- local value=$2
- local log=$3
- shift 3
-
- local jdk
-
- jdk=$(report_jvm_version "${JAVA_HOME}")
-
- if [[ -n ${index}
- && ${index} =~ ^[0-9]+$ ]]; then
- MODULE_STATUS[${index}]="${value}"
- MODULE_STATUS_LOG[${index}]="${log}"
- MODULE_STATUS_JDK[${index}]=" with JDK v${jdk}"
- MODULE_STATUS_MSG[${index}]="${*}"
- else
- yetus_error "ASSERT: module_status given bad index: ${index}"
- yetus_error "ASSERT: module_stats $*"
- generate_stack
- exit 1
- fi
-}
-
-## @description run the tests for the queued modules
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param repostatus
-## @param testtype
-## @param mvncmdline
-function modules_workers
-{
- local repostatus=$1
- local testtype=$2
- shift 2
- local modindex=0
- local fn
- local savestart=${TIMER}
- local savestop
- local repo
- local modulesuffix
- local jdk=""
- local jdkindex=0
- local statusjdk
- local result=0
-
- if [[ ${repostatus} == branch ]]; then
- repo=${PATCH_BRANCH}
- else
- repo="the patch"
- fi
-
- modules_reset
-
- verify_multijdk_test "${testtype}"
- if [[ $? == 1 ]]; then
- jdk=$(report_jvm_version "${JAVA_HOME}")
- statusjdk=" with JDK v${jdk}"
- jdk="-jdk${jdk}"
- jdk=${jdk// /}
- yetus_debug "Starting MultiJDK mode${statusjdk} on ${testtype}"
- fi
-
- until [[ ${modindex} -eq ${#MODULE[@]} ]]; do
- start_clock
-
- fn=$(module_file_fragment "${MODULE[${modindex}]}")
- fn="${fn}${jdk}"
- modulesuffix=$(basename "${MODULE[${modindex}]}")
- if [[ ${BUILDTOOLCWD} == true ]]; then
- pushd "${BASEDIR}/${MODULE[${modindex}]}" >/dev/null
- fi
-
- if [[ ${modulesuffix} == . ]]; then
- modulesuffix="root"
- fi
-
- if [[ $? != 0 ]]; then
- echo "${BASEDIR}/${MODULE[${modindex}]} no longer exists. Skipping."
- ((modindex=modindex+1))
- continue
- fi
-
- # shellcheck disable=2086,2046
- echo_and_redirect "${PATCH_DIR}/${repostatus}-${testtype}-${fn}.txt" \
- $("${BUILDTOOL}_executor") \
- ${MODULEEXTRAPARAM[${modindex}]//@@@MODULEFN@@@/${fn}} \
- "${@//@@@MODULEFN@@@/${fn}}"
-
- if [[ $? == 0 ]] ; then
- module_status \
- ${modindex} \
- +1 \
- "${repostatus}-${testtype}-${fn}.txt" \
- "${modulesuffix} in ${repo} passed${statusjdk}."
- else
- module_status \
- ${modindex} \
- -1 \
- "${repostatus}-${testtype}-${fn}.txt" \
- "${modulesuffix} in ${repo} failed${statusjdk}."
- ((result = result + 1))
- fi
-
- # compile is special
- if [[ ${testtype} = compile ]]; then
- MODULE_COMPILE_LOG[${modindex}]="${PATCH_DIR}/${repostatus}-${testtype}-${fn}.txt"
- yetus_debug "Comile log set to ${MODULE_COMPILE_LOG[${modindex}]}"
- fi
-
- savestop=$(stop_clock)
- MODULE_STATUS_TIMER[${modindex}]=${savestop}
- # shellcheck disable=SC2086
- echo "Elapsed: $(clock_display ${savestop})"
- if [[ ${BUILDTOOLCWD} == true ]]; then
- popd >/dev/null
- fi
- ((modindex=modindex+1))
- done
-
- TIMER=${savestart}
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Reset the queue for tests
-## @audience public
-## @stability evolving
-## @replaceable no
-function clear_personality_queue
-{
- yetus_debug "Personality: clear queue"
- MODCOUNT=0
- MODULE=()
-}
-
-## @description Build the queue for tests
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param module
-## @param profiles/flags/etc
-function personality_enqueue_module
-{
- yetus_debug "Personality: enqueue $*"
- local module=$1
- shift
-
- MODULE[${MODCOUNT}]=${module}
- MODULEEXTRAPARAM[${MODCOUNT}]=${*}
- ((MODCOUNT=MODCOUNT+1))
-}
-
-## @description Utility to push many tests into the failure list
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param testdesc
-## @param testlist
-function populate_test_table
-{
- local reason=$1
- shift
- local first=""
- local i
-
- for i in "$@"; do
- if [[ -z "${first}" ]]; then
- add_test_table "${reason}" "${i}"
- first="${reason}"
- else
- add_test_table " " "${i}"
- fi
- done
-}
-
-## @description Run and verify the output of the appropriate unit tests
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function check_unittests
-{
- local i
- local testsys
- local test_logfile
- local result=0
- local -r savejavahome=${JAVA_HOME}
- local multijdkmode=false
- local jdk=""
- local jdkindex=0
- local statusjdk
- local formatresult=0
- local needlog
- local unitlogs
-
- verify_needed_test unit
-
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "Running unit tests"
-
- verify_multijdk_test unit
- if [[ $? == 1 ]]; then
- multijdkmode=true
- fi
-
- for jdkindex in ${JDK_DIR_LIST}; do
- if [[ ${multijdkmode} == true ]]; then
- JAVA_HOME=${jdkindex}
- jdk=$(report_jvm_version "${JAVA_HOME}")
- statusjdk="JDK v${jdk} "
- jdk="-jdk${jdk}"
- jdk=${jdk// /}
- fi
-
- personality_modules patch unit
- "${BUILDTOOL}_modules_worker" patch unit
-
- ((result=result+$?))
-
- modules_messages patch unit false
- if [[ ${result} == 0 ]]; then
- continue
- fi
-
- i=0
- until [[ $i -eq ${#MODULE[@]} ]]; do
- module=${MODULE[${i}]}
- fn=$(module_file_fragment "${module}")
- fn="${fn}${jdk}"
- test_logfile="${PATCH_DIR}/patch-unit-${fn}.txt"
-
- if [[ ${BUILDTOOLCWD} == true ]]; then
- pushd "${MODULE[${i}]}" >/dev/null
- fi
-
- needlog=0
- for testsys in ${TESTFORMATS}; do
- if declare -f ${testsys}_process_tests >/dev/null; then
- yetus_debug "Calling ${testsys}_process_tests"
- "${testsys}_process_tests" "${module}" "${test_logfile}" "${fn}"
- formatresult=$?
- ((result=result+formatresult))
- if [[ "${formatresult}" != 0 ]]; then
- needlog=1
- fi
- fi
- done
-
- if [[ ${needlog} == 1 ]]; then
- unitlogs="${unitlogs} @@BASE@@/patch-unit-${fn}.txt"
- fi
-
- if [[ ${BUILDTOOLCWD} == true ]]; then
- popd >/dev/null
- fi
-
- ((i=i+1))
- done
-
- done
- JAVA_HOME=${savejavahome}
-
- if [[ -n "${unitlogs}" ]]; then
- add_footer_table "unit test logs" "${unitlogs}"
- fi
-
- if [[ ${JENKINS} == true ]]; then
- add_footer_table "${statusjdk} Test Results" "${BUILD_URL}testReport/"
- fi
-
- for testsys in ${TESTFORMATS}; do
- if declare -f ${testsys}_finalize_results >/dev/null; then
- yetus_debug "Calling ${testsys}_finalize_results"
- "${testsys}_finalize_results" "${statusjdk}"
- fi
- done
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Write comments onto bug systems that have code review support.
-## @description File should be in the form of "file:line:comment"
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param filename
-function bugsystem_linecomments
-{
- declare title=$1
- declare fn=$2
- declare line
- declare bugs
- declare realline
- declare text
- declare idxline
- declare uniline
-
- if [[ ! -f "${GITUNIDIFFLINES}" ]]; then
- return
- fi
-
- while read -r line;do
- file=$(echo "${line}" | cut -f1 -d:)
- realline=$(echo "${line}" | cut -f2 -d:)
- text=$(echo "${line}" | cut -f3- -d:)
- idxline="${file}:${realline}:"
- uniline=$(${GREP} "${idxline}" "${GITUNIDIFFLINES}" | cut -f3 -d: )
-
- for bugs in ${BUGLINECOMMENTS}; do
- if declare -f ${bugs}_linecomments >/dev/null;then
- "${bugs}_linecomments" "${title}" "${file}" "${realline}" "${uniline}" "${text}"
- fi
- done
- done < "${fn}"
-}
-
-## @description Write the final output to the selected bug system
-## @audience private
-## @stability evolving
-## @replaceable no
-function bugsystem_finalreport
-{
- declare bugs
-
- add_footer_table "Powered by" "Apache Yetus http://yetus.apache.org"
-
- for bugs in ${BUGCOMMENTS}; do
- if declare -f ${bugs}_finalreport >/dev/null;then
- "${bugs}_finalreport" "${@}"
- fi
- done
-}
-
-## @description Clean the filesystem as appropriate and then exit
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param runresult
-function cleanup_and_exit
-{
- local result=$1
-
- if [[ ${JENKINS} == "true" && ${RELOCATE_PATCH_DIR} == "true" && \
- -e ${PATCH_DIR} && -d ${PATCH_DIR} ]] ; then
- # if PATCH_DIR is already inside BASEDIR, then
- # there is no need to move it since we assume that
- # Jenkins or whatever already knows where it is at
- # since it told us to put it there!
- relative_dir "${PATCH_DIR}" >/dev/null
- if [[ $? == 1 ]]; then
- yetus_debug "mv ${PATCH_DIR} ${BASEDIR}"
- mv "${PATCH_DIR}" "${BASEDIR}"
- fi
- fi
- big_console_header "Finished build."
-
- # shellcheck disable=SC2086
- exit ${result}
-}
-
-## @description Driver to execute _tests routines
-## @audience private
-## @stability evolving
-## @replaceable no
-function runtests
-{
- local plugin
-
- ### Run tests for Jenkins or if explictly asked for by a developer
- if [[ ${JENKINS} == "true" || ${RUN_TESTS} == "true" ]] ; then
-
- verify_patchdir_still_exists
- check_unittests
-
- (( RESULT = RESULT + $? ))
- fi
-
- for plugin in ${TESTTYPES}; do
- verify_patchdir_still_exists
- if declare -f ${plugin}_tests >/dev/null 2>&1; then
- modules_reset
- yetus_debug "Running ${plugin}_tests"
- #shellcheck disable=SC2086
- ${plugin}_tests
- (( RESULT = RESULT + $? ))
- fi
- done
-}
-
-## @description Calculate the differences between the specified files
-## @description and output it to stdout.
-## @audience public
-## @stability evolving
-## @replaceable no
-function calcdiffs
-{
- local orig=$1
- local new=$2
- local tmp=${PATCH_DIR}/pl.$$.${RANDOM}
- local count=0
- local j
-
- # first, pull out just the errors
- # shellcheck disable=SC2016
- ${AWK} -F: '{print $NF}' "${orig}" > "${tmp}.branch"
-
- # shellcheck disable=SC2016
- ${AWK} -F: '{print $NF}' "${new}" > "${tmp}.patch"
-
- # compare the errors, generating a string of line
- # numbers. Sorry portability: GNU diff makes this too easy
- ${DIFF} --unchanged-line-format="" \
- --old-line-format="" \
- --new-line-format="%dn " \
- "${tmp}.branch" \
- "${tmp}.patch" > "${tmp}.lined"
-
- # now, pull out those lines of the raw output
- # shellcheck disable=SC2013
- for j in $(cat "${tmp}.lined"); do
- # shellcheck disable=SC2086
- head -${j} "${new}" | tail -1
- done
-
- rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
-}
-
-
-## @description Helper routine for plugins to ask projects, etc
-## @description to count problems in a log file
-## @description and output it to stdout.
-## @audience public
-## @stability evolving
-## @replaceable no
-## @return number of issues
-function generic_count_probs
-{
- declare testtype=$1
- declare input=$2
-
- if declare -f ${PROJECT_NAME}_${testtype}_count_probs >/dev/null; then
- "${PROJECT_NAME}_${testtype}_count_probs" "${input}"
- elif declare -f ${BUILDTOOL}_${testtype}_count_probs >/dev/null; then
- "${BUILDTOOL}_${testtype}_count_probs" "${input}"
- elif declare -f ${testtype}_count_probs >/dev/null; then
- "${testtype}_count_probs" "${input}"
- else
- yetus_error "ERROR: ${testtype}: No function defined to count problems."
- echo 0
- fi
-}
-
-## @description Helper routine for plugins to do a pre-patch prun
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param testype
-## @param multijdk
-## @return 1 on failure
-## @return 0 on success
-function generic_pre_handler
-{
- declare testtype=$1
- declare multijdkmode=$2
- declare result=0
- declare -r savejavahome=${JAVA_HOME}
- declare multijdkmode=false
- declare jdkindex=0
-
- verify_needed_test "${testtype}"
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "Pre-patch ${testtype} verification on ${PATCH_BRANCH}"
-
- verify_multijdk_test "${testtype}"
- if [[ $? == 1 ]]; then
- multijdkmode=true
- fi
-
- for jdkindex in ${JDK_DIR_LIST}; do
- if [[ ${multijdkmode} == true ]]; then
- JAVA_HOME=${jdkindex}
- fi
-
- personality_modules branch "${testtype}"
- "${BUILDTOOL}_modules_worker" branch "${testtype}"
-
- ((result=result + $?))
- modules_messages branch "${testtype}" true
-
- done
- JAVA_HOME=${savejavahome}
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Generic post-patch log handler
-## @audience public
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-## @param origlog
-## @param testtype
-## @param multijdkmode
-function generic_postlog_compare
-{
- declare origlog=$1
- declare testtype=$2
- declare multijdk=$3
- declare result=0
- declare i
- declare fn
- declare jdk
- declare statusjdk
-
- if [[ ${multijdk} == true ]]; then
- jdk=$(report_jvm_version "${JAVA_HOME}")
- statusjdk=" with JDK v${jdk}"
- jdk="-jdk${jdk}"
- jdk=${jdk// /}
- fi
-
- i=0
- until [[ ${i} -eq ${#MODULE[@]} ]]; do
- if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
- ((result=result+1))
- ((i=i+1))
- continue
- fi
-
- fn=$(module_file_fragment "${MODULE[${i}]}")
- fn="${fn}${jdk}"
- module_suffix=$(basename "${MODULE[${i}]}")
- if [[ ${module_suffix} == \. ]]; then
- module_suffix=root
- fi
-
- yetus_debug "${testtype}: branch-${origlog}-${fn}.txt vs. patch-${origlog}-${fn}.txt"
-
- # if it was a new module, this won't exist.
- if [[ -f "${PATCH_DIR}/branch-${origlog}-${fn}.txt" ]]; then
- ${GREP} -i warning "${PATCH_DIR}/branch-${origlog}-${fn}.txt" \
- > "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt"
- else
- touch "${PATCH_DIR}/branch-${origlog}-${fn}.txt" \
- "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt"
- fi
-
- if [[ -f "${PATCH_DIR}/patch-${origlog}-${fn}.txt" ]]; then
- ${GREP} -i warning "${PATCH_DIR}/patch-${origlog}-${fn}.txt" \
- > "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt"
- else
- touch "${PATCH_DIR}/patch-${origlog}-${fn}.txt" \
- "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt"
- fi
-
- numbranch=$("generic_count_probs" "${testtype}" "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt")
- numpatch=$("generic_count_probs" "${testtype}" "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt")
-
- yetus_debug "${testtype}: old: ${numbranch} vs new: ${numpatch}"
-
- if [[ -n ${numbranch}
- && -n ${numpatch}
- && ${numpatch} -gt ${numbranch} ]]; then
-
- ${DIFF} -u "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt" \
- "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt" \
- > "${PATCH_DIR}/${testtype}-${fn}-diff.txt"
-
- add_vote_table -1 "${testtype}" "${fn}${statusjdk} has problems."
- add_footer_table "${testtype}" "${fn}: @@BASE@@/${testtype}-${fn}-diff.txt"
-
- ((result=result+1))
- fi
- ((i=i+1))
- done
- modules_messages patch "${testtype}" true
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Generic post-patch handler
-## @audience public
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-## @param origlog
-## @param testtype
-## @param multijdkmode
-## @param run commands
-function generic_post_handler
-{
- declare origlog=$1
- declare testtype=$2
- declare multijdkmode=$3
- declare need2run=$4
- declare i
- declare result=0
- declare fn
- declare -r savejavahome=${JAVA_HOME}
- declare jdk=""
- declare jdkindex=0
- declare statusjdk
- declare -i numbranch=0
- declare -i numpatch=0
-
- verify_needed_test "${testtype}"
- if [[ $? == 0 ]]; then
- yetus_debug "${testtype} not needed"
- return 0
- fi
-
- big_console_header "Patch ${testtype} verification"
-
- for jdkindex in ${JDK_DIR_LIST}; do
- if [[ ${multijdkmode} == true ]]; then
- JAVA_HOME=${jdkindex}
- yetus_debug "Using ${JAVA_HOME} to run this set of tests"
- fi
-
- if [[ ${need2run} = true ]]; then
- personality_modules "${codebase}" "${testtype}"
- "${BUILDTOOL}_modules_worker" "${codebase}" "${testtype}"
-
- if [[ ${UNSUPPORTED_TEST} = true ]]; then
- return 0
- fi
- fi
-
- generic_postlog_compare "${origlog}" "${testtype}" "${multijdkmode}"
- ((result=result+$?))
- done
- JAVA_HOME=${savejavahome}
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Execute the compile phase. This will callout
-## @description to _compile
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param branch|patch
-## @return 0 on success
-## @return 1 on failure
-function compile
-{
- declare codebase=$1
- declare result=0
- declare -r savejavahome=${JAVA_HOME}
- declare multijdkmode=false
- declare jdkindex=0
-
- verify_needed_test compile
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- if [[ ${codebase} = "branch" ]]; then
- big_console_header "Pre-patch ${PATCH_BRANCH} compilation"
- else
- big_console_header "Patch compilation"
- fi
-
- verify_multijdk_test compile
- if [[ $? == 1 ]]; then
- multijdkmode=true
- fi
-
- for jdkindex in ${JDK_DIR_LIST}; do
- if [[ ${multijdkmode} == true ]]; then
- JAVA_HOME=${jdkindex}
- fi
-
- personality_modules "${codebase}" compile
- "${BUILDTOOL}_modules_worker" "${codebase}" compile
- modules_messages "${codebase}" compile true
-
- for plugin in ${TESTTYPES}; do
- verify_patchdir_still_exists
- if declare -f ${plugin}_compile >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_compile ${codebase} ${multijdkmode}"
- "${plugin}_compile" "${codebase}" "${multijdkmode}"
- ((result = result + $?))
- fi
- done
-
- done
- JAVA_HOME=${savejavahome}
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Execute the static analysis test cycle.
-## @description This will callout to _precompile, compile, _postcompile and _rebuild
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param branch|patch
-## @return 0 on success
-## @return 1 on failure
-function compile_cycle
-{
- declare codebase=$1
- declare result=0
- declare plugin
-
- find_changed_modules
-
- for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_precompile >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_precompile"
- #shellcheck disable=SC2086
- ${plugin}_precompile ${codebase}
- if [[ $? -gt 0 ]]; then
- ((result = result+1))
- fi
- fi
- done
-
- compile "${codebase}"
-
- for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_postcompile >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_postcompile"
- #shellcheck disable=SC2086
- ${plugin}_postcompile ${codebase}
- if [[ $? -gt 0 ]]; then
- ((result = result+1))
- fi
- fi
- done
-
- for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_rebuild >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_rebuild"
- #shellcheck disable=SC2086
- ${plugin}_rebuild ${codebase}
- if [[ $? -gt 0 ]]; then
- ((result = result+1))
- fi
- fi
- done
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Execute the patch file test phase. Calls out to
-## @description to _patchfile
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param branch|patch
-## @return 0 on success
-## @return 1 on failure
-function patchfiletests
-{
- declare plugin
- declare result=0
-
- for plugin in ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_patchfile >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_patchfile"
- #shellcheck disable=SC2086
- ${plugin}_patchfile "${PATCH_DIR}/patch"
- if [[ $? -gt 0 ]]; then
- ((result = result+1))
- fi
- fi
- done
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-
-## @description Wipe the repo clean to not invalidate tests
-## @audience public
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function distclean
-{
- declare result=0
- declare plugin
-
- personality_modules branch distclean
-
- for plugin in ${TESTTYPES} ${TESTFORMATS}; do
- if declare -f ${plugin}_clean >/dev/null 2>&1; then
- yetus_debug "Running ${plugin}_distclean"
- #shellcheck disable=SC2086
- ${plugin}_clean
- if [[ $? -gt 0 ]]; then
- ((result = result+1))
- fi
- fi
- done
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-## @description Setup to execute
-## @audience public
-## @stability evolving
-## @replaceable no
-## @param $@
-## @return 0 on success
-## @return 1 on failure
-function initialize
-{
- setup_defaults
-
- parse_args "$@"
-
- importplugins
-
- parse_args_plugins "$@"
-
- BUGCOMMENTS=${BUGCOMMENTS:-${BUGSYSTEMS}}
- if [[ ! ${BUGCOMMENTS} =~ console ]]; then
- BUGCOMMENTS="${BUGCOMMENTS} console"
- fi
-
- BUGLINECOMMENTS=${BUGLINECOMMENTS:-${BUGCOMMENTS}}
-
- plugins_initialize
-
- finish_docker_stats
-
- locate_patch
-
- # from here on out, we'll be in ${BASEDIR} for cwd
- # plugins need to pushd/popd if they change.
- git_checkout
-
- patchfile_dryrun_driver "${PATCH_DIR}/patch"
- if [[ $? != 0 ]]; then
- yetus_error "ERROR: ${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}."
- cleanup_and_exit 1
- fi
-
- determine_issue
- if [[ "${ISSUE}" == 'Unknown' ]]; then
- echo "Testing patch on ${PATCH_BRANCH}."
- else
- echo "Testing ${ISSUE} patch on ${PATCH_BRANCH}."
- fi
-
- find_changed_files
-
- check_reexec
-
- determine_needed_tests
-
- prepopulate_footer
-}
-
-## @description perform prechecks
-## @audience private
-## @stability evolving
-## @return exits on failure
-function prechecks
-{
- declare plugin
- declare result=0
-
- for plugin in ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
- verify_patchdir_still_exists
-
- if declare -f ${plugin}_precheck >/dev/null 2>&1; then
-
- yetus_debug "Running ${plugin}_precheck"
- #shellcheck disable=SC2086
- ${plugin}_precheck
-
- (( result = result + $? ))
- if [[ ${result} != 0 ]] ; then
- bugsystem_finalreport 1
- cleanup_and_exit 1
- fi
- fi
- done
-}
-
-## @description import core library routines
-## @audience private
-## @stability evolving
-function import_core
-{
- declare filename
-
- for filename in "${BINDIR}/core.d"/*; do
- # shellcheck disable=SC1091
- # shellcheck source=core.d/00-yetuslib.sh
- # shellcheck source=core.d/01-common.sh
- . "${filename}"
- done
-}
-
-###############################################################################
-###############################################################################
-###############################################################################
-
-import_core
-
-initialize "$@"
-
-prechecks
-
-patchfiletests
-((RESULT=RESULT+$?))
-
-compile_cycle branch
-((RESULT=RESULT+$?))
-
-distclean
-
-apply_patch_file
-
-compute_gitdiff
-
-compile_cycle patch
-((RESULT=RESULT+$?))
-
-runtests
-((RESULT=RESULT+$?))
-
-finish_vote_table
-
-finish_footer_table
-
-bugsystem_finalreport ${RESULT}
-cleanup_and_exit ${RESULT}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/core.d/00-yetuslib.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/00-yetuslib.sh b/precommit/core.d/00-yetuslib.sh
new file mode 100644
index 0000000..6ab6682
--- /dev/null
+++ b/precommit/core.d/00-yetuslib.sh
@@ -0,0 +1,95 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+## @description Print a message to stderr
+## @audience public
+## @stability stable
+## @replaceable no
+## @param string
+function yetus_error
+{
+ echo "$*" 1>&2
+}
+
+## @description Print a message to stderr if --debug is turned on
+## @audience public
+## @stability stable
+## @replaceable no
+## @param string
+function yetus_debug
+{
+ if [[ "${YETUS_SHELL_SCRIPT_DEBUG}" = true ]]; then
+ echo "[$(date) DEBUG]: $*" 1>&2
+ fi
+}
+
+## @description Given variable $1 delete $2 from it
+## @audience public
+## @stability stable
+## @replaceable no
+function yetus_delete_entry
+{
+ if [[ ${!1} =~ \ ${2}\ ]] ; then
+ yetus_debug "Removing ${2} from ${1}"
+ eval "${1}"=\""${!1// ${2} }"\"
+ fi
+}
+
+## @description Given variable $1 add $2 to it
+## @audience public
+## @stability stable
+## @replaceable no
+function yetus_add_entry
+{
+ if [[ ! ${!1} =~ \ ${2}\ ]] ; then
+ yetus_debug "Adding ${2} to ${1}"
+ #shellcheck disable=SC2140
+ eval "${1}"=\""${!1} ${2} "\"
+ fi
+}
+
+## @description Given variable $1 determine if $2 is in it
+## @audience public
+## @stability stable
+## @replaceable no
+## @returns 1 = yes, 0 = no
+function yetus_verify_entry
+{
+ [[ ! ${!1} =~ \ ${2}\ ]]
+}
+
+## @description run the command, sending stdout and stderr to the given filename
+## @audience public
+## @stability stable
+## @param filename
+## @param command
+## @param [..]
+## @replaceable no
+## @returns $?
+function yetus_run_and_redirect
+{
+ declare logfile=$1
+ shift
+
+ # to the log
+ {
+ date
+ echo "cd $(pwd)"
+ echo "${*}"
+ } >> "${logfile}"
+ # run the actual command
+ "${@}" >> "${logfile}" 2>&1
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/core.d/01-common.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/01-common.sh b/precommit/core.d/01-common.sh
new file mode 100755
index 0000000..2110f75
--- /dev/null
+++ b/precommit/core.d/01-common.sh
@@ -0,0 +1,469 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+## @description Setup the default global variables
+## @audience public
+## @stability stable
+## @replaceable no
+function common_defaults
+{
+ #shellcheck disable=SC2034
+ BASEDIR=$(pwd)
+ BUGSYSTEMS=""
+ BUILDTOOLS=""
+ LOAD_SYSTEM_PLUGINS=true
+ #shellcheck disable=SC2034
+ JENKINS=false
+ #shellcheck disable=SC2034
+ OFFLINE=false
+ OSTYPE=$(uname -s)
+ #shellcheck disable=SC2034
+ PATCH_BRANCH=""
+ PATCH_BRANCH_DEFAULT="master"
+ #shellcheck disable=SC2034
+ PATCH_DRYRUNMODE=false
+ PATCH_DIR=/tmp
+ while [[ -e ${PATCH_DIR} ]]; do
+ PATCH_DIR=/tmp/yetus-${RANDOM}.${RANDOM}
+ done
+ #shellcheck disable=SC2034
+ PATCH_METHOD=""
+ #shellcheck disable=SC2034
+ PATCH_METHODS=("gitapply" "patchcmd")
+ #shellcheck disable=SC2034
+ PATCH_LEVEL=0
+ PROJECT_NAME=yetus
+ RESULT=0
+ #shellcheck disable=SC2034
+ TESTTYPES=""
+ TESTFORMATS=""
+ USER_PLUGIN_DIR=""
+
+ #shellcheck disable=SC2034
+ YETUS_SHELL_SCRIPT_DEBUG=false
+
+ # Solaris needs POSIX and GNU, not SVID
+ case ${OSTYPE} in
+ SunOS)
+ AWK=${AWK:-/usr/xpg4/bin/awk}
+ CURL=${CURL:-curl}
+ DIFF=${DIFF:-/usr/gnu/bin/diff}
+ FILE=${FILE:-file}
+ GIT=${GIT:-git}
+ GREP=${GREP:-/usr/xpg4/bin/grep}
+ PATCH=${PATCH:-/usr/gnu/bin/patch}
+ SED=${SED:-/usr/xpg4/bin/sed}
+ ;;
+ *)
+ AWK=${AWK:-awk}
+ CURL=${CURL:-curl}
+ DIFF=${DIFF:-diff}
+ FILE=${FILE:-file}
+ GIT=${GIT:-git}
+ GREP=${GREP:-grep}
+ PATCH=${PATCH:-patch}
+ SED=${SED:-sed}
+ ;;
+ esac
+}
+
+## @description Interpret the common command line parameters used by test-patch,
+## @description smart-apply-patch, and the bug system plugins
+## @audience private
+## @stability stable
+## @replaceable no
+## @params $@
+## @return May exit on failure
+function common_args
+{
+ declare i
+
+ for i in "$@"; do
+ case ${i} in
+ --awk-cmd=*)
+ AWK=${i#*=}
+ ;;
+ --basedir=*)
+ #shellcheck disable=SC2034
+ BASEDIR=${i#*=}
+ ;;
+ --branch=*)
+ #shellcheck disable=SC2034
+ PATCH_BRANCH=${i#*=}
+ ;;
+ --branch-default=*)
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=${i#*=}
+ ;;
+ --curl-cmd=*)
+ CURL=${i#*=}
+ ;;
+ --debug)
+ #shellcheck disable=SC2034
+ YETUS_SHELL_SCRIPT_DEBUG=true
+ ;;
+ --diff-cmd=*)
+ DIFF=${i#*=}
+ ;;
+ --file-cmd=*)
+ FILE=${i#*=}
+ ;;
+ --git-cmd=*)
+ GIT=${i#*=}
+ ;;
+ --grep-cmd=*)
+ GREP=${i#*=}
+ ;;
+ --help|-help|-h|help|--h|--\?|-\?|\?)
+ yetus_usage
+ exit 0
+ ;;
+ --list-plugins)
+ list_plugins
+ exit 0
+ ;;
+ --offline)
+ #shellcheck disable=SC2034
+ OFFLINE=true
+ ;;
+ --patch-cmd=*)
+ PATCH=${i#*=}
+ ;;
+ --patch-dir=*)
+ PATCH_DIR=${i#*=}
+ ;;
+ --plugins=*)
+ ENABLED_PLUGINS=${i#*=}
+ ENABLED_PLUGINS=${ENABLED_PLUGINS//,/ }
+ ;;
+ --project=*)
+ PROJECT_NAME=${i#*=}
+ ;;
+ --skip-system-plugins)
+ LOAD_SYSTEM_PLUGINS=false
+ ;;
+ --sed-cmd=*)
+ SED=${i#*=}
+ ;;
+ --user-plugins=*)
+ USER_PLUGIN_DIR=${i#*=}
+ ;;
+ *)
+ ;;
+ esac
+ done
+}
+
+## @description List all installed plug-ins, regardless of whether
+## @description they have been enabled
+## @audience public
+## @stability evolving
+## @replaceable no
+function list_plugins
+{
+ declare plugintype
+ declare name
+
+ ENABLED_PLUGINS="all"
+ importplugins
+
+ printf "Reminder: every plug-in may be enabled via 'all'.\n\n"
+ for plugintype in BUILDTOOLS TESTTYPES BUGSYSTEMS TESTFORMATS; do
+ printf "%s:\n\t" ${plugintype}
+ for name in ${!plugintype}; do
+ printf "%s " ${name}
+ done
+ echo ""
+ done
+}
+
+## @description Let plugins also get a copy of the arguments
+## @audience private
+## @stability evolving
+## @replaceable no
+function parse_args_plugins
+{
+ declare plugin
+
+ for plugin in ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
+ if declare -f ${plugin}_parse_args >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_parse_args"
+ #shellcheck disable=SC2086
+ ${plugin}_parse_args "$@"
+ (( RESULT = RESULT + $? ))
+ fi
+ done
+}
+
+## @description Let plugins also get a copy of the arguments
+## @audience private
+## @stability evolving
+## @replaceable no
+function plugins_initialize
+{
+ declare plugin
+
+ for plugin in ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS} ${BUILDTOOLS}; do
+ if declare -f ${plugin}_initialize >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_initialize"
+ #shellcheck disable=SC2086
+ ${plugin}_initialize
+ (( RESULT = RESULT + $? ))
+ fi
+ done
+}
+
+## @description Determine if a plugin was enabeld by the user
+## @description ENABLED_PLUGINS must be defined
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param test
+function verify_plugin_enabled
+{
+ declare toadd=$1
+ declare bar
+ declare idx
+ declare strip
+ declare stridx
+
+ yetus_debug "Testing if $1 has been enabled by user"
+
+ bar=""
+ for idx in ${ENABLED_PLUGINS}; do
+ stridx=${idx// }
+ yetus_debug "verify_plugin_enabled: processing ${stridx}"
+ case ${stridx} in
+ all)
+ bar=${toadd}
+ ;;
+ -*)
+ strip=${stridx#-}
+ if [[ ${strip} = "${toadd}" ]]; then
+ bar=""
+ fi
+ ;;
+ +*|*)
+ strip=${stridx#+}
+ if [[ ${strip} = "${toadd}" ]]; then
+ bar=${toadd}
+ fi
+ ;;
+ esac
+ done
+
+ if [[ -n ${bar} ]]; then
+ yetus_debug "Post-parsing: checking ${bar} = ${toadd}"
+ fi
+ [[ ${bar} = "${toadd}" ]]
+}
+
+## @description Personality-defined plug-in list
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param plug-in list string
+function personality_plugins
+{
+ if [[ -z "${ENABLED_PLUGINS}" ]]; then
+ ENABLED_PLUGINS="$1"
+ ENABLED_PLUGINS=${ENABLED_PLUGINS//,/ }
+ yetus_debug "Using personality plug-in list: ${ENABLED_PLUGINS}"
+ fi
+}
+
+## @description Add the given test type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param test
+function add_test
+{
+ if verify_plugin_enabled "${1}"; then
+ yetus_add_entry NEEDED_TESTS "${1}"
+ fi
+}
+
+## @description Remove the given test type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param test
+function delete_test
+{
+ yetus_delete_entry NEEDED_TESTS "${1}"
+}
+
+## @description Verify if a given test was requested
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param test
+## @return 1 = yes
+## @return 0 = no
+function verify_needed_test
+{
+ yetus_verify_entry NEEDED_TESTS "${1}"
+}
+
+## @description Add the given test type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param plugin
+function add_test_type
+{
+ if verify_plugin_enabled "${1}"; then
+ yetus_add_entry TESTTYPES "${1}"
+ fi
+}
+
+## @description Remove the given test type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param plugin
+function delete_test_type
+{
+ yetus_delete_entry TESTTYPES "${1}"
+}
+
+## @description Add the given bugsystem type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param bugsystem
+function add_bugsystem
+{
+ if verify_plugin_enabled "${1}"; then
+ yetus_add_entry BUGSYSTEMS "${1}"
+ fi
+}
+
+## @description Remove the given bugsystem type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param bugsystem
+function delete_bugsystem
+{
+ yetus_delete_entry BUGSYSTEMS "${1}"
+}
+
+## @description Add the given test format type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param test format
+function add_test_format
+{
+ if verify_plugin_enabled "${1}"; then
+ yetus_add_entry TESTFORMATS "${1}"
+ fi
+}
+
+## @description Remove the given test format type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param test format
+function delete_test_format
+{
+ yetus_delete_entry TESTFORMATS "${1}"
+}
+
+## @description Add the given build tool type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param build tool
+function add_build_tool
+{
+ if verify_plugin_enabled "${1}"; then
+ yetus_add_entry BUILDTOOLS "${1}"
+ fi
+}
+
+## @description Remove the given build tool type
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param build tool
+function delete_build_tool
+{
+ yetus_delete_entry BUILDTOOLS "${1}"
+}
+
+## @description Import content from test-patch.d and optionally
+## @description from user provided plugin directory
+## @audience private
+## @stability evolving
+## @replaceable no
+## @description Import content from test-patch.d and optionally
+## @description from user provided plugin directory
+## @audience private
+## @stability evolving
+## @replaceable no
+function importplugins
+{
+ local i
+ local plugin
+ local files=()
+
+ if [[ ${LOAD_SYSTEM_PLUGINS} == "true" ]]; then
+ if [[ -d "${BINDIR}/test-patch.d" ]]; then
+ files=(${BINDIR}/test-patch.d/*.sh)
+ fi
+ fi
+
+ if [[ -n "${USER_PLUGIN_DIR}" && -d "${USER_PLUGIN_DIR}" ]]; then
+ yetus_debug "Loading user provided plugins from ${USER_PLUGIN_DIR}"
+ files=("${files[@]}" ${USER_PLUGIN_DIR}/*.sh)
+ fi
+
+ if [[ -z ${PERSONALITY}
+ && -f "${BINDIR}/personality/${PROJECT_NAME}.sh"
+ && ${LOAD_SYSTEM_PLUGINS} = "true" ]]; then
+ PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
+ fi
+
+ if [[ -n ${PERSONALITY} ]]; then
+ if [[ ! -f ${PERSONALITY} ]]; then
+ if [[ -f "${BINDIR}/personality/${PROJECT_NAME}.sh"
+ && ${LOAD_SYSTEM_PLUGINS} = "true" ]]; then
+ PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
+ else
+ yetus_debug "Can't find ${PERSONALITY} to import."
+ return
+ fi
+ fi
+ yetus_debug "Importing ${PERSONALITY}"
+ # shellcheck disable=SC1090
+ . "${PERSONALITY}"
+ fi
+
+ for i in "${files[@]}"; do
+ if [[ -f ${i} ]]; then
+ yetus_debug "Importing ${i}"
+ #shellcheck disable=SC1090
+ . "${i}"
+ fi
+ done
+
+ if declare -f personality_globals > /dev/null; then
+ personality_globals
+ fi
+}
[09/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/releasedocmaker.py
----------------------------------------------------------------------
diff --git a/dev-support/releasedocmaker.py b/dev-support/releasedocmaker.py
deleted file mode 100755
index ae3ce45..0000000
--- a/dev-support/releasedocmaker.py
+++ /dev/null
@@ -1,642 +0,0 @@
-#!/usr/bin/env python
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from glob import glob
-from optparse import OptionParser
-from time import gmtime, strftime
-from distutils.version import LooseVersion
-import os
-import re
-import sys
-import urllib
-import urllib2
-try:
- import json
-except ImportError:
- import simplejson as json
-
-RELEASE_VERSION = {}
-NAME_PATTERN = re.compile(r' \([0-9]+\)')
-RELNOTE_PATTERN = re.compile('^\<\!\-\- ([a-z]+) \-\-\>')
-
-ASF_LICENSE = '''
-<!---
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
--->
-'''
-
-def clean(_str):
- return tableclean(re.sub(NAME_PATTERN, "", _str))
-
-def format_components(_str):
- _str = re.sub(NAME_PATTERN, '', _str).replace("'", "")
- if _str != "":
- ret = _str
- else:
- # some markdown parsers don't like empty tables
- ret = "."
- return clean(ret)
-
-# convert to utf-8
-# protect some known md metachars
-# or chars that screw up doxia
-def tableclean(_str):
- _str = _str.encode('utf-8')
- _str = _str.replace("_", r"\_")
- _str = _str.replace("\r", "")
- _str = _str.rstrip()
- return _str
-
-# same thing as tableclean,
-# except table metachars are also
-# escaped as well as more
-# things we don't want doxia to
-# screw up
-def notableclean(_str):
- _str = tableclean(_str)
- _str = _str.replace("|", r"\|")
- _str = _str.replace("<", r"\<")
- _str = _str.replace(">", r"\>")
- _str = _str.replace("*", r"\*")
- _str = _str.rstrip()
- return _str
-
-# if release notes have a special marker,
-# we'll treat them as already in markdown format
-def processrelnote(_str):
- fmt = RELNOTE_PATTERN.match(_str)
- if fmt is None:
- return notableclean(_str)
- else:
- return {
- 'markdown' : tableclean(_str),
- }.get(fmt.group(1),notableclean(_str))
-
-# clean output dir
-def clean_output_dir(directory):
- files = os.listdir(directory)
- for name in files:
- os.remove(os.path.join(directory, name))
- os.rmdir(directory)
-
-def mstr(obj):
- if obj is None:
- return ""
- return unicode(obj)
-
-def buildindex(title, asf_license):
- """Write an index file for later conversion using mvn site"""
- versions = glob("[0-9]*.[0-9]*.[0-9]*")
- versions.sort(key=LooseVersion, reverse=True)
- with open("index.md", "w") as indexfile:
- if asf_license is True:
- indexfile.write(ASF_LICENSE)
- for version in versions:
- indexfile.write("* %s v%s\n" % (title, version))
- for k in ("Changes", "Release Notes"):
- indexfile.write(" * [%s](%s/%s.%s.html)\n" \
- % (k, version, k.upper().replace(" ", ""), version))
-
-def buildreadme(title, asf_license):
- """Write an index file for Github using README.md"""
- versions = glob("[0-9]*.[0-9]*.[0-9]*")
- versions.sort(key=LooseVersion, reverse=True)
- with open("README.md", "w") as indexfile:
- if asf_license is True:
- indexfile.write(ASF_LICENSE)
- for version in versions:
- indexfile.write("* %s v%s\n" % (title, version))
- for k in ("Changes", "Release Notes"):
- indexfile.write(" * [%s](%s/%s.%s.md)\n" \
- % (k, version, k.upper().replace(" ", ""), version))
-
-class GetVersions(object):
- """ List of version strings """
- def __init__(self, versions, projects):
- versions = versions
- projects = projects
- self.newversions = []
- versions.sort(key=LooseVersion)
- print "Looking for %s through %s"%(versions[0], versions[-1])
- for project in projects:
- url = "https://issues.apache.org/jira/rest/api/2/project/%s/versions" % project
- resp = urllib2.urlopen(url)
- datum = json.loads(resp.read())
- for data in datum:
- name = data['name']
- if name[0].isdigit and versions[0] <= name and name <= versions[-1]:
- print "Adding %s to the list" % name
- self.newversions.append(name)
- newlist = list(set(self.newversions))
- self.newversions = newlist
-
- def getlist(self):
- return self.newversions
-
-class Version(object):
- """Represents a version number"""
- def __init__(self, data):
- self.mod = False
- self.data = data
- found = re.match(r'^((\d+)(\.\d+)*).*$', data)
- if found:
- self.parts = [int(p) for p in found.group(1).split('.')]
- else:
- self.parts = []
- # backfill version with zeroes if missing parts
- self.parts.extend((0,) * (3 - len(self.parts)))
-
- def __str__(self):
- if self.mod:
- return '.'.join([str(p) for p in self.parts])
- return self.data
-
- def __cmp__(self, other):
- return cmp(self.parts, other.parts)
-
-class Jira(object):
- """A single JIRA"""
-
- def __init__(self, data, parent):
- self.key = data['key']
- self.fields = data['fields']
- self.parent = parent
- self.notes = None
- self.incompat = None
- self.reviewed = None
- self.important = None
-
- def get_id(self):
- return mstr(self.key)
-
- def get_description(self):
- return mstr(self.fields['description'])
-
- def get_release_note(self):
- if self.notes is None:
- field = self.parent.field_id_map['Release Note']
- if self.fields.has_key(field):
- self.notes = mstr(self.fields[field])
- elif self.get_incompatible_change() or self.get_important():
- self.notes = self.get_description()
- else:
- self.notes = ""
- return self.notes
-
- def get_priority(self):
- ret = ""
- pri = self.fields['priority']
- if pri is not None:
- ret = pri['name']
- return mstr(ret)
-
- def get_assignee(self):
- ret = ""
- mid = self.fields['assignee']
- if mid is not None:
- ret = mid['displayName']
- return mstr(ret)
-
- def get_components(self):
- if len(self.fields['components']) > 0:
- return ", ".join([comp['name'] for comp in self.fields['components']])
- else:
- return ""
-
- def get_summary(self):
- return self.fields['summary']
-
- def get_type(self):
- ret = ""
- mid = self.fields['issuetype']
- if mid is not None:
- ret = mid['name']
- return mstr(ret)
-
- def get_reporter(self):
- ret = ""
- mid = self.fields['reporter']
- if mid is not None:
- ret = mid['displayName']
- return mstr(ret)
-
- def get_project(self):
- ret = ""
- mid = self.fields['project']
- if mid is not None:
- ret = mid['key']
- return mstr(ret)
-
- def __cmp__(self, other):
- selfsplit = self.get_id().split('-')
- othersplit = other.get_id().split('-')
- result = cmp(selfsplit[0], othersplit[0])
- if result != 0:
- return result
- else:
- if selfsplit[1] < othersplit[1]:
- return True
- elif selfsplit[1] > othersplit[1]:
- return False
- return False
-
- def get_incompatible_change(self):
- if self.incompat is None:
- field = self.parent.field_id_map['Hadoop Flags']
- self.reviewed = False
- self.incompat = False
- if self.fields.has_key(field):
- if self.fields[field]:
- for flag in self.fields[field]:
- if flag['value'] == "Incompatible change":
- self.incompat = True
- if flag['value'] == "Reviewed":
- self.reviewed = True
- return self.incompat
-
- def get_important(self):
- if self.important is None:
- field = self.parent.field_id_map['Flags']
- self.important = False
- if self.fields.has_key(field):
- if self.fields[field]:
- for flag in self.fields[field]:
- if flag['value'] == "Important":
- self.important = True
- return self.important
-
- def check_missing_component(self):
- if len(self.fields['components']) > 0:
- return False
- return True
-
- def check_missing_assignee(self):
- if self.fields['assignee'] is not None:
- return False
- return True
-
- def check_version_string(self):
- field = self.parent.field_id_map['Fix Version/s']
- for ver in self.fields[field]:
- found = re.match(r'^((\d+)(\.\d+)*).*$|^(\w+\-\d+)$', ver['name'])
- if not found:
- return True
- return False
-
- def get_release_date(self, version):
- fix_versions = self.fields['fixVersions']
- for j in range(len(fix_versions)):
- if fix_versions[j] == version:
- return fix_versions[j]['releaseDate']
- return None
-
-class JiraIter(object):
- """An Iterator of JIRAs"""
-
- def __init__(self, version, projects):
- self.version = version
- self.projects = projects
- ver = str(version).replace("-SNAPSHOT", "")
-
- resp = urllib2.urlopen("https://issues.apache.org/jira/rest/api/2/field")
- data = json.loads(resp.read())
-
- self.field_id_map = {}
- for part in data:
- self.field_id_map[part['name']] = part['id']
-
- self.jiras = []
- pos = 0
- end = 1
- count = 100
- while pos < end:
- pjs = "','".join(projects)
- jql = "project in ('%s') and fixVersion in ('%s') and resolution = Fixed" % (pjs, ver)
- params = urllib.urlencode({'jql': jql, 'startAt':pos, 'maxResults':count})
- resp = urllib2.urlopen("https://issues.apache.org/jira/rest/api/2/search?%s" % params)
- data = json.loads(resp.read())
- if data.has_key('error_messages'):
- raise Exception(data['error_messages'])
- pos = data['startAt'] + data['maxResults']
- end = data['total']
- self.jiras.extend(data['issues'])
-
- needaversion = False
- if ver not in RELEASE_VERSION:
- needaversion = True
-
- if needaversion is True:
- issues = data['issues']
- for i in range(len(issues)):
- fix_versions = issues[i]['fields']['fixVersions']
- for j in range(len(fix_versions)):
- fields = fix_versions[j]
- if 'releaseDate' in fields:
- RELEASE_VERSION[fields['name']] = fields['releaseDate']
-
- self.iter = self.jiras.__iter__()
-
- def __iter__(self):
- return self
-
- def next(self):
- data = self.iter.next()
- j = Jira(data, self)
- return j
-
-class Outputs(object):
- """Several different files to output to at the same time"""
-
- def __init__(self, base_file_name, file_name_pattern, keys, params=None):
- if params is None:
- params = {}
- self.params = params
- self.base = open(base_file_name%params, 'w')
- self.others = {}
- for key in keys:
- both = dict(params)
- both['key'] = key
- self.others[key] = open(file_name_pattern%both, 'w')
-
- def write_all(self, pattern):
- both = dict(self.params)
- both['key'] = ''
- self.base.write(pattern%both)
- for key in self.others.keys():
- both = dict(self.params)
- both['key'] = key
- self.others[key].write(pattern%both)
-
- def write_key_raw(self, key, _str):
- self.base.write(_str)
- if self.others.has_key(key):
- self.others[key].write(_str)
-
- def close(self):
- self.base.close()
- for value in self.others.values():
- value.close()
-
- def write_list(self, mylist):
- for jira in sorted(mylist):
- line = '| [%s](https://issues.apache.org/jira/browse/%s) | %s | %s | %s | %s | %s |\n'
- line = line % (notableclean(jira.get_id()),
- notableclean(jira.get_id()),
- notableclean(jira.get_summary()),
- notableclean(jira.get_priority()),
- format_components(jira.get_components()),
- notableclean(jira.get_reporter()),
- notableclean(jira.get_assignee()))
- self.write_key_raw(jira.get_project(), line)
-
-def main():
- usage = "usage: %prog --project PROJECT [--project PROJECT] --version VERSION [--version VERSION2 ...]"
- parser = OptionParser(usage=usage,
- epilog="Markdown-formatted CHANGES and RELEASENOTES files will be stored"
- "in a directory named after the highest version provided.")
- parser.add_option("-i", "--index", dest="index", action="store_true",
- default=False, help="build an index file")
- parser.add_option("-l", "--license", dest="license", action="store_false",
- default=True, help="Add an ASF license")
- parser.add_option("-n", "--lint", dest="lint", action="store_true",
- help="use lint flag to exit on failures")
- parser.add_option("-p", "--project", dest="projects",
- action="append", type="string",
- help="projects in JIRA to include in releasenotes", metavar="PROJECT")
- parser.add_option("-r", "--range", dest="range", action="store_true",
- default=False, help="Given versions are a range")
- parser.add_option("-t", "--projecttitle", dest="title", type="string",
- help="Title to use for the project (default is Apache PROJECT)")
- parser.add_option("-u", "--usetoday", dest="usetoday", action="store_true",
- default=False, help="use current date for unreleased versions")
- parser.add_option("-v", "--version", dest="versions", action="append", type="string",
- help="versions in JIRA to include in releasenotes", metavar="VERSION")
- (options, _) = parser.parse_args()
-
- if options.versions is None:
- parser.error("At least one version needs to be supplied")
-
- proxy = urllib2.ProxyHandler()
- opener = urllib2.build_opener(proxy)
- urllib2.install_opener(opener)
-
- projects = options.projects
- if projects is None:
- parser.error("At least one project needs to be supplied")
-
- if options.range is True:
- versions = [Version(v) for v in GetVersions(options.versions, projects).getlist()]
- else:
- versions = [Version(v) for v in options.versions]
- versions.sort()
-
- if options.title is None:
- title = projects[0]
- else:
- title = options.title
-
- haderrors = False
-
- for version in versions:
- vstr = str(version)
- jlist = JiraIter(vstr, projects)
-
- if vstr in RELEASE_VERSION:
- reldate = RELEASE_VERSION[vstr]
- elif options.usetoday:
- reldate = strftime("%Y-%m-%d", gmtime())
- else:
- reldate = "Unreleased (as of %s)" % strftime("%Y-%m-%d", gmtime())
-
- if not os.path.exists(vstr):
- os.mkdir(vstr)
-
- reloutputs = Outputs("%(ver)s/RELEASENOTES.%(ver)s.md",
- "%(ver)s/RELEASENOTES.%(key)s.%(ver)s.md",
- [], {"ver":version, "date":reldate, "title":title})
- choutputs = Outputs("%(ver)s/CHANGES.%(ver)s.md",
- "%(ver)s/CHANGES.%(key)s.%(ver)s.md",
- [], {"ver":version, "date":reldate, "title":title})
-
- if options.license is True:
- reloutputs.write_all(ASF_LICENSE)
- choutputs.write_all(ASF_LICENSE)
-
- relhead = '# %(title)s %(key)s %(ver)s Release Notes\n\n' \
- 'These release notes cover new developer and user-facing ' \
- 'incompatibilities, important issues, features, and major improvements.\n\n'
- chhead = '# %(title)s Changelog\n\n' \
- '## Release %(ver)s - %(date)s\n'\
- '\n'
-
- reloutputs.write_all(relhead)
- choutputs.write_all(chhead)
- error_count = 0
- warning_count = 0
- lint_message = ""
- incompatlist = []
- importantlist = []
- buglist = []
- improvementlist = []
- newfeaturelist = []
- subtasklist = []
- tasklist = []
- testlist = []
- otherlist = []
-
- for jira in sorted(jlist):
- if jira.get_incompatible_change():
- incompatlist.append(jira)
- elif jira.get_important():
- importantlist.append(jira)
- elif jira.get_type() == "Bug":
- buglist.append(jira)
- elif jira.get_type() == "Improvement":
- improvementlist.append(jira)
- elif jira.get_type() == "New Feature":
- newfeaturelist.append(jira)
- elif jira.get_type() == "Sub-task":
- subtasklist.append(jira)
- elif jira.get_type() == "Task":
- tasklist.append(jira)
- elif jira.get_type() == "Test":
- testlist.append(jira)
- else:
- otherlist.append(jira)
-
- line = '* [%s](https://issues.apache.org/jira/browse/%s) | *%s* | **%s**\n' \
- % (notableclean(jira.get_id()), notableclean(jira.get_id()),
- notableclean(jira.get_priority()), notableclean(jira.get_summary()))
-
- if jira.get_incompatible_change() and len(jira.get_release_note()) == 0:
- warning_count += 1
- reloutputs.write_key_raw(jira.get_project(), "\n---\n\n")
- reloutputs.write_key_raw(jira.get_project(), line)
- line = '\n**WARNING: No release note provided for this incompatible change.**\n\n'
- lint_message += "\nWARNING: incompatible change %s lacks release notes." % \
- (notableclean(jira.get_id()))
- reloutputs.write_key_raw(jira.get_project(), line)
-
- if jira.get_important() and len(jira.get_release_note()) == 0:
- warning_count += 1
- reloutputs.write_key_raw(jira.get_project(), "\n---\n\n")
- reloutputs.write_key_raw(jira.get_project(), line)
- line = '\n**WARNING: No release note provided for this important issue.**\n\n'
- lint_message += "\nWARNING: important issue %s lacks release notes." % \
- (notableclean(jira.get_id()))
- reloutputs.write_key_raw(jira.get_project(), line)
-
- if jira.check_version_string():
- warning_count += 1
- lint_message += "\nWARNING: Version string problem for %s " % jira.get_id()
-
- if jira.check_missing_component() or jira.check_missing_assignee():
- error_count += 1
- error_message = []
- if jira.check_missing_component():
- error_message.append("component")
- if jira.check_missing_assignee():
- error_message.append("assignee")
- lint_message += "\nERROR: missing %s for %s " \
- % (" and ".join(error_message), jira.get_id())
-
- if len(jira.get_release_note()) > 0:
- reloutputs.write_key_raw(jira.get_project(), "\n---\n\n")
- reloutputs.write_key_raw(jira.get_project(), line)
- line = '\n%s\n\n' % (processrelnote(jira.get_release_note()))
- reloutputs.write_key_raw(jira.get_project(), line)
-
- if options.lint is True:
- print lint_message
- print "======================================="
- print "%s: Error:%d, Warning:%d \n" % (vstr, error_count, warning_count)
- if error_count > 0:
- haderrors = True
- clean_output_dir(vstr)
- continue
-
- reloutputs.write_all("\n\n")
- reloutputs.close()
-
- choutputs.write_all("### INCOMPATIBLE CHANGES:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(incompatlist)
-
- choutputs.write_all("\n\n### IMPORTANT ISSUES:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(importantlist)
-
- choutputs.write_all("\n\n### NEW FEATURES:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(newfeaturelist)
-
- choutputs.write_all("\n\n### IMPROVEMENTS:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(improvementlist)
-
- choutputs.write_all("\n\n### BUG FIXES:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(buglist)
-
- choutputs.write_all("\n\n### TESTS:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(testlist)
-
- choutputs.write_all("\n\n### SUB-TASKS:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(subtasklist)
-
- choutputs.write_all("\n\n### OTHER:\n\n")
- choutputs.write_all("| JIRA | Summary | Priority | Component | Reporter | Contributor |\n")
- choutputs.write_all("|:---- |:---- | :--- |:---- |:---- |:---- |\n")
- choutputs.write_list(otherlist)
- choutputs.write_list(tasklist)
-
- choutputs.write_all("\n\n")
- choutputs.close()
-
- if options.index:
- buildindex(title, options.license)
- buildreadme(title, options.license)
-
- if haderrors is True:
- sys.exit(1)
-
-if __name__ == "__main__":
- main()
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/shelldocs.py
----------------------------------------------------------------------
diff --git a/dev-support/shelldocs.py b/dev-support/shelldocs.py
deleted file mode 100755
index 7a1fe21..0000000
--- a/dev-support/shelldocs.py
+++ /dev/null
@@ -1,274 +0,0 @@
-#!/usr/bin/python
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import re
-import sys
-import string
-from optparse import OptionParser
-
-asflicense='''
-<!---
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
--->
-'''
-
-def docstrip(key,string):
- string=re.sub("^## @%s " % key ,"",string)
- string=string.lstrip()
- string=string.rstrip()
- return string
-
-def toc(list):
- tocout=[]
- header=()
- for i in list:
- if header != i.getinter():
- header=i.getinter()
- line=" * %s\n" % (i.headerbuild())
- tocout.append(line)
- line=" * [%s](#%s)\n" % (i.getname().replace("_","\_"),i.getname())
- tocout.append(line)
- return tocout
-
-class ShellFunction:
- def __init__(self):
- self.reset()
-
- def __cmp__(self,other):
- if (self.audience == other.audience):
- if (self.stability == other.stability):
- if (self.replaceb == other.replaceb):
- return(cmp(self.name,other.name))
- else:
- if (self.replaceb == "Yes"):
- return -1
- else:
- return 1
- else:
- if (self.stability == "Stable"):
- return -1
- else:
- return 1
- else:
- if (self.audience == "Public"):
- return -1
- else:
- return 1
-
- def reset(self):
- self.name=None
- self.audience=None
- self.stability=None
- self.replaceb=None
- self.returnt=None
- self.desc=None
- self.params=None
-
- def setname(self,text):
- definition=text.split();
- self.name=definition[1]
-
- def getname(self):
- if (self.name is None):
- return "None"
- else:
- return self.name
-
- def setaudience(self,text):
- self.audience=docstrip("audience",text)
- self.audience=self.audience.capitalize()
-
- def getaudience(self):
- if (self.audience is None):
- return "None"
- else:
- return self.audience
-
- def setstability(self,text):
- self.stability=docstrip("stability",text)
- self.stability=self.stability.capitalize()
-
- def getstability(self):
- if (self.stability is None):
- return "None"
- else:
- return self.stability
-
- def setreplace(self,text):
- self.replaceb=docstrip("replaceable",text)
- self.replaceb=self.replaceb.capitalize()
-
- def getreplace(self):
- if (self.replaceb is None):
- return "None"
- else:
- return self.replaceb
-
- def getinter(self):
- return( (self.getaudience(), self.getstability(), self.getreplace()))
-
- def addreturn(self,text):
- if (self.returnt is None):
- self.returnt = []
- self.returnt.append(docstrip("return",text))
-
- def getreturn(self):
- if (self.returnt is None):
- return "Nothing"
- else:
- return "\n\n".join(self.returnt)
-
- def adddesc(self,text):
- if (self.desc is None):
- self.desc = []
- self.desc.append(docstrip("description",text))
-
- def getdesc(self):
- if (self.desc is None):
- return "None"
- else:
- return " ".join(self.desc)
-
- def addparam(self,text):
- if (self.params is None):
- self.params = []
- self.params.append(docstrip("param",text))
-
- def getparams(self):
- if (self.params is None):
- return ""
- else:
- return " ".join(self.params)
-
- def getusage(self):
- line="%s %s" % (self.name, self.getparams())
- return line
-
- def headerbuild(self):
- if self.getreplace() == "Yes":
- replacetext="Replaceable"
- else:
- replacetext="Not Replaceable"
- line="%s/%s/%s" % (self.getaudience(), self.getstability(), replacetext)
- return(line)
-
- def getdocpage(self):
- line="### `%s`\n\n"\
- "* Synopsis\n\n"\
- "```\n%s\n"\
- "```\n\n" \
- "* Description\n\n" \
- "%s\n\n" \
- "* Returns\n\n" \
- "%s\n\n" \
- "| Classification | Level |\n" \
- "| :--- | :--- |\n" \
- "| Audience | %s |\n" \
- "| Stability | %s |\n" \
- "| Replaceable | %s |\n\n" \
- % (self.getname(),
- self.getusage(),
- self.getdesc(),
- self.getreturn(),
- self.getaudience(),
- self.getstability(),
- self.getreplace())
- return line
-
- def __str__(self):
- line="{%s %s %s %s}" \
- % (self.getname(),
- self.getaudience(),
- self.getstability(),
- self.getreplace())
- return line
-
-def main():
- parser=OptionParser(usage="usage: %prog --skipprnorep --output OUTFILE --input INFILE [--input INFILE ...]")
- parser.add_option("-o","--output", dest="outfile",
- action="store", type="string",
- help="file to create", metavar="OUTFILE")
- parser.add_option("-i","--input", dest="infile",
- action="append", type="string",
- help="file to read", metavar="INFILE")
- parser.add_option("--skipprnorep", dest="skipprnorep",
- action="store_true", help="Skip Private & Not Replaceable")
-
- (options, args)=parser.parse_args()
-
- allfuncs=[]
- for filename in options.infile:
- with open(filename,"r") as shellcode:
- funcdef=ShellFunction()
- for line in shellcode:
- if line.startswith('## @description'):
- funcdef.adddesc(line)
- elif line.startswith('## @audience'):
- funcdef.setaudience(line)
- elif line.startswith('## @stability'):
- funcdef.setstability(line)
- elif line.startswith('## @replaceable'):
- funcdef.setreplace(line)
- elif line.startswith('## @param'):
- funcdef.addparam(line)
- elif line.startswith('## @return'):
- funcdef.addreturn(line)
- elif line.startswith('function'):
- funcdef.setname(line)
- if options.skipprnorep and \
- funcdef.getaudience() == "Private" and \
- funcdef.getreplace() == "No":
- pass
- else:
- allfuncs.append(funcdef)
- funcdef=ShellFunction()
-
- allfuncs=sorted(allfuncs)
-
- outfile=open(options.outfile, "w")
- outfile.write(asflicense)
- for line in toc(allfuncs):
- outfile.write(line)
-
- outfile.write("\n------\n\n")
-
- header=[]
- for funcs in allfuncs:
- if header != funcs.getinter():
- header=funcs.getinter()
- line="## %s\n" % (funcs.headerbuild())
- outfile.write(line)
- outfile.write(funcs.getdocpage())
- outfile.close()
-
-if __name__ == "__main__":
- main()
-
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/smart-apply-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/smart-apply-patch.sh b/dev-support/smart-apply-patch.sh
deleted file mode 100755
index ee06030..0000000
--- a/dev-support/smart-apply-patch.sh
+++ /dev/null
@@ -1,251 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Make sure that bash version meets the pre-requisite
-
-if [[ -z "${BASH_VERSINFO}" ]] \
- || [[ "${BASH_VERSINFO[0]}" -lt 3 ]] \
- || [[ "${BASH_VERSINFO[0]}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then
- echo "bash v3.2+ is required. Sorry."
- exit 1
-fi
-
-this="${BASH_SOURCE-$0}"
-BINDIR=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
-#shellcheck disable=SC2034
-QATESTMODE=false
-
-# dummy functions
-function add_vote_table
-{
- true
-}
-
-function add_footer_table
-{
- true
-}
-
-function big_console_header
-{
- true
-}
-
-function add_test
-{
- true
-}
-
-## @description Clean the filesystem as appropriate and then exit
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param runresult
-function cleanup_and_exit
-{
- local result=$1
-
- if [[ ${PATCH_DIR} =~ ^/tmp/yetus
- && -d ${PATCH_DIR} ]]; then
- rm -rf "${PATCH_DIR}"
- fi
-
- # shellcheck disable=SC2086
- exit ${result}
-}
-
-## @description Setup the default global variables
-## @audience public
-## @stability stable
-## @replaceable no
-function setup_defaults
-{
- common_defaults
-}
-
-## @description Print the usage information
-## @audience public
-## @stability stable
-## @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 ""
- 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')"
-
- importplugins
-
- unset TESTFORMATS
- unset TESTTYPES
- unset BUILDTOOLS
-
- for plugin in ${BUGSYSTEMS}; do
- if declare -f ${plugin}_usage >/dev/null 2>&1; then
- echo
- "${plugin}_usage"
- fi
- done
-}
-
-## @description Interpret the command line parameters
-## @audience private
-## @stability stable
-## @replaceable no
-## @params $@
-## @return May exit on failure
-function parse_args
-{
- local i
-
- common_args "$@"
-
- for i in "$@"; do
- case ${i} in
- --committer)
- COMMITMODE=true
- ;;
- --dry-run)
- PATCH_DRYRUNMODE=true
- ;;
- --*)
- ## PATCH_OR_ISSUE can't be a --. So this is probably
- ## a plugin thing.
- continue
- ;;
- *)
- PATCH_OR_ISSUE=${i#*=}
- ;;
- esac
- done
-
- if [[ ! -d ${PATCH_DIR} ]]; then
- mkdir -p "${PATCH_DIR}"
- if [[ $? != 0 ]] ; then
- yetus_error "ERROR: Unable to create ${PATCH_DIR}"
- cleanup_and_exit 1
- fi
- fi
-}
-
-## @description git am dryrun
-## @replaceable no
-## @audience private
-## @stability evolving
-function gitam_dryrun
-{
-
- # there is no dryrun method for git-am, so just
- # use apply instead.
- gitapply_dryrun "$@"
-
- if [[ ${PATCH_METHOD} = "gitapply" ]]; then
- PATCH_METHOD="gitam"
- fi
-}
-
-## @description git am signoff
-## @replaceable no
-## @audience private
-## @stability evolving
-function gitam_apply
-{
- declare patchfile=$1
-
- echo "Applying the patch:"
- yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-am.log" \
- "${GIT}" am --signoff --whitespace=fix "-p${PATCH_LEVEL}" "${patchfile}"
- ${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-am.log"
-}
-
-## @description import core library routines
-## @audience private
-## @stability evolving
-function import_core
-{
- declare filename
-
- for filename in "${BINDIR}/core.d"/*; do
- # shellcheck disable=SC1091
- # shellcheck source=core.d/01-common.sh
- . "${filename}"
- done
-}
-
-trap "cleanup_and_exit 1" HUP INT QUIT TERM
-
-import_core
-
-setup_defaults
-
-parse_args "$@"
-
-importplugins
-yetus_debug "Removing BUILDTOOLS, TESTTYPES, and TESTFORMATS from installed plug-in list"
-unset BUILDTOOLS
-unset TESTTYPES
-unset TESTFORMATS
-
-parse_args_plugins "$@"
-
-plugins_initialize
-
-locate_patch
-
-if [[ ${COMMITMODE} = true ]]; then
- PATCH_METHODS=("gitam" "${PATCH_METHODS[@]}")
-fi
-
-patchfile_dryrun_driver "${PATCH_DIR}/patch"
-RESULT=$?
-
-if [[ ${RESULT} -gt 0 ]]; then
- yetus_error "ERROR: Aborting! ${PATCH_OR_ISSUE} cannot be verified."
- cleanup_and_exit ${RESULT}
-fi
-
-if [[ ${PATCH_DRYRUNMODE} == false ]]; then
- patchfile_apply_driver "${PATCH_DIR}/patch"
- RESULT=$?
-fi
-
-if [[ ${COMMITMODE} = true
- && ${PATCH_METHOD} != "gitam" ]]; then
- yetus_debug "Running git add -A"
- git add -A
-fi
-
-cleanup_and_exit ${RESULT}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch-docker/Dockerfile-endstub
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-docker/Dockerfile-endstub b/dev-support/test-patch-docker/Dockerfile-endstub
deleted file mode 100644
index aa0463e..0000000
--- a/dev-support/test-patch-docker/Dockerfile-endstub
+++ /dev/null
@@ -1,19 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-ADD launch-test-patch.sh /testptch/launch-test-patch.sh
-RUN chmod a+rx /testptch/launch-test-patch.sh
-CMD /testptch/launch-test-patch.sh
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch-docker/Dockerfile-startstub
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-docker/Dockerfile-startstub b/dev-support/test-patch-docker/Dockerfile-startstub
deleted file mode 100644
index d191285..0000000
--- a/dev-support/test-patch-docker/Dockerfile-startstub
+++ /dev/null
@@ -1,91 +0,0 @@
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-FROM ubuntu:trusty
-
-WORKDIR /root
-
-######
-# Install common dependencies from packages
-######
-RUN apt-get update && apt-get install --no-install-recommends -y \
- git curl ant make maven \
- cmake gcc g++ protobuf-compiler \
- build-essential libtool \
- zlib1g-dev pkg-config libssl-dev \
- snappy libsnappy-dev \
- bzip2 libbz2-dev \
- libjansson-dev \
- fuse libfuse-dev \
- libcurl4-openssl-dev \
- python python2.7 pylint \
- ruby \
- openjdk-7-jdk \
- libperl-critic-perl
-
-# Fixing the Apache commons / Maven dependency problem under Ubuntu:
-# See http://wiki.apache.org/commons/VfsProblems
-RUN cd /usr/share/maven/lib && ln -s ../../java/commons-lang.jar .
-
-#######
-# Oracle Java
-#######
-
-RUN apt-get install -y software-properties-common
-RUN add-apt-repository -y ppa:webupd8team/java
-RUN apt-get update
-
-
-# Auto-accept the Oracle JDK license
-RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
-RUN apt-get install -y oracle-java7-installer
-
-# Auto-accept the Oracle JDK license
-RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
-RUN apt-get install -y oracle-java8-installer
-
-######
-# Install findbugs
-######
-RUN mkdir -p /opt/findbugs && \
- curl -L https://sourceforge.net/projects/findbugs/files/findbugs/3.0.1/findbugs-noUpdateChecks-3.0.1.tar.gz/download \
- -o /opt/findbugs.tar.gz && \
- tar xzf /opt/findbugs.tar.gz --strip-components 1 -C /opt/findbugs
-ENV FINDBUGS_HOME /opt/findbugs
-
-####
-# Install shellcheck
-####
-RUN apt-get install -y cabal-install
-RUN cabal update && cabal install shellcheck --global
-
-####
-# Install rubocop
-###
-RUN gem install rubocop
-
-####
-# Install ruby-lint
-###
-RUN gem install ruby-lint
-
-####
-# Install bats
-####
-RUN add-apt-repository -y ppa:duggan/bats
-RUN apt-get update
-RUN apt-get install -y bats
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch-docker/launch-test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-docker/launch-test-patch.sh b/dev-support/test-patch-docker/launch-test-patch.sh
deleted file mode 100755
index ac976ad..0000000
--- a/dev-support/test-patch-docker/launch-test-patch.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-cd "${BASEDIR}"
-
-if [[ -n ${JAVA_HOME}
- && ! -d ${JAVA_HOME} ]]; then
- echo "JAVA_HOME: ${JAVA_HOME} does not exist. Dockermode: attempting to switch to another." 1>&2
- JAVA_HOME=""
-fi
-
-if [[ -z ${JAVA_HOME} ]]; then
- JAVA_HOME=$(find /usr/lib/jvm/ -name "java-*" -type d | tail -1)
- export JAVA_HOME
-fi
-
-# Avoid out of memory errors in builds
-MAVEN_OPTS=${MAVEN_OPTS:-"-Xms256m -Xmx1g"}
-export MAVEN_OPTS
-
-# strip out --docker param to prevent re-exec again
-TESTPATCHMODE=${TESTPATCHMODE/--docker }
-
-
-cd "${BASEDIR}"
-PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
-
-cd "${PATCH_DIR}/precommit/"
-#shellcheck disable=SC2086
-"${PATCH_DIR}/precommit/test-patch.sh" \
- --reexec \
- --dockermode ${TESTPATCHMODE} \
- --basedir="${BASEDIR}" \
- --patch-dir="${PATCH_DIR}" \
- --java-home="${JAVA_HOME}" \
- --personality="${PATCH_DIR}/precommit/personality/provided.sh" \
- --user-plugins="${PATCH_DIR}/precommit/user-plugins"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch-docker/test-patch-docker.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-docker/test-patch-docker.sh b/dev-support/test-patch-docker/test-patch-docker.sh
deleted file mode 100755
index 8b19502..0000000
--- a/dev-support/test-patch-docker/test-patch-docker.sh
+++ /dev/null
@@ -1,388 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-DID=${RANDOM}
-
-## @description Print a message to stderr if --debug is turned on
-## @audience private
-## @stability stable
-## @replaceable no
-## @param string
-function yetus_debug
-{
- if [[ "${YETUS_SHELL_SCRIPT_DEBUG}" = true ]]; then
- echo "[$(date) DEBUG]: $*" 1>&2
- fi
-}
-
-## @description Run docker with some arguments, and
-## @description optionally send to debug
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function dockercmd
-{
- yetus_debug "docker $*"
- docker "$@"
-}
-
-## @description Handle command line arguments
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --debug)
- YETUS_SHELL_SCRIPT_DEBUG=true
- ;;
- --dockerversion=*)
- DOCKER_VERSION=${i#*=}
- ;;
- --help|-help|-h|help|--h|--\?|-\?|\?)
- yetus_usage
- exit 0
- ;;
- --java-home=*)
- JAVA_HOME=${i#*=}
- ;;
- --patch-dir=*)
- PATCH_DIR=${i#*=}
- ;;
- --project=*)
- PROJECT_NAME=${i#*=}
- ;;
- *)
- ;;
- esac
- done
-}
-
-## @description Stop and delete all defunct containers
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function stop_exited_containers
-{
- local line
- local id
- local value
- local size
-
- echo "Docker containers in exit state:"
-
- dockercmd ps -a | grep Exited
-
- # stop *all* containers that are in exit state for
- # more than > 8 hours
- while read line; do
- id=$(echo "${line}" | cut -f1 -d' ')
- value=$(echo "${line}" | cut -f2 -d' ')
- size=$(echo "${line}" | cut -f3 -d' ')
-
- if [[ ${size} =~ day
- || ${size} =~ week
- || ${size} =~ month
- || ${size} =~ year ]]; then
- echo "Removing docker ${id}"
- dockercmd rm "${id}"
- fi
-
- if [[ ${size} =~ hours
- && ${value} -gt 8 ]]; then
- echo "Removing docker ${id}"
- dockercmd rm "${id}"
- fi
- done < <(
- dockercmd ps -a \
- | grep Exited \
- | sed -e 's,ago,,g' \
- | awk '{print $1" "$(NF - 2)" "$(NF - 1)}')
-}
-
-## @description Remove all containers that are not
-## @description are not running + older than 1 day
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function rm_old_containers
-{
- local line
- local id
- local value
- local size
-
- while read line; do
- id=$(echo "${line}" | cut -f1 -d, )
- state=$(echo "${line}" | cut -f2 -d, )
- stoptime=$(echo "${line}" | cut -f3 -d, | cut -f1 -d. )
-
- # believe it or not, date is not even close to standardized...
- if [[ $(uname -s) == Linux ]]; then
-
- # GNU date
- stoptime=$(date -d "${stoptime}" "+%s")
- else
-
- # BSD date
- stoptime=$(date -j -f "%Y-%m-%dT%H:%M:%S" "${stoptime}" "+%s")
- fi
-
- if [[ ${state} == false ]]; then
- curtime=$(date "+%s")
- ((difftime = curtime - stoptime))
- if [[ ${difftime} -gt 86400 ]]; then
- echo "Removing docker ${id}"
- dockercmd rm "${id}"
- fi
- fi
- done < <(
- # see https://github.com/koalaman/shellcheck/issues/375
- # shellcheck disable=SC2046
- dockercmd inspect \
- -f '{{.Id}},{{.State.Running}},{{.State.FinishedAt}}' \
- $(dockercmd ps -qa) 2>/dev/null)
-}
-
-## @description Remove untagged/unused images
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function remove_untagged_images
-{
- # this way is a bit more compatible with older docker versions
- dockercmd images | tail -n +2 | awk '$1 == "<none>" {print $3}' | \
- xargs --no-run-if-empty docker rmi
-}
-
-## @description Remove defunct tagged images
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function remove_old_tagged_images
-{
- local line
- local id
- local created
-
- while read line; do
- id=$(echo "${line}" | awk '{print $1}')
- created=$(echo "${line}" | awk '{print $5}')
-
- if [[ ${created} =~ week
- || ${created} =~ month
- || ${created} =~ year ]]; then
- echo "Removing docker image ${id}"
- dockercmd rmi "${id}"
- fi
-
- if [[ ${id} =~ test-patch-base-${PROJECT_NAME}-date ]]; then
- if [[ ${created} =~ day
- || ${created} =~ hours ]]; then
- echo "Removing docker image ${id}"
- dockercmd rmi "${id}"
- fi
- fi
- done < <(dockercmd images)
-
-}
-
-## @description Performance docker maintenance on Jenkins
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function cleanup_apache_jenkins_docker
-{
- echo "=========================="
- echo "Docker Images:"
- dockercmd images
- echo "=========================="
- echo "Docker Containers:"
- dockercmd ps -a
- echo "=========================="
-
- stop_exited_containers
-
- rm_old_containers
-
- remove_untagged_images
-
- remove_old_tagged_images
-}
-
-## @description Clean up our old images used for patch testing
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function cleanup_test_patch_images
-{
- local images
- local imagecount
- local rmimage
- local rmi
-
- # we always want to leave at least one of our images
- # so that the whole thing doesn't have to be rebuilt.
- # This also let's us purge any old images so that
- # we can get fresh stuff sometimes
- images=$(dockercmd images | grep --color=none "test-patch-tp-${PROJECT_NAME}" | awk '{print $1}') 2>&1
-
- # shellcheck disable=SC2086
- imagecount=$(echo ${images} | tr ' ' '\n' | wc -l)
- ((imagecount = imagecount - 1 ))
-
- # shellcheck disable=SC2086
- rmimage=$(echo ${images} | tr ' ' '\n' | tail -${imagecount})
- for rmi in ${rmimage}
- do
- echo "Removing image ${rmi}"
- dockercmd rmi "${rmi}"
- done
-}
-
-## @description Perform pre-run maintenance to free up
-## @description resources. With --jenkins, it is a lot
-## @description more destructive.
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function cleanup
-{
- if [[ ${TESTPATCHMODE} =~ jenkins ]]; then
- cleanup_apache_jenkins_docker
- fi
-
- cleanup_test_patch_images
-}
-
-## @description Deterine the user name and user id of the user
-## @description that the docker container should use
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function determine_user
-{
- # On the Apache Jenkins hosts, $USER is pretty much untrustable beacuse some
- # ... person ... sets it to an account that doesn't actually exist.
- # so instead, we need to try and override it with something that's
- # probably close to reality.
- if [[ ${TESTPATCHMODE} =~ jenkins ]]; then
- USER=$(id | cut -f2 -d\( | cut -f1 -d\))
- fi
-
- if [[ "$(uname -s)" == "Linux" ]]; then
- USER_NAME=${SUDO_USER:=$USER}
- USER_ID=$(id -u "${USER_NAME}")
- GROUP_ID=$(id -g "${USER_NAME}")
- else # boot2docker uid and gid
- USER_NAME=${USER}
- USER_ID=1000
- GROUP_ID=50
- fi
-}
-
-## @description Determine the revision of a dockerfile
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function getdockerfilerev
-{
- grep 'TEST_PATCH_PRIVATE: gitrev=' \
- "${PATCH_DIR}/precommit/test-patch-docker/Dockerfile" \
- | cut -f2 -d=
-}
-
-## @description Start a test patch docker container
-## @audience private
-## @stability evolving
-## @replaceable no
-## @param args
-function run_image
-{
- local dockerfilerev
- local baseimagename
-
- dockerfilerev=$(getdockerfilerev)
-
- baseimagename="test-patch-base-${PROJECT_NAME}-${dockerfilerev}"
-
- # make a base image, if it isn't available
- dockercmd build -t "${baseimagename}" "${PATCH_DIR}/precommit/test-patch-docker"
-
- # using the base image, make one that is patch specific
- dockercmd build -t "test-patch-tp-${PROJECT_NAME}-${DID}" - <<PatchSpecificDocker
-FROM ${baseimagename}
-RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
-RUN useradd -g ${GROUP_ID} -u ${USER_ID} -m ${USER_NAME}
-RUN chown -R ${USER_NAME} /home/${USER_NAME}
-ENV HOME /home/${USER_NAME}
-USER ${USER_NAME}
-PatchSpecificDocker
-
- if [[ -f "${PATCH_DIR}/buildtool-docker-params.txt" ]]; then
- extraargs=$(cat "${PATCH_DIR}/buildtool-docker-params.txt")
- else
- extraargs=""
- fi
-
- if [[ ${PATCH_DIR} =~ ^/ ]]; then
- dockercmd run --rm=true -i \
- ${extraargs} \
- -v "${PWD}:/testptch/${PROJECT_NAME}" \
- -v "${PATCH_DIR}:/testptch/patchprocess" \
- -u "${USER_NAME}" \
- -w "/testptch/${PROJECT_NAME}" \
- --env=BASEDIR="/testptch/${PROJECT_NAME}" \
- --env=DOCKER_VERSION="${DOCKER_VERSION} Image:${baseimagename}" \
- --env=JAVA_HOME="${JAVA_HOME}" \
- --env=PATCH_DIR=/testptch/patchprocess \
- --env=PROJECT_NAME="${PROJECT_NAME}" \
- --env=TESTPATCHMODE="${TESTPATCHMODE}" \
- "test-patch-tp-${PROJECT_NAME}-${DID}"
- else
- dockercmd run --rm=true -i \
- ${extraargs} \
- -v "${PWD}:/testptch/${PROJECT_NAME}" \
- -u "${USER_NAME}" \
- -w "/testptch/${PROJECT_NAME}" \
- --env=BASEDIR="/testptch/${PROJECT_NAME}" \
- --env=DOCKER_VERSION="${DOCKER_VERSION} Image:${baseimagename}" \
- --env=JAVA_HOME="${JAVA_HOME}" \
- --env=PATCH_DIR="${PATCH_DIR}" \
- --env=PROJECT_NAME="${PROJECT_NAME}" \
- --env=TESTPATCHMODE="${TESTPATCHMODE}" \
- "test-patch-tp-${PROJECT_NAME}-${DID}"
- fi
-}
-
-parse_args "$@"
-cleanup
-determine_user
-run_image
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/ant.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/ant.sh b/dev-support/test-patch.d/ant.sh
deleted file mode 100755
index 9d931a5..0000000
--- a/dev-support/test-patch.d/ant.sh
+++ /dev/null
@@ -1,201 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-if [[ -z "${ANT_HOME:-}" ]]; then
- ANT=ant
-else
- ANT=${ANT_HOME}/bin/ant
-fi
-
-add_build_tool ant
-
-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')"
-}
-
-function ant_parse_args
-{
- local i
-
- for i in "$@"; do
- case ${i} in
- --ant-cmd=*)
- ANT=${i#*=}
- ;;
- esac
- done
-
- # if we requested offline, pass that to ant
- if [[ ${OFFLINE} == "true" ]]; then
- ANT_ARGS=("${ANT_ARGS[@]}" -Doffline=)
- fi
-}
-
-function ant_initialize
-{
- # we need to do this before docker kicks in
- if [[ -e "${HOME}/.ivy2"
- && ! -d "${HOME}/.ivy2" ]]; then
- yetus_error "ERROR: ${HOME}/.ivy2 is not a directory."
- return 1
- elif [[ ! -e "${HOME}/.ivy2" ]]; then
- yetus_debug "Creating ${HOME}/.ivy2"
- mkdir -p "${HOME}/.ivy2"
- fi
-}
-
-function ant_buildfile
-{
- echo "build.xml"
-}
-
-function ant_executor
-{
- echo "${ANT}" "${ANT_ARGS[@]}"
-}
-
-function ant_modules_worker
-{
- declare repostatus=$1
- declare tst=$2
- shift 2
-
- # shellcheck disable=SC2034
- UNSUPPORTED_TEST=false
-
- case ${tst} in
- findbugs)
- modules_workers "${repostatus}" findbugs findbugs
- ;;
- compile)
- modules_workers "${repostatus}" compile
- ;;
- distclean)
- modules_workers "${repostatus}" distclean clean
- ;;
- javadoc)
- modules_workers "${repostatus}" javadoc clean javadoc
- ;;
- unit)
- modules_workers "${repostatus}" unit
- ;;
- *)
- # shellcheck disable=SC2034
- UNSUPPORTED_TEST=true
- if [[ ${repostatus} = patch ]]; then
- add_footer_table "${tst}" "not supported by the ${BUILDTOOL} plugin"
- fi
- yetus_error "WARNING: ${tst} is unsupported by ${BUILDTOOL}"
- return 1
- ;;
- esac
-}
-
-function ant_javac_count_probs
-{
- declare warningfile=$1
- declare val1
- declare val2
-
- #shellcheck disable=SC2016
- val1=$(${GREP} -E "\[javac\] [0-9]+ errors?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
- #shellcheck disable=SC2016
- val2=$(${GREP} -E "\[javac\] [0-9]+ warnings?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
- echo $((val1+val2))
-}
-
-## @description Helper for check_patch_javadoc
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function ant_javadoc_count_probs
-{
- local warningfile=$1
- local val1
- local val2
-
- #shellcheck disable=SC2016
- val1=$(${GREP} -E "\[javadoc\] [0-9]+ errors?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
- #shellcheck disable=SC2016
- val2=$(${GREP} -E "\[javadoc\] [0-9]+ warnings?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
- echo $((val1+val2))
-}
-
-function ant_builtin_personality_modules
-{
- local repostatus=$1
- local testtype=$2
-
- local module
-
- yetus_debug "Using builtin personality_modules"
- yetus_debug "Personality: ${repostatus} ${testtype}"
-
- clear_personality_queue
-
- for module in ${CHANGED_MODULES}; do
- # shellcheck disable=SC2086
- personality_enqueue_module ${module}
- done
-}
-
-function ant_builtin_personality_file_tests
-{
- local filename=$1
-
- yetus_debug "Using builtin ant personality_file_tests"
-
- if [[ ${filename} =~ \.sh
- || ${filename} =~ \.cmd
- ]]; then
- yetus_debug "tests/shell: ${filename}"
- elif [[ ${filename} =~ \.c$
- || ${filename} =~ \.cc$
- || ${filename} =~ \.h$
- || ${filename} =~ \.hh$
- || ${filename} =~ \.proto$
- || ${filename} =~ src/test
- || ${filename} =~ \.cmake$
- || ${filename} =~ CMakeLists.txt
- ]]; then
- yetus_debug "tests/units: ${filename}"
- add_test javac
- add_test unit
- elif [[ ${filename} =~ build.xml
- || ${filename} =~ ivy.xml
- || ${filename} =~ \.java$
- ]]; then
- yetus_debug "tests/javadoc+units: ${filename}"
- add_test javac
- add_test javadoc
- add_test unit
- fi
-
- if [[ ${filename} =~ \.java$ ]]; then
- add_test findbugs
- fi
-}
-
-function ant_docker_support
-{
- echo "-v ${HOME}/.ivy2:${HOME}/.ivy2" > "${PATCH_DIR}/buildtool-docker-params.txt"
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/asflicense.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/asflicense.sh b/dev-support/test-patch.d/asflicense.sh
deleted file mode 100755
index befe7a1..0000000
--- a/dev-support/test-patch.d/asflicense.sh
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-add_test_type asflicense
-add_test asflicense
-
-function asflicense_parse_args
-{
- declare i
-
- for i in "$@"; do
- case ${i} in
- --asflicense-rat-excludes=*)
- ASFLICENSE_RAT_EXCLUDES=${i#*=}
- ;;
- --asflicense-rat-jar=*)
- ASFLICENSE_RAT_JAR=${i#*=}
- ;;
- esac
- done
-
- case ${BUILDTOOL} in
- ant|gradle|maven)
- add_test asflicense
- ;;
- *)
- if [[ -f "${ASFLICENSE_RAT_JAR}" ]]; then
- add_test asflicense
- fi
- ;;
- esac
-}
-
-## @description Verify all files have an Apache License
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function asflicense_tests
-{
- local numpatch
- local btfails=true
- local asfex
-
- big_console_header "Determining number of patched ASF License errors"
-
- start_clock
-
- personality_modules patch asflicense
- case ${BUILDTOOL} in
- ant)
- modules_workers patch asflicense releaseaudit
- ;;
- gradle)
- btfails=false
- modules_workers patch asflicense rat
- ;;
- maven)
- modules_workers patch asflicense apache-rat:check
- ;;
- *)
- if [[ -z "${ASFLICENSE_RAT_JAR}" ]]; then
- return 0
- fi
-
- if [[ -f ${ASFLICENSE_RAT_EXCLUDES} ]]; then
- asfex="-E ${ASFLICENSE_RAT_EXCLUDES} -d ${BASEDIR}"
- else
- asfex="${BASEDIR}"
- fi
-
- asflicense_writexsl "${PATCH_DIR}/asf.xsl"
- echo_and_redirect "${PATCH_DIR}/patch-asflicense.txt" \
- "${JAVA_HOME}/bin/java" \
- -jar "${ASFLICENSE_RAT_JAR}" \
- -s "${PATCH_DIR}/asf.xsl" \
- "${asfex}"
- ;;
- esac
-
- # RAT fails the build if there are license problems.
- # so let's take advantage of that a bit.
- if [[ $? == 0 && ${btfails} = true ]]; then
- add_vote_table 1 asflicense "Patch does not generate ASF License warnings."
- return 0
- fi
-
- if [[ ! -f "${PATCH_DIR}/patch-asflicense.txt" ]]; then
- #shellcheck disable=SC2038
- find "${BASEDIR}" -name rat.txt \
- -o -name releaseaudit_report.txt \
- -o -name rat-report.txt \
- | xargs cat > "${PATCH_DIR}/patch-asflicense.txt"
- fi
-
- if [[ ! -s "${PATCH_DIR}/patch-asflicense.txt" ]]; then
- if [[ ${btfails} = true ]]; then
- # if we're here, then build actually failed
- modules_messages patch asflicense true
- else
- add_vote_table 0 asflicense "ASF License check generated no output?"
- return 0
- fi
- fi
-
- numpatch=$("${GREP}" -c '\!?????' "${PATCH_DIR}/patch-asflicense.txt")
- echo ""
- echo ""
- echo "There appear to be ${numpatch} ASF License warnings after applying the patch."
- if [[ -n ${numpatch}
- && ${numpatch} -gt 0 ]] ; then
- add_vote_table -1 asflicense "Patch generated ${numpatch} ASF License warnings."
-
- echo "Lines that start with ????? in the ASF License "\
- "report indicate files that do not have an Apache license header:" \
- > "${PATCH_DIR}/patch-asflicense-problems.txt"
-
- ${GREP} '\!?????' "${PATCH_DIR}/patch-asflicense.txt" \
- >> "${PATCH_DIR}/patch-asflicense-problems.txt"
-
- add_footer_table asflicense "@@BASE@@/patch-asflicense-problems.txt"
- return 1
- fi
- add_vote_table 1 asflicense "Patch does not generate ASF License warnings."
- return 0
-}
-
-function asflicense_writexsl
-{
-cat > "${1}" << EOF
-<?xml version='1.0' ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one *
- or more contributor license agreements. See the NOTICE file *
- distributed with this work for additional information *
- regarding copyright ownership. The ASF licenses this file *
- to you under the Apache License, Version 2.0 (the *
- "License"); you may not use this file except in compliance *
- with the License. You may obtain a copy of the License at *
- *
- http://www.apache.org/licenses/LICENSE-2.0 *
- *
- Unless required by applicable law or agreed to in writing, *
- software distributed under the License is distributed on an *
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- KIND, either express or implied. See the License for the *
- specific language governing permissions and limitations *
- under the License. *
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method='text'/>
-<xsl:template match='/'>
- Files with Apache License headers will be marked AL
- Binary files (which do not require any license headers) will be marked B
- Compressed archives will be marked A
- Notices, licenses etc. will be marked N
-
- <xsl:for-each select='descendant::resource'>
- <xsl:choose>
- <xsl:when test='license-approval/@name="false"'>!</xsl:when>
- <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test='type/@name="notice"'>N </xsl:when>
- <xsl:when test='type/@name="archive"'>A </xsl:when>
- <xsl:when test='type/@name="binary"'>B </xsl:when>
- <xsl:when test='type/@name="standard"'><xsl:value-of select='header-type/@name'/></xsl:when>
- <xsl:otherwise>!!!!!</xsl:otherwise>
- </xsl:choose>
- <xsl:text> </xsl:text>
- <xsl:value-of select='@name'/>
- <xsl:text>
- </xsl:text>
- </xsl:for-each>
-</xsl:template>
-</xsl:stylesheet>
-EOF
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/author.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/author.sh b/dev-support/test-patch.d/author.sh
deleted file mode 100755
index d456bbb..0000000
--- a/dev-support/test-patch.d/author.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type author
-
-## @description Check the current directory for @author tags
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function author_patchfile
-{
- declare patchfile=$1
- declare authorTags
- # shellcheck disable=SC2155
- declare -r appname=$(basename "${BASH_SOURCE-$0}")
-
- big_console_header "Checking there are no @author tags in the patch."
-
- start_clock
-
- if [[ ${CHANGED_FILES} =~ ${appname} ]]; then
- echo "Skipping @author checks as ${appname} has been patched."
- add_vote_table 0 @author "Skipping @author checks as ${appname} has been patched."
- return 0
- fi
-
- authorTags=$("${GREP}" -c -i '^[^-].*@author' "${patchfile}")
- echo "There appear to be ${authorTags} @author tags in the patch."
- if [[ ${authorTags} != 0 ]] ; then
- add_vote_table -1 @author \
- "The patch appears to contain ${authorTags} @author tags which the" \
- " community has agreed to not allow in code contributions."
- return 1
- fi
- add_vote_table +1 @author "The patch does not contain any @author tags."
- return 0
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/cc.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/cc.sh b/dev-support/test-patch.d/cc.sh
deleted file mode 100755
index cae91d3..0000000
--- a/dev-support/test-patch.d/cc.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type cc
-
-function cc_filefilter
-{
- declare filename=$1
-
- if [[ ${filename} =~ \.c$
- || ${filename} =~ \.cc$
- || ${filename} =~ \.cpp$
- || ${filename} =~ \.cxx$
- || ${filename} =~ \.h$
- || ${filename} =~ \.hh$
- ]]; then
- yetus_debug "tests/cc: ${filename}"
- add_test cc
- add_test compile
- fi
-}
-
-## @description check for C/C++ compiler errors
-## @audience private
-## @stability stable
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function cc_compile
-{
- declare codebase=$1
- declare multijdkmode=$2
-
- verify_needed_test cc
- if [[ $? = 0 ]]; then
- return 0
- fi
-
- if [[ ${codebase} = patch ]]; then
- generic_postlog_compare compile cc "${multijdkmode}"
- fi
-}
-
-function cc_count_probs
-{
- declare warningfile=$1
-
- #shellcheck disable=SC2016,SC2046
- ${GREP} -E '^.*\.(c|cc|h|hh)\:[[:digit:]]*\:' "${warningfile}" | ${AWK} '{sum+=1} END {print sum}'
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/checkstyle.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/checkstyle.sh b/dev-support/test-patch.d/checkstyle.sh
deleted file mode 100755
index 24b9ffc..0000000
--- a/dev-support/test-patch.d/checkstyle.sh
+++ /dev/null
@@ -1,237 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type checkstyle
-
-CHECKSTYLE_TIMER=0
-
-function checkstyle_filefilter
-{
- local filename=$1
-
- if [[ ${BUILDTOOL} == maven
- || ${BUILDTOOL} == ant ]]; then
- if [[ ${filename} =~ \.java$ ]]; then
- add_test checkstyle
- fi
- fi
-}
-
-function checkstyle_runner
-{
- local repostatus=$1
- local tmp=${PATCH_DIR}/$$.${RANDOM}
- local j
- local i=0
- local fn
- local savestart=${TIMER}
- local savestop
- local output
- local logfile
- local repo
- local modulesuffix
- local cmd
-
- modules_reset
-
- if [[ ${repostatus} == branch ]]; then
- repo=${PATCH_BRANCH}
- else
- repo="the patch"
- fi
-
- #shellcheck disable=SC2153
- until [[ $i -eq ${#MODULE[@]} ]]; do
- start_clock
- fn=$(module_file_fragment "${MODULE[${i}]}")
- modulesuffix=$(basename "${MODULE[${i}]}")
- output="${PATCH_DIR}/${repostatus}-checkstyle-${fn}.txt"
- logfile="${PATCH_DIR}/maven-${repostatus}-checkstyle-${fn}.txt"
-
- if [[ ${BUILDTOOLCWD} == true ]]; then
- pushd "${BASEDIR}/${MODULE[${i}]}" >/dev/null
- fi
-
- case ${BUILDTOOL} in
- ant)
- cmd="${ANT} \
- -Dcheckstyle.consoleOutput=true \
- ${MODULEEXTRAPARAM[${i}]//@@@MODULEFN@@@/${fn}} \
- ${ANT_ARGS[*]} checkstyle"
- ;;
- maven)
- cmd="${MAVEN} ${MAVEN_ARGS[*]} \
- checkstyle:checkstyle \
- -Dcheckstyle.consoleOutput=true \
- ${MODULEEXTRAPARAM[${i}]//@@@MODULEFN@@@/${fn}} -Ptest-patch"
- ;;
- *)
- UNSUPPORTED_TEST=true
- return 0
- ;;
- esac
-
- #shellcheck disable=SC2086
- echo ${cmd} "> ${logfile}"
- #shellcheck disable=SC2086
- ${cmd} 2>&1 \
- | tee "${logfile}" \
- | ${GREP} ^/ \
- | ${SED} -e "s,${BASEDIR},.,g" \
- > "${tmp}"
-
- if [[ $? == 0 ]] ; then
- module_status ${i} +1 "${logfile}" "${modulesuffix} in ${repo} passed checkstyle"
- else
- module_status ${i} -1 "${logfile}" "${modulesuffix} in ${repo} failed checkstyle"
- ((result = result + 1))
- fi
- savestop=$(stop_clock)
- #shellcheck disable=SC2034
- MODULE_STATUS_TIMER[${i}]=${savestop}
-
- for j in ${CHANGED_FILES}; do
- ${GREP} "${j}" "${tmp}" >> "${output}"
- done
-
- rm "${tmp}" 2>/dev/null
-
- if [[ ${BUILDTOOLCWD} == true ]]; then
- popd >/dev/null
- fi
- ((i=i+1))
- done
-
- TIMER=${savestart}
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-function checkstyle_postcompile
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- checkstyle_preapply
- else
- checkstyle_postapply
- fi
-}
-
-function checkstyle_preapply
-{
- local result
-
- verify_needed_test checkstyle
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "${PATCH_BRANCH} checkstyle"
-
- start_clock
-
- personality_modules branch checkstyle
- checkstyle_runner branch
- result=$?
- modules_messages branch checkstyle true
-
- # keep track of how much as elapsed for us already
- CHECKSTYLE_TIMER=$(stop_clock)
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
-
-function checkstyle_postapply
-{
- local result
- local module
- local mod
- local fn
- local i=0
- local numprepatch=0
- local numpostpatch=0
- local diffpostpatch=0
-
- verify_needed_test checkstyle
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "Patch checkstyle plugin"
-
- start_clock
-
- personality_modules patch checkstyle
- checkstyle_runner patch
- result=$?
-
- if [[ ${UNSUPPORTED_TEST} = true ]]; then
- return 0
- fi
-
- # add our previous elapsed to our new timer
- # by setting the clock back
- offset_clock "${CHECKSTYLE_TIMER}"
-
- until [[ $i -eq ${#MODULE[@]} ]]; do
- if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
- ((result=result+1))
- ((i=i+1))
- continue
- fi
- module=${MODULE[$i]}
- fn=$(module_file_fragment "${module}")
-
- if [[ ! -f "${PATCH_DIR}/branch-checkstyle-${fn}.txt" ]]; then
- touch "${PATCH_DIR}/branch-checkstyle-${fn}.txt"
- fi
-
- calcdiffs "${PATCH_DIR}/branch-checkstyle-${fn}.txt" "${PATCH_DIR}/patch-checkstyle-${fn}.txt" > "${PATCH_DIR}/diff-checkstyle-${fn}.txt"
- #shellcheck disable=SC2016
- diffpostpatch=$(wc -l "${PATCH_DIR}/diff-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
-
- if [[ ${diffpostpatch} -gt 0 ]] ; then
- ((result = result + 1))
-
- # shellcheck disable=SC2016
- numprepatch=$(wc -l "${PATCH_DIR}/branch-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
- # shellcheck disable=SC2016
- numpostpatch=$(wc -l "${PATCH_DIR}/patch-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
-
- mod=${module}
- if [[ ${mod} == . ]]; then
- mod=root
- fi
- module_status ${i} -1 "diff-checkstyle-${fn}.txt" "Patch generated "\
- "${diffpostpatch} new checkstyle issues in "\
- "${mod} (total was ${numprepatch}, now ${numpostpatch})."
- fi
- ((i=i+1))
- done
-
- modules_messages patch checkstyle true
-
- if [[ ${result} != 0 ]]; then
- return 1
- fi
- return 0
-}
[07/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/shellcheck.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/shellcheck.sh b/dev-support/test-patch.d/shellcheck.sh
deleted file mode 100755
index d50d212..0000000
--- a/dev-support/test-patch.d/shellcheck.sh
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type shellcheck
-
-SHELLCHECK_TIMER=0
-
-SHELLCHECK=${SHELLCHECK:-$(which shellcheck 2>/dev/null)}
-
-SHELLCHECK_SPECIFICFILES=""
-
-# if it ends in an explicit .sh, then this is shell code.
-# if it doesn't have an extension, we assume it is shell code too
-function shellcheck_filefilter
-{
- local filename=$1
-
- if [[ ${filename} =~ \.sh$ ]]; then
- add_test shellcheck
- SHELLCHECK_SPECIFICFILES="${SHELLCHECK_SPECIFICFILES} ./${filename}"
- fi
-
- if [[ ! ${filename} =~ \. ]]; then
- add_test shellcheck
- fi
-}
-
-function shellcheck_private_findbash
-{
- local i
- local value
- local list
-
- while read line; do
- value=$(find "${line}" ! -name '*.cmd' -type f \
- | ${GREP} -E -v '(.orig$|.rej$)')
-
- for i in ${value}; do
- if [[ ! ${i} =~ \.sh(\.|$)
- && ! $(head -n 1 "${i}") =~ ^#! ]]; then
- yetus_debug "Shellcheck skipped: ${i}"
- continue
- fi
- list="${list} ${i}"
- done
- done < <(find . -type d -name bin -o -type d -name sbin -o -type d -name scripts -o -type d -name libexec -o -type d -name shellprofile.d)
- # shellcheck disable=SC2086
- echo ${list} ${SHELLCHECK_SPECIFICFILES} | tr ' ' '\n' | sort -u
-}
-
-function shellcheck_preapply
-{
- local i
-
- verify_needed_test shellcheck
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "shellcheck plugin: prepatch"
-
- if [[ ! -x "${SHELLCHECK}" ]]; then
- yetus_error "shellcheck is not available."
- return 0
- fi
-
- start_clock
-
- echo "Running shellcheck against all identifiable shell scripts"
- pushd "${BASEDIR}" >/dev/null
- for i in $(shellcheck_private_findbash); do
- if [[ -f ${i} ]]; then
- ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/branch-shellcheck-result.txt"
- fi
- done
- popd > /dev/null
- # keep track of how much as elapsed for us already
- SHELLCHECK_TIMER=$(stop_clock)
- return 0
-}
-
-function shellcheck_postapply
-{
- local i
- local msg
- local numPrepatch
- local numPostpatch
- local diffPostpatch
-
- verify_needed_test shellcheck
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- big_console_header "shellcheck plugin: postpatch"
-
- if [[ ! -x "${SHELLCHECK}" ]]; then
- yetus_error "shellcheck is not available."
- add_vote_table 0 shellcheck "Shellcheck was not available."
- return 0
- fi
-
- start_clock
-
- # add our previous elapsed to our new timer
- # by setting the clock back
- offset_clock "${SHELLCHECK_TIMER}"
-
- echo "Running shellcheck against all identifiable shell scripts"
- # we re-check this in case one has been added
- for i in $(shellcheck_private_findbash); do
- if [[ -f ${i} ]]; then
- ${SHELLCHECK} -f gcc "${i}" >> "${PATCH_DIR}/patch-shellcheck-result.txt"
- fi
- done
-
- if [[ ! -f "${PATCH_DIR}/branch-shellcheck-result.txt" ]]; then
- touch "${PATCH_DIR}/branch-shellcheck-result.txt"
- fi
-
- # shellcheck disable=SC2016
- SHELLCHECK_VERSION=$(${SHELLCHECK} --version | ${GREP} version: | ${AWK} '{print $NF}')
- msg="v${SHELLCHECK_VERSION}"
- if [[ ${SHELLCHECK_VERSION} =~ 0.[0-3].[0-5] ]]; then
- msg="${msg} (This is an old version that has serious bugs. Consider upgrading.)"
- fi
- add_footer_table shellcheck "${msg}"
-
- calcdiffs \
- "${PATCH_DIR}/branch-shellcheck-result.txt" \
- "${PATCH_DIR}/patch-shellcheck-result.txt" \
- > "${PATCH_DIR}/diff-patch-shellcheck.txt"
- # shellcheck disable=SC2016
- diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-shellcheck.txt" | ${AWK} '{print $1}')
-
- if [[ ${diffPostpatch} -gt 0 ]] ; then
- # shellcheck disable=SC2016
- numPrepatch=$(wc -l "${PATCH_DIR}/branch-shellcheck-result.txt" | ${AWK} '{print $1}')
-
- # shellcheck disable=SC2016
- numPostpatch=$(wc -l "${PATCH_DIR}/patch-shellcheck-result.txt" | ${AWK} '{print $1}')
-
- add_vote_table -1 shellcheck "The applied patch generated "\
- "${diffPostpatch} new shellcheck issues (total was ${numPrepatch}, now ${numPostpatch})."
- add_footer_table shellcheck "@@BASE@@/diff-patch-shellcheck.txt"
- bugsystem_linecomments "shellcheck" "${PATCH_DIR}/diff-patch-shellcheck.txt"
- return 1
- fi
-
- add_vote_table +1 shellcheck "There were no new shellcheck issues."
- return 0
-}
-
-function shellcheck_postcompile
-{
- declare repostatus=$1
-
- if [[ "${repostatus}" = branch ]]; then
- shellcheck_preapply
- else
- shellcheck_postapply
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/tap.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/tap.sh b/dev-support/test-patch.d/tap.sh
deleted file mode 100755
index 7ced908..0000000
--- a/dev-support/test-patch.d/tap.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_format tap
-
-TAP_FAILED_TESTS=""
-TAP_LOG_DIR="target/tap"
-
-function tap_process_args
-{
- declare i
-
- for i in "$@"; do
- case ${i} in
- --tap-log-dir=*)
- TAP_LOG_DIR=${i#=*}
- ;;
- esac
- done
-}
-
-function tap_usage
-{
- echo "TAP Options:"
- echo "--tap-log-dir=<dir> Directory relative to the module for tap output (default: \"target/tap\")"
-}
-
-function tap_process_tests
-{
- # shellcheck disable=SC2034
- declare module=$1
- # shellcheck disable=SC2034
- declare buildlogfile=$2
- declare filefrag=$3
- declare result=0
- declare module_failed_tests
- declare filenames
-
- filenames=$(find "${TAP_LOG_DIR}" -type f -exec "${GREP}" -l -E "^not ok" {} \;)
-
- if [[ -n "${filenames}" ]]; then
- module_failed_tests=$(echo "${filenames}" \
- | ${SED} -e "s,${TAP_LOG_DIR},,g" -e s,^/,,g )
- # shellcheck disable=SC2086
- cat ${filenames} >> "${PATCH_DIR}/patch-${filefrag}.tap"
- TAP_LOGS="${TAP_LOGS} @@BASE@@/patch-${filefrag}.tap"
- TAP_FAILED_TESTS="${TAP_FAILED_TESTS} ${module_failed_tests}"
- ((result=result+1))
- fi
-
- if [[ ${result} -gt 0 ]]; then
- return 1
- fi
- return 0
-}
-
-function tap_finalize_results
-{
- declare jdk=$1
-
- if [[ -n "${TAP_FAILED_TESTS}" ]] ; then
- # shellcheck disable=SC2086
- populate_test_table "${jdk}Failed TAP tests" ${TAP_FAILED_TESTS}
- TAP_FAILED_TESTS=""
- add_footer_table "TAP logs" "${TAP_LOGS}"
- fi
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/test4tests.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/test4tests.sh b/dev-support/test-patch.d/test4tests.sh
deleted file mode 100755
index 94b9b7f..0000000
--- a/dev-support/test-patch.d/test4tests.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type test4tests
-
-## @description Check the patch file for changed/new tests
-## @audience private
-## @stability evolving
-## @replaceable no
-## @return 0 on success
-## @return 1 on failure
-function test4tests_patchfile
-{
- declare testReferences=0
- declare i
-
- big_console_header "Checking there are new or changed tests in the patch."
-
- verify_needed_test unit
-
- if [[ $? == 0 ]]; then
- echo "Patch does not appear to need new or modified tests."
- return 0
- fi
-
- start_clock
-
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ (^|/)test/ ]]; then
- ((testReferences=testReferences + 1))
- fi
- done
-
- echo "There appear to be ${testReferences} test file(s) referenced in the patch."
- if [[ ${testReferences} == 0 ]] ; then
- add_vote_table -1 "test4tests" \
- "The patch doesn't appear to include any new or modified tests. " \
- "Please justify why no new tests are needed for this patch." \
- "Also please list what manual steps were performed to verify this patch."
- return 1
- fi
- add_vote_table +1 "test4tests" \
- "The patch appears to include ${testReferences} new or modified test files."
- return 0
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/whitespace.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/whitespace.sh b/dev-support/test-patch.d/whitespace.sh
deleted file mode 100755
index 32c5f42..0000000
--- a/dev-support/test-patch.d/whitespace.sh
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type whitespace
-
-function whitespace_linecomment_reporter
-{
- declare file=$1
- shift
- declare comment=$*
- declare tmpfile="${PATCH_DIR}/wlr.$$.${RANDOM}"
-
- while read -r line; do
- {
- # shellcheck disable=SC2086
- printf "%s" "$(echo ${line} | cut -f1-2 -d:)"
- echo "${comment}"
- } >> "${tmpfile}"
- done < "${file}"
-
- bugsystem_linecomments "whitespace:" "${tmpfile}"
- rm "${tmpfile}"
-}
-
-function whitespace_postcompile
-{
- declare repostatus=$1
- declare count
- declare result=0
-
- if [[ "${repostatus}" = branch ]]; then
- return 0
- fi
-
- big_console_header "Checking for whitespace at the end of lines"
- start_clock
-
- pushd "${BASEDIR}" >/dev/null
- # shellcheck disable=SC2016
- ${AWK} '/\t/ {print $0}' \
- "${GITDIFFCONTENT}" \
- | ${GREP} -v Makefile: >> "${PATCH_DIR}/whitespace-tabs.txt"
-
- ${GREP} -E '[[:blank:]]$' \
- "${GITDIFFCONTENT}" \
- >> "${PATCH_DIR}/whitespace-eol.txt"
-
- # shellcheck disable=SC2016
- count=$(wc -l "${PATCH_DIR}/whitespace-eol.txt" | ${AWK} '{print $1}')
-
- if [[ ${count} -gt 0 ]]; then
- add_vote_table -1 whitespace "The patch has ${count}"\
- " line(s) that end in whitespace. Use git apply --whitespace=fix."
-
- whitespace_linecomment_reporter "${PATCH_DIR}/whitespace-eol.txt" "end of line"
- add_footer_table whitespace "@@BASE@@/whitespace-eol.txt"
- ((result=result+1))
- fi
-
- # shellcheck disable=SC2016
- count=$(wc -l "${PATCH_DIR}/whitespace-tabs.txt" | ${AWK} '{print $1}')
-
- if [[ ${count} -gt 0 ]]; then
- add_vote_table -1 whitespace "The patch has ${count}"\
- " line(s) with tabs."
- add_footer_table whitespace "@@BASE@@/whitespace-tabs.txt"
- whitespace_linecomment_reporter "${PATCH_DIR}/whitespace-tabs.txt" "tabs in line"
- ((result=result+1))
- fi
-
- if [[ ${result} -gt 0 ]]; then
- popd >/dev/null
- return 1
- fi
-
- popd >/dev/null
- add_vote_table +1 whitespace "Patch has no whitespace issues."
- return 0
-}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/dev-support/test-patch.d/xml.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/xml.sh b/dev-support/test-patch.d/xml.sh
deleted file mode 100755
index b04a2f3..0000000
--- a/dev-support/test-patch.d/xml.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-add_test_type xml
-
-function xml_filefilter
-{
- declare filename=$1
-
- if [[ ${filename} =~ \.xml$ ]]; then
- add_test xml
- fi
-}
-
-function xml_postcompile
-{
- declare repostatus=$1
- declare js
- declare i
- declare count
-
- verify_needed_test xml
- if [[ $? == 0 ]]; then
- return 0
- fi
-
- if [[ "${repostatus}" = branch ]]; then
- return 0
- fi
-
- big_console_header "Checking if XML files are well-formed"
-
- js="${JAVA_HOME}/bin/jrunscript"
- if [[ ! -x ${js} ]]; then
- yetus_error "${js} does not exist"
- return 0
- fi
-
- start_clock
-
- pushd "${BASEDIR}" >/dev/null
- for i in ${CHANGED_FILES}; do
- if [[ ${i} =~ \.xml$ && -f ${i} ]]; then
- ${js} -e "XMLDocument(arguments[0])" "${i}" >> "${PATCH_DIR}/xml.txt" 2>&1
- if [[ $? != 0 ]]; then
- ((count=count+1))
- fi
- fi
- done
-
- if [[ ${count} -gt 0 ]]; then
- add_vote_table -1 xml "The patch has ${count} ill-formed XML file(s)."
- add_footer_table xml "@@BASE@@/xml.txt"
- popd >/dev/null
- return 1
- fi
-
- popd >/dev/null
- add_vote_table +1 xml "The patch has no ill-formed XML file."
- return 0
-}
[02/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh
new file mode 100755
index 0000000..93874a2
--- /dev/null
+++ b/precommit/test-patch.sh
@@ -0,0 +1,2647 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Make sure that bash version meets the pre-requisite
+
+if [[ -z "${BASH_VERSINFO}" ]] \
+ || [[ "${BASH_VERSINFO[0]}" -lt 3 ]] \
+ || [[ "${BASH_VERSINFO[0]}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then
+ echo "bash v3.2+ is required. Sorry."
+ exit 1
+fi
+
+this="${BASH_SOURCE-$0}"
+BINDIR=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+STARTINGDIR=$(pwd)
+USER_PARAMS=("$@")
+GLOBALTIMER=$(date +"%s")
+#shellcheck disable=SC2034
+QATESTMODE=false
+
+# global arrays
+declare -a TP_HEADER
+declare -a TP_VOTE_TABLE
+declare -a TP_TEST_TABLE
+declare -a TP_FOOTER_TABLE
+declare -a MODULE_STATUS
+declare -a MODULE_STATUS_TIMER
+declare -a MODULE_STATUS_MSG
+declare -a MODULE_STATUS_LOG
+declare -a MODULE_COMPILE_LOG
+declare -a MODULE
+
+TP_HEADER_COUNTER=0
+TP_VOTE_COUNTER=0
+TP_TEST_COUNTER=0
+TP_FOOTER_COUNTER=0
+
+## @description Setup the default global variables
+## @audience public
+## @stability stable
+## @replaceable no
+function setup_defaults
+{
+ common_defaults
+
+ DOCKERFILE="${BINDIR}/test-patch-docker/Dockerfile-startstub"
+ HOW_TO_CONTRIBUTE="https://yetus.apache.org/documentation/latest/precommit-patchnames"
+ INSTANCE=${RANDOM}
+ RELOCATE_PATCH_DIR=false
+
+ ALLOWSUMMARIES=true
+
+ DOCKERSUPPORT=false
+ BUILD_NATIVE=${BUILD_NATIVE:-true}
+
+ BUILDTOOLCWD=true
+
+ # shellcheck disable=SC2034
+ CHANGED_MODULES=""
+ # shellcheck disable=SC2034
+ CHANGED_UNFILTERED_MODULES=""
+ # shellcheck disable=SC2034
+ CHANGED_UNION_MODULES=""
+ USER_MODULE_LIST=""
+ CHANGED_FILES=""
+ REEXECED=false
+ RESETREPO=false
+ ISSUE=""
+ TIMER=$(date +"%s")
+ BUILDTOOL=maven
+ JDK_TEST_LIST="compile javadoc unit"
+}
+
+## @description Convert the given module name to a file fragment
+## @audience public
+## @stability stable
+## @replaceable no
+## @param module
+function module_file_fragment
+{
+ local mod=$1
+ if [[ ${mod} == . ]]; then
+ echo root
+ else
+ echo "$1" | tr '/' '_' | tr '\\' '_'
+ fi
+}
+
+## @description Convert time in seconds to m + s
+## @audience public
+## @stability stable
+## @replaceable no
+## @param seconds
+function clock_display
+{
+ local -r elapsed=$1
+
+ if [[ ${elapsed} -lt 0 ]]; then
+ echo "N/A"
+ else
+ printf "%3sm %02ss" $((elapsed/60)) $((elapsed%60))
+ fi
+}
+
+## @description Activate the local timer
+## @audience public
+## @stability stable
+## @replaceable no
+function start_clock
+{
+ yetus_debug "Start clock"
+ TIMER=$(date +"%s")
+}
+
+## @description Print the elapsed time in seconds since the start of the local timer
+## @audience public
+## @stability stable
+## @replaceable no
+function stop_clock
+{
+ local -r stoptime=$(date +"%s")
+ local -r elapsed=$((stoptime-TIMER))
+ yetus_debug "Stop clock"
+
+ echo ${elapsed}
+}
+
+## @description Print the elapsed time in seconds since the start of the global timer
+## @audience private
+## @stability stable
+## @replaceable no
+function stop_global_clock
+{
+ local -r stoptime=$(date +"%s")
+ local -r elapsed=$((stoptime-GLOBALTIMER))
+ yetus_debug "Stop global clock"
+
+ echo ${elapsed}
+}
+
+## @description Add time to the local timer
+## @audience public
+## @stability stable
+## @replaceable no
+## @param seconds
+function offset_clock
+{
+ declare off=$1
+
+ yetus_debug "offset clock by ${off}"
+
+ if [[ -n ${off} ]]; then
+ ((TIMER=TIMER-off))
+ else
+ yetus_error "ASSERT: no offset passed to offset_clock: ${index}"
+ generate_stack
+ fi
+}
+
+## @description generate a stack trace when in debug mode
+## @audience public
+## @stability stable
+## @replaceable no
+## @return exits
+function generate_stack
+{
+ declare frame
+
+ if [[ "${YETUS_SHELL_SCRIPT_DEBUG}" = true ]]; then
+ while caller "${frame}"; do
+ ((frame++));
+ done
+ fi
+ exit 1
+}
+
+## @description Add to the header of the display
+## @audience public
+## @stability stable
+## @replaceable no
+## @param string
+function add_header_line
+{
+ # shellcheck disable=SC2034
+ TP_HEADER[${TP_HEADER_COUNTER}]="$*"
+ ((TP_HEADER_COUNTER=TP_HEADER_COUNTER+1 ))
+}
+
+## @description Add to the output table. If the first parameter is a number
+## @description that is the vote for that column and calculates the elapsed time
+## @description based upon the last start_clock(). If it the string null, then it is
+## @description a special entry that signifies extra
+## @description content for the final column. The second parameter is the reporting
+## @description subsystem (or test) that is providing the vote. The second parameter
+## @description is always required. The third parameter is any extra verbage that goes
+## @description with that subsystem.
+## @audience public
+## @stability stable
+## @replaceable no
+## @param +1/0/-1/null
+## @param subsystem
+## @param string
+## @return Elapsed time display
+function add_vote_table
+{
+ local value=$1
+ local subsystem=$2
+ shift 2
+
+ local calctime
+ local -r elapsed=$(stop_clock)
+
+ yetus_debug "add_vote_table ${value} ${subsystem} ${*}"
+
+ calctime=$(clock_display "${elapsed}")
+
+ if [[ ${value} == "1" ]]; then
+ value="+1"
+ fi
+
+ if [[ -z ${value} ]]; then
+ # shellcheck disable=SC2034
+ TP_VOTE_TABLE[${TP_VOTE_COUNTER}]="| | ${subsystem} | | ${*:-} |"
+ else
+ # shellcheck disable=SC2034
+ TP_VOTE_TABLE[${TP_VOTE_COUNTER}]="| ${value} | ${subsystem} | ${calctime} | $* |"
+ fi
+ ((TP_VOTE_COUNTER=TP_VOTE_COUNTER+1))
+}
+
+## @description Report the JVM version of the given directory
+## @stability stable
+## @audience private
+## @replaceable yes
+## @params directory
+## @returns version
+function report_jvm_version
+{
+ #shellcheck disable=SC2016
+ "${1}/bin/java" -version 2>&1 | head -1 | ${AWK} '{print $NF}' | tr -d \"
+}
+
+## @description Verify if a given test is multijdk
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param test
+## @return 1 = yes
+## @return 0 = no
+function verify_multijdk_test
+{
+ local i=$1
+
+ if [[ "${JDK_DIR_LIST}" == "${JAVA_HOME}" ]]; then
+ yetus_debug "MultiJDK not configured."
+ return 0
+ fi
+
+ if [[ ${JDK_TEST_LIST} =~ $i ]]; then
+ yetus_debug "${i} is in ${JDK_TEST_LIST} and MultiJDK configured."
+ return 1
+ fi
+ return 0
+}
+
+## @description Put the opening environment information at the bottom
+## @description of the footer table
+## @stability stable
+## @audience private
+## @replaceable yes
+function prepopulate_footer
+{
+ # shellcheck disable=SC2155
+ declare -r unamea=$(uname -a)
+
+ add_footer_table "uname" "${unamea}"
+ add_footer_table "Build tool" "${BUILDTOOL}"
+
+ if [[ -n ${REEXECPERSONALITY} ]]; then
+ add_footer_table "Personality" "${REEXECPERSONALITY}"
+ elif [[ -n ${PERSONALITY} ]]; then
+ add_footer_table "Personality" "${PERSONALITY}"
+ fi
+
+ gitrev=$(${GIT} rev-parse --verify --short HEAD)
+
+ add_footer_table "git revision" "${PATCH_BRANCH} / ${gitrev}"
+}
+
+## @description Put docker stats in various tables
+## @stability stable
+## @audience private
+## @replaceable yes
+function finish_docker_stats
+{
+ if [[ ${DOCKERMODE} == true ]]; then
+ # DOCKER_VERSION is set by our creator.
+ add_footer_table "Docker" "${DOCKER_VERSION}"
+ fi
+}
+
+## @description Put the max memory consumed by maven at the bottom of the table.
+## @audience private
+## @stability stable
+## @replaceable no
+function finish_footer_table
+{
+ local maxmem
+
+ # `sort | head` can cause a broken pipe error, but we can ignore it just like compute_gitdiff.
+ # shellcheck disable=SC2016,SC2086
+ maxmem=$(find "${PATCH_DIR}" -type f -exec ${AWK} 'match($0, /^\[INFO\] Final Memory: [0-9]+/)
+ { print substr($0, 22, RLENGTH-21) }' {} \; | sort -nr 2>/dev/null | head -n 1)
+
+ if [[ -n ${maxmem} ]]; then
+ add_footer_table "Max memory used" "${maxmem}MB"
+ fi
+}
+
+## @description Put the final elapsed time at the bottom of the table.
+## @audience private
+## @stability stable
+## @replaceable no
+function finish_vote_table
+{
+
+ local -r elapsed=$(stop_global_clock)
+ local calctime
+
+ calctime=$(clock_display "${elapsed}")
+
+ echo ""
+ echo "Total Elapsed time: ${calctime}"
+ echo ""
+
+ # shellcheck disable=SC2034
+ TP_VOTE_TABLE[${TP_VOTE_COUNTER}]="| | | ${calctime} | |"
+ ((TP_VOTE_COUNTER=TP_VOTE_COUNTER+1 ))
+}
+
+## @description Add to the footer of the display. @@BASE@@ will get replaced with the
+## @description correct location for the local filesystem in dev mode or the URL for
+## @description Jenkins mode.
+## @audience public
+## @stability stable
+## @replaceable no
+## @param subsystem
+## @param string
+function add_footer_table
+{
+ local subsystem=$1
+ shift 1
+
+ # shellcheck disable=SC2034
+ TP_FOOTER_TABLE[${TP_FOOTER_COUNTER}]="| ${subsystem} | $* |"
+ ((TP_FOOTER_COUNTER=TP_FOOTER_COUNTER+1 ))
+}
+
+## @description Special table just for unit test failures
+## @audience public
+## @stability stable
+## @replaceable no
+## @param failurereason
+## @param testlist
+function add_test_table
+{
+ local failure=$1
+ shift 1
+
+ # shellcheck disable=SC2034
+ TP_TEST_TABLE[${TP_TEST_COUNTER}]="| ${failure} | $* |"
+ ((TP_TEST_COUNTER=TP_TEST_COUNTER+1 ))
+}
+
+## @description Large display for the user console
+## @audience public
+## @stability stable
+## @replaceable no
+## @param string
+## @return large chunk of text
+function big_console_header
+{
+ local text="$*"
+ local spacing=$(( (75+${#text}) /2 ))
+ printf "\n\n"
+ echo "============================================================================"
+ echo "============================================================================"
+ printf "%*s\n" ${spacing} "${text}"
+ echo "============================================================================"
+ echo "============================================================================"
+ printf "\n\n"
+}
+
+## @description Find the largest size of a column of an array
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return size
+function findlargest
+{
+ local column=$1
+ shift
+ local a=("$@")
+ local sizeofa=${#a[@]}
+ local i=0
+ local string
+ local maxlen=0
+
+ until [[ ${i} -eq ${sizeofa} ]]; do
+ # shellcheck disable=SC2086
+ string=$( echo ${a[$i]} | cut -f$((column + 1)) -d\| )
+ if [[ ${#string} -gt ${maxlen} ]]; then
+ maxlen=${#string}
+ fi
+ i=$((i+1))
+ done
+ echo "${maxlen}"
+}
+
+## @description Write the contents of a file to all of the bug systems
+## @description (so content should avoid special formatting)
+## @params filename
+## @stability stable
+## @audience public
+function write_comment
+{
+ local -r commentfile=${1}
+ declare bug
+
+ for bug in ${BUGCOMMENTS}; do
+ if declare -f ${bug}_write_comment >/dev/null; then
+ "${bug}_write_comment" "${commentfile}"
+ fi
+ done
+}
+
+## @description Verify that the patch directory is still in working order
+## @description since bad actors on some systems wipe it out. If not,
+## @description recreate it and then exit
+## @audience private
+## @stability evolving
+## @replaceable yes
+## @returns may exit on failure
+function verify_patchdir_still_exists
+{
+ local -r commentfile=/tmp/testpatch.$$.${RANDOM}
+ local extra=""
+
+ if [[ ! -d ${PATCH_DIR} ]]; then
+ rm "${commentfile}" 2>/dev/null
+
+ echo "(!) The patch artifact directory has been removed! " > "${commentfile}"
+ echo "This is a fatal error for test-patch.sh. Aborting. " >> "${commentfile}"
+ echo
+ cat ${commentfile}
+ echo
+ if [[ ${JENKINS} == true ]]; then
+ if [[ -n ${NODE_NAME} ]]; then
+ extra=" (node ${NODE_NAME})"
+ fi
+ echo "Jenkins${extra} information at ${BUILD_URL} may provide some hints. " >> "${commentfile}"
+
+ write_comment ${commentfile}
+ fi
+
+ rm "${commentfile}"
+ cleanup_and_exit "${RESULT}"
+ fi
+}
+
+## @description generate a list of all files and line numbers in $GITDIFFLINES that
+## @description that were added/changed in the source repo. $GITDIFFCONTENT
+## @description is same file, but also includes the content of those lines
+## @audience private
+## @stability stable
+## @replaceable no
+function compute_gitdiff
+{
+ local file
+ local line
+ local startline
+ local counter
+ local numlines
+ local actual
+ local content
+ local outfile="${PATCH_DIR}/computegitdiff.${RANDOM}"
+
+ pushd "${BASEDIR}" >/dev/null
+ ${GIT} add --all --intent-to-add
+ while read -r line; do
+ if [[ ${line} =~ ^\+\+\+ ]]; then
+ file="./"$(echo "${line}" | cut -f2- -d/)
+ continue
+ elif [[ ${line} =~ ^@@ ]]; then
+ startline=$(echo "${line}" | cut -f3 -d' ' | cut -f1 -d, | tr -d + )
+ numlines=$(echo "${line}" | cut -f3 -d' ' | cut -s -f2 -d, )
+ # if this is empty, then just this line
+ # if it is 0, then no lines were added and this part of the patch
+ # is strictly a delete
+ if [[ ${numlines} == 0 ]]; then
+ continue
+ elif [[ -z ${numlines} ]]; then
+ numlines=1
+ fi
+ counter=0
+ # it isn't obvious, but on MOST platforms under MOST use cases,
+ # this is faster than using sed, and definitely faster than using
+ # awk.
+ # http://unix.stackexchange.com/questions/47407/cat-line-x-to-line-y-on-a-huge-file
+ # has a good discussion w/benchmarks
+ #
+ # note that if tail is still sending data through the pipe, but head gets enough
+ # to do what was requested, head will exit, leaving tail with a broken pipe.
+ # we're going to send stderr to /dev/null and ignore the error since head's
+ # output is really what we're looking for
+ tail -n "+${startline}" "${file}" 2>/dev/null | head -n ${numlines} > "${outfile}"
+ oldifs=${IFS}
+ IFS=''
+ while read -r content; do
+ ((actual=counter+startline))
+ echo "${file}:${actual}:" >> "${GITDIFFLINES}"
+ printf "%s:%s:%s\n" "${file}" "${actual}" "${content}" >> "${GITDIFFCONTENT}"
+ ((counter=counter+1))
+ done < "${outfile}"
+ rm "${outfile}"
+ IFS=${oldifs}
+ fi
+ done < <("${GIT}" diff --unified=0 --no-color)
+
+ if [[ ! -f "${GITDIFFLINES}" ]]; then
+ touch "${GITDIFFLINES}"
+ fi
+
+ if [[ ! -f "${GITDIFFCONTENT}" ]]; then
+ touch "${GITDIFFCONTENT}"
+ fi
+
+ if [[ -s "${GITDIFFLINES}" ]]; then
+ compute_unidiff
+ else
+ touch "${GITUNIDIFFLINES}"
+ fi
+
+ popd >/dev/null
+}
+
+## @description generate an index of unified diff lines vs. modified/added lines
+## @description ${GITDIFFLINES} must exist.
+## @audience private
+## @stability stable
+## @replaceable no
+function compute_unidiff
+{
+ declare fn
+ declare filen
+ declare tmpfile="${PATCH_DIR}/tmp.$$.${RANDOM}"
+
+ # now that we know what lines are where, we can deal
+ # with github's pain-in-the-butt API. It requires
+ # that the client provides the line number of the
+ # unified diff on a per file basis.
+
+ # First, build a per-file unified diff, pulling
+ # out the 'extra' lines, grabbing the adds with
+ # the line number in the diff file along the way,
+ # finally rewriting the line so that it is in
+ # './filename:diff line:content' format
+
+ for fn in ${CHANGED_FILES}; do
+ filen=${fn##./}
+
+ if [[ -f "${filen}" ]]; then
+ ${GIT} diff ${filen} \
+ | tail -n +6 \
+ | ${GREP} -n '^+' \
+ | ${GREP} -vE '^[0-9]*:\+\+\+' \
+ | ${SED} -e 's,^\([0-9]*:\)\+,\1,g' \
+ -e s,^,./${filen}:,g \
+ >> "${tmpfile}"
+ fi
+ done
+
+ # at this point, tmpfile should be in the same format
+ # as gitdiffcontent, just with different line numbers.
+ # let's do a merge (using gitdifflines because it's easier)
+
+ # ./filename:real number:diff number
+ # shellcheck disable=SC2016
+ paste -d: "${GITDIFFLINES}" "${tmpfile}" \
+ | ${AWK} -F: '{print $1":"$2":"$5":"$6}' \
+ >> "${GITUNIDIFFLINES}"
+
+ rm "${tmpfile}"
+}
+
+## @description Print the command to be executing to the screen. Then
+## @description run the command, sending stdout and stderr to the given filename
+## @description This will also ensure that any directories in ${BASEDIR} have
+## @description the exec bit set as a pre-exec step.
+## @audience public
+## @stability stable
+## @param filename
+## @param command
+## @param [..]
+## @replaceable no
+## @returns $?
+function echo_and_redirect
+{
+ local logfile=$1
+ shift
+
+ verify_patchdir_still_exists
+
+ find "${BASEDIR}" -type d -exec chmod +x {} \;
+ # to the screen
+ echo "cd $(pwd)"
+ echo "${*} > ${logfile} 2>&1"
+ yetus_run_and_redirect "${logfile}" "${@}"
+}
+
+## @description is a given directory relative to BASEDIR?
+## @audience public
+## @stability stable
+## @replaceable yes
+## @param path
+## @returns 1 - no, path
+## @returns 0 - yes, path - BASEDIR
+function relative_dir
+{
+ local p=${1#${BASEDIR}}
+
+ if [[ ${#p} -eq ${#1} ]]; then
+ echo "${p}"
+ return 1
+ fi
+ p=${p#/}
+ echo "${p}"
+ return 0
+}
+
+## @description Print the usage information
+## @audience public
+## @stability stable
+## @replaceable no
+function yetus_usage
+{
+ local -r up=$(echo "${PROJECT_NAME}" | tr '[:lower:]' '[:upper:]')
+
+ echo "Usage: 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 "--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')"
+ # 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: ${HOW_TO_CONTRIBUTE} )"
+ 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 "--dockerfile=<file> Dockerfile fragment to use as the base"
+ 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 ""
+ 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
+ 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."
+
+ importplugins
+
+ for plugin in ${BUILDTOOLS} ${TESTTYPES} ${BUGSYSTEMS} ${TESTFORMATS}; do
+ if declare -f ${plugin}_usage >/dev/null 2>&1; then
+ echo
+ "${plugin}_usage"
+ fi
+ done
+}
+
+## @description Interpret the command line parameters
+## @audience private
+## @stability stable
+## @replaceable no
+## @params $@
+## @return May exit on failure
+function parse_args
+{
+ local i
+ local j
+
+ common_args "$@"
+
+ for i in "$@"; do
+ case ${i} in
+ --bugcomments=*)
+ BUGCOMMENTS=${i#*=}
+ BUGCOMMENTS=${BUGCOMMENTS//,/ }
+ ;;
+ --build-native=*)
+ BUILD_NATIVE=${i#*=}
+ ;;
+ --build-tool=*)
+ BUILDTOOL=${i#*=}
+ ;;
+ --build-url=*)
+ BUILD_URL=${i#*=}
+ ;;
+ --contrib-guide=*)
+ HOW_TO_CONTRIBUTE=${i#*=}
+ ;;
+ --dirty-workspace)
+ DIRTY_WORKSPACE=true
+ ;;
+ --docker)
+ DOCKERSUPPORT=true
+ ;;
+ --dockerfile=*)
+ DOCKERFILE=${i#*=}
+ ;;
+ --dockermode)
+ DOCKERMODE=true
+ ;;
+ --java-home=*)
+ JAVA_HOME=${i#*=}
+ ;;
+ --jenkins)
+ JENKINS=true
+ TEST_PARALLEL=${TEST_PARALLEL:-true}
+ INSTANCE=${EXECUTOR_NUMBER:-RANDOM}
+ ;;
+ --linecomments=*)
+ BUGLINECOMMENTS=${i#*=}
+ BUGLINECOMMENTS=${BUGLINECOMMENTS//,/ }
+ ;;
+ --modulelist=*)
+ USER_MODULE_LIST=${i#*=}
+ USER_MODULE_LIST=${USER_MODULE_LIST//,/ }
+ yetus_debug "Manually forcing modules ${USER_MODULE_LIST}"
+ ;;
+ --multijdkdirs=*)
+ JDK_DIR_LIST=${i#*=}
+ JDK_DIR_LIST=${JDK_DIR_LIST//,/ }
+ yetus_debug "Multi-JVM mode activated with ${JDK_DIR_LIST}"
+ ;;
+ --multijdktests=*)
+ JDK_TEST_LIST=${i#*=}
+ JDK_TEST_LIST=${JDK_TEST_LIST//,/ }
+ yetus_debug "Multi-JVM test list: ${JDK_TEST_LIST}"
+ ;;
+ --mv-patch-dir)
+ RELOCATE_PATCH_DIR=true;
+ ;;
+ --personality=*)
+ PERSONALITY=${i#*=}
+ ;;
+ --reexec)
+ REEXECED=true
+ ;;
+ --resetrepo)
+ RESETREPO=true
+ ;;
+ --run-tests)
+ RUN_TESTS=true
+ ;;
+ --skip-dirs=*)
+ MODULE_SKIPDIRS=${i#*=}
+ MODULE_SKIPDIRS=${MODULE_SKIPDIRS//,/ }
+ yetus_debug "Setting skipdirs to ${MODULE_SKIPDIRS}"
+ ;;
+ --summarize=*)
+ ALLOWSUMMARIES=${i#*=}
+ ;;
+ --test-parallel=*)
+ TEST_PARALLEL=${i#*=}
+ ;;
+ --test-threads=*)
+ # shellcheck disable=SC2034
+ TEST_THREADS=${i#*=}
+ ;;
+ --tpglobaltimer=*)
+ GLOBALTIMER=${i#*=}
+ ;;
+ --tpinstance=*)
+ INSTANCE=${i#*=}
+ EXECUTOR_NUMBER=${INSTANCE}
+ ;;
+ --tpperson=*)
+ REEXECPERSONALITY=${i#*=}
+ ;;
+ --tpreexectimer=*)
+ REEXECLAUNCHTIMER=${i#*=}
+ ;;
+ --*)
+ ## PATCH_OR_ISSUE can't be a --. So this is probably
+ ## a plugin thing.
+ continue
+ ;;
+ *)
+ PATCH_OR_ISSUE=${i}
+ ;;
+ esac
+ done
+
+ if [[ -n ${REEXECLAUNCHTIMER} ]]; then
+ TIMER=${REEXECLAUNCHTIMER};
+ else
+ start_clock
+ fi
+
+ if [[ ${REEXECED} == true
+ && ${DOCKERMODE} == true ]]; then
+ add_vote_table 0 reexec "docker + precommit patch detected."
+ elif [[ ${REEXECED} == true ]]; then
+ add_vote_table 0 reexec "precommit patch detected."
+ elif [[ ${DOCKERMODE} == true ]]; then
+ add_vote_table 0 reexec "docker mode."
+ fi
+
+ if [[ -z "${PATCH_OR_ISSUE}" ]]; then
+ yetus_usage
+ exit 1
+ fi
+
+ # we need absolute dir for ${BASEDIR}
+ cd "${STARTINGDIR}"
+ BASEDIR=$(cd -P -- "${BASEDIR}" >/dev/null && pwd -P)
+
+ if [[ -n ${USER_PATCH_DIR} ]]; then
+ PATCH_DIR="${USER_PATCH_DIR}"
+ fi
+
+ cd "${STARTINGDIR}"
+ if [[ ! -d ${PATCH_DIR} ]]; then
+ mkdir -p "${PATCH_DIR}"
+ if [[ $? == 0 ]] ; then
+ echo "${PATCH_DIR} has been created"
+ else
+ echo "Unable to create ${PATCH_DIR}"
+ cleanup_and_exit 1
+ fi
+ fi
+
+ # we need absolute dir for PATCH_DIR
+ PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
+
+ if [[ ${JENKINS} == "true" ]]; then
+ echo "Running in Jenkins mode"
+ ISSUE=${PATCH_OR_ISSUE}
+ RESETREPO=true
+ else
+ if [[ ${RESETREPO} == "true" ]] ; then
+ echo "Running in destructive (--resetrepo) developer mode"
+ else
+ echo "Running in developer mode"
+ fi
+ JENKINS=false
+ fi
+
+ if [[ -n "${USER_PLUGIN_DIR}" ]]; then
+ USER_PLUGIN_DIR=$(cd -P -- "${USER_PLUGIN_DIR}" >/dev/null && pwd -P)
+ fi
+
+ GITDIFFLINES="${PATCH_DIR}/gitdifflines.txt"
+ GITDIFFCONTENT="${PATCH_DIR}/gitdiffcontent.txt"
+ GITUNIDIFFLINES="${PATCH_DIR}/gitdiffunilines.txt"
+
+}
+
+## @description Locate the build file for a given directory
+## @audience private
+## @stability stable
+## @replaceable no
+## @return directory containing the buildfile. Nothing returned if not found.
+## @params buildfile
+## @params directory
+function find_buildfile_dir
+{
+ local buildfile=$1
+ local dir=$2
+
+ yetus_debug "Find ${buildfile} dir for: ${dir}"
+
+ while builtin true; do
+ if [[ -f "${dir}/${buildfile}" ]];then
+ echo "${dir}"
+ yetus_debug "Found: ${dir}"
+ return 0
+ elif [[ ${dir} == "." || ${dir} == "/" ]]; then
+ yetus_debug "ERROR: ${buildfile} is not found."
+ return 1
+ else
+ dir=$(dirname "${dir}")
+ fi
+ done
+}
+
+## @description List of files that ${PATCH_DIR}/patch modifies
+## @audience private
+## @stability stable
+## @replaceable no
+## @return None; sets ${CHANGED_FILES}
+function find_changed_files
+{
+ # get a list of all of the files that have been changed,
+ # except for /dev/null (which would be present for new files).
+ # Additionally, remove any a/ b/ patterns at the front of the patch filenames.
+ # shellcheck disable=SC2016
+ CHANGED_FILES=$(${AWK} 'function p(s){sub("^[ab]/","",s); if(s!~"^/dev/null"){print s}}
+ /^diff --git / { p($3); p($4) }
+ /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
+}
+
+## @description Check for directories to skip during
+## @description changed module calcuation
+## @audience private
+## @stability stable
+## @replaceable no
+## @params directory
+## @returns 0 for use
+## @returns 1 for skip
+function module_skipdir
+{
+ local dir=${1}
+ local i
+
+ yetus_debug "Checking skipdirs for ${dir}"
+
+ if [[ -z ${MODULE_SKIPDIRS} ]]; then
+ yetus_debug "Skipping skipdirs"
+ return 0
+ fi
+
+ while builtin true; do
+ for i in ${MODULE_SKIPDIRS}; do
+ if [[ ${dir} = "${i}" ]];then
+ yetus_debug "Found a skip: ${dir}"
+ return 1
+ fi
+ done
+ if [[ ${dir} == "." || ${dir} == "/" ]]; then
+ return 0
+ else
+ dir=$(dirname "${dir}")
+ yetus_debug "Trying to skip: ${dir}"
+ fi
+ done
+}
+
+## @description Find the modules of the build that ${PATCH_DIR}/patch modifies
+## @audience private
+## @stability stable
+## @replaceable no
+## @return None; sets ${CHANGED_MODULES} and ${CHANGED_UNFILTERED_MODULES}
+function find_changed_modules
+{
+ local i
+ local changed_dirs
+ local builddirs
+ local builddir
+ local module
+ local buildmods
+ local prev_builddir
+ local i=1
+ local dir
+ local buildfile
+
+ buildfile=$("${BUILDTOOL}_buildfile")
+
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: Unsupported build tool."
+ bugsystem_finalreport 1
+ cleanup_and_exit 1
+ fi
+
+ changed_dirs=$(for i in ${CHANGED_FILES}; do dirname "${i}"; done | sort -u)
+
+ # Empty string indicates the build system wants to disable module detection
+ if [[ -z ${buildfile} ]]; then
+ buiddirs="."
+ else
+ # Now find all the modules that were changed
+ for i in ${changed_dirs}; do
+
+ module_skipdir "${i}"
+ if [[ $? != 0 ]]; then
+ continue
+ fi
+
+ builddir=$(find_buildfile_dir "${buildfile}" "${i}")
+ if [[ -z ${builddir} ]]; then
+ yetus_error "ERROR: ${buildfile} is not found. Make sure the target is a ${BUILDTOOL}-based project."
+ bugsystem_finalreport 1
+ cleanup_and_exit 1
+ fi
+ builddirs="${builddirs} ${builddir}"
+ done
+ fi
+
+ #shellcheck disable=SC2086,SC2034
+ CHANGED_UNFILTERED_MODULES=$(echo ${builddirs} ${USER_MODULE_LIST} | tr ' ' '\n' | sort -u)
+ #shellcheck disable=SC2086,SC2116
+ CHANGED_UNFILTERED_MODULES=$(echo ${CHANGED_UNFILTERED_MODULES})
+
+ if [[ ${BUILDTOOL} = maven ]]; then
+ # Filter out modules without code
+ for module in ${builddirs}; do
+ ${GREP} "<packaging>pom</packaging>" "${module}/pom.xml" > /dev/null
+ if [[ "$?" != 0 ]]; then
+ buildmods="${buildmods} ${module}"
+ fi
+ done
+ else
+ buildmods=${CHANGED_UNFILTERED_MODULES}
+ fi
+
+ #shellcheck disable=SC2086,SC2034
+ CHANGED_MODULES=$(echo ${buildmods} ${USER_MODULE_LIST} | tr ' ' '\n' | sort -u)
+
+ # turn it back into a list so that anyone printing doesn't
+ # generate multiline output
+ #shellcheck disable=SC2086,SC2116
+ CHANGED_MODULES=$(echo ${CHANGED_MODULES})
+
+ yetus_debug "Locate the union of ${CHANGED_MODULES}"
+ # shellcheck disable=SC2086
+ count=$(echo ${CHANGED_MODULES} | wc -w)
+ if [[ ${count} -lt 2 ]]; then
+ yetus_debug "Only one entry, so keeping it ${CHANGED_MODULES}"
+ # shellcheck disable=SC2034
+ CHANGED_UNION_MODULES=${CHANGED_MODULES}
+ return
+ fi
+
+ i=1
+ while [[ ${i} -lt 100 ]]
+ do
+ module=$(echo "${CHANGED_MODULES}" | tr ' ' '\n' | cut -f1-${i} -d/ | uniq)
+ count=$(echo "${module}" | wc -w)
+ if [[ ${count} -eq 1
+ && -f ${module}/${buildfile} ]]; then
+ prev_builddir=${module}
+ elif [[ ${count} -gt 1 ]]; then
+ builddir=${prev_builddir}
+ break
+ fi
+ ((i=i+1))
+ done
+
+ if [[ -z ${builddir} ]]; then
+ builddir="."
+ fi
+
+ yetus_debug "Finding union of ${builddir}"
+ builddir=$(find_buildfile_dir "${buildfile}" "${builddir}" || true)
+
+ #shellcheck disable=SC2034
+ CHANGED_UNION_MODULES="${builddir}"
+}
+
+## @description git checkout the appropriate branch to test. Additionally, this calls
+## @description 'determine_branch' based upon the context provided
+## @description in ${PATCH_DIR} and in git after checkout.
+## @audience private
+## @stability stable
+## @replaceable no
+## @return 0 on success. May exit on failure.
+function git_checkout
+{
+ local currentbranch
+ local exemptdir
+ local status
+
+ big_console_header "Confirming git environment"
+
+ cd "${BASEDIR}"
+ if [[ ! -d .git ]]; then
+ yetus_error "ERROR: ${BASEDIR} is not a git repo."
+ cleanup_and_exit 1
+ fi
+
+ if [[ ${RESETREPO} == "true" ]] ; then
+
+ if [[ -d .git/rebase-apply ]]; then
+ yetus_error "ERROR: a previous rebase failed. Aborting it."
+ ${GIT} rebase --abort
+ fi
+
+ ${GIT} reset --hard
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: git reset is failing"
+ cleanup_and_exit 1
+ fi
+
+ # if PATCH_DIR is in BASEDIR, then we don't want
+ # git wiping it out.
+ exemptdir=$(relative_dir "${PATCH_DIR}")
+ if [[ $? == 1 ]]; then
+ ${GIT} clean -xdf
+ else
+ # we do, however, want it emptied of all _files_.
+ # we need to leave _directories_ in case we are in
+ # re-exec mode (which places a directory full of stuff in it)
+ yetus_debug "Exempting ${exemptdir} from clean"
+ rm "${PATCH_DIR}/*" 2>/dev/null
+ ${GIT} clean -xdf -e "${exemptdir}"
+ fi
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: git clean is failing"
+ cleanup_and_exit 1
+ fi
+
+ ${GIT} checkout --force "${PATCH_BRANCH_DEFAULT}"
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: git checkout --force ${PATCH_BRANCH_DEFAULT} is failing"
+ cleanup_and_exit 1
+ fi
+
+ determine_branch
+
+ # we need to explicitly fetch in case the
+ # git ref hasn't been brought in tree yet
+ if [[ ${OFFLINE} == false ]]; then
+
+ ${GIT} pull --rebase
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: git pull is failing"
+ cleanup_and_exit 1
+ fi
+ fi
+ # forcibly checkout this branch or git ref
+ ${GIT} checkout --force "${PATCH_BRANCH}"
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: git checkout ${PATCH_BRANCH} is failing"
+ cleanup_and_exit 1
+ fi
+
+ # if we've selected a feature branch that has new changes
+ # since our last build, we'll need to rebase to see those changes.
+ if [[ ${OFFLINE} == false ]]; then
+ ${GIT} pull --rebase
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: git pull is failing"
+ cleanup_and_exit 1
+ fi
+ fi
+
+ else
+
+ status=$(${GIT} status --porcelain)
+ if [[ "${status}" != "" && -z ${DIRTY_WORKSPACE} ]] ; then
+ yetus_error "ERROR: --dirty-workspace option not provided."
+ yetus_error "ERROR: can't run in a workspace that contains the following modifications"
+ yetus_error "${status}"
+ cleanup_and_exit 1
+ fi
+
+ determine_branch
+
+ currentbranch=$(${GIT} rev-parse --abbrev-ref HEAD)
+ if [[ "${currentbranch}" != "${PATCH_BRANCH}" ]];then
+ echo "WARNING: Current git branch is ${currentbranch} but patch is built for ${PATCH_BRANCH}."
+ echo "WARNING: Continuing anyway..."
+ PATCH_BRANCH=${currentbranch}
+ fi
+ fi
+
+ return 0
+}
+
+## @description Confirm the given branch is a git reference
+## @descriptoin or a valid gitXYZ commit hash
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param branch
+## @return 0 on success, if gitXYZ was passed, PATCH_BRANCH=xyz
+## @return 1 on failure
+function verify_valid_branch
+{
+ local check=$1
+ local i
+ local hash
+
+ # shortcut some common
+ # non-resolvable names
+ if [[ -z ${check} ]]; then
+ return 1
+ fi
+
+ if [[ ${check} =~ ^git ]]; then
+ hash=$(echo "${check}" | cut -f2- -dt)
+ if [[ -n ${hash} ]]; then
+ ${GIT} cat-file -t "${hash}" >/dev/null 2>&1
+ if [[ $? -eq 0 ]]; then
+ PATCH_BRANCH=${hash}
+ return 0
+ fi
+ return 1
+ else
+ return 1
+ fi
+ fi
+
+ ${GIT} show-ref "${check}" >/dev/null 2>&1
+ return $?
+}
+
+## @description Try to guess the branch being tested using a variety of heuristics
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success, with PATCH_BRANCH updated appropriately
+## @return 1 on failure, with PATCH_BRANCH updated to PATCH_BRANCH_DEFAULT
+function determine_branch
+{
+ declare bugs
+ declare retval=1
+
+ # something has already set this, so move on
+ if [[ -n ${PATCH_BRANCH} ]]; then
+ return
+ fi
+
+ pushd "${BASEDIR}" > /dev/null
+
+ yetus_debug "Determine branch"
+
+ # something has already set this, so move on
+ if [[ -n ${PATCH_BRANCH} ]]; then
+ return
+ fi
+
+ # developer mode, existing checkout, whatever
+ if [[ "${DIRTY_WORKSPACE}" == true ]];then
+ PATCH_BRANCH=$(${GIT} rev-parse --abbrev-ref HEAD)
+ echo "dirty workspace mode; applying against existing branch"
+ return
+ fi
+
+ for bugs in ${BUGSYSTEMS}; do
+ if declare -f ${bugs}_determine_branch >/dev/null;then
+ "${bugs}_determine_branch"
+ retval=$?
+ if [[ ${retval} == 0 ]]; then
+ break
+ fi
+ fi
+ done
+
+ if [[ ${retval} != 0 ]]; then
+ PATCH_BRANCH="${PATCH_BRANCH_DEFAULT}"
+ fi
+ popd >/dev/null
+}
+
+## @description Try to guess the issue being tested using a variety of heuristics
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success, with ISSUE updated appropriately
+## @return 1 on failure, with ISSUE updated to "Unknown"
+function determine_issue
+{
+ declare bugsys
+
+ yetus_debug "Determine issue"
+
+ for bugsys in ${BUGSYSTEMS}; do
+ if declare -f ${bugsys}_determine_issue >/dev/null; then
+ "${bugsys}_determine_issue" "${PATCH_OR_ISSUE}"
+ if [[ $? == 0 ]]; then
+ yetus_debug "${bugsys} says ${ISSUE}"
+ return 0
+ fi
+ fi
+ done
+ return 1
+}
+
+## @description Use some heuristics to determine which long running
+## @description tests to run
+## @audience private
+## @stability stable
+## @replaceable no
+function determine_needed_tests
+{
+ local i
+ local plugin
+
+ for i in ${CHANGED_FILES}; do
+ yetus_debug "Determining needed tests for ${i}"
+ personality_file_tests "${i}"
+
+ for plugin in ${TESTTYPES}; do
+ if declare -f ${plugin}_filefilter >/dev/null 2>&1; then
+ "${plugin}_filefilter" "${i}"
+ fi
+ done
+ done
+
+ add_footer_table "Optional Tests" "${NEEDED_TESTS}"
+}
+
+## @description Given ${PATCH_DIR}/patch, apply the patch
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return exit on failure
+function apply_patch_file
+{
+ big_console_header "Applying patch to ${PATCH_BRANCH}"
+
+ patchfile_apply_driver "${PATCH_DIR}/patch"
+ if [[ $? != 0 ]] ; then
+ echo "PATCH APPLICATION FAILED"
+ ((RESULT = RESULT + 1))
+ add_vote_table -1 patch "The patch command could not apply the patch."
+ bugsystem_finalreport 1
+ cleanup_and_exit 1
+ fi
+ return 0
+}
+
+## @description copy the test-patch binary bits to a new working dir,
+## @description setting USER_PLUGIN_DIR and PERSONALITY to the new
+## @description locations.
+## @description this is used for test-patch in docker and reexec mode
+## @audience private
+## @stability evolving
+## @replaceable no
+function copytpbits
+{
+ local dockerdir
+ local dockfile
+ local person
+ # we need to copy/consolidate all the bits that might have changed
+ # that are considered part of test-patch. This *might* break
+ # things that do off-path includes, but there isn't much we can
+ # do about that, I don't think.
+
+ # if we've already copied, then don't bother doing it again
+ if [[ ${STARTINGDIR} == ${PATCH_DIR}/precommit ]]; then
+ yetus_debug "Skipping copytpbits; already copied once"
+ return
+ fi
+
+ pushd "${STARTINGDIR}" >/dev/null
+ mkdir -p "${PATCH_DIR}/precommit/user-plugins"
+ mkdir -p "${PATCH_DIR}/precommit/personality"
+ mkdir -p "${PATCH_DIR}/precommit/test-patch-docker"
+
+ # copy our entire universe, preserving links, etc.
+ yetus_debug "copying '${BINDIR}' over to '${PATCH_DIR}/precommit'"
+ (cd "${BINDIR}"; tar cpf - . ) | (cd "${PATCH_DIR}/precommit"; tar xpf - )
+
+ if [[ -n "${USER_PLUGIN_DIR}"
+ && -d "${USER_PLUGIN_DIR}" ]]; then
+ yetus_debug "copying '${USER_PLUGIN_DIR}' over to ${PATCH_DIR}/precommit/user-plugins"
+ cp -pr "${USER_PLUGIN_DIR}/*" \
+ "${PATCH_DIR}/precommit/user-plugins"
+ fi
+ # Set to be relative to ${PATCH_DIR}/precommit
+ USER_PLUGIN_DIR="${PATCH_DIR}/precommit/user-plugins"
+
+ if [[ -n ${PERSONALITY}
+ && -f ${PERSONALITY} ]]; then
+ yetus_debug "copying '${PERSONALITY}' over to '${PATCH_DIR}/precommit/personality/provided.sh'"
+ cp -pr "${PERSONALITY}" "${PATCH_DIR}/precommit/personality/provided.sh"
+ fi
+
+ if [[ -n ${DOCKERFILE}
+ && -f ${DOCKERFILE} ]]; then
+ yetus_debug "copying '${DOCKERFILE}' over to '${PATCH_DIR}/precommit/test-patch-docker/Dockerfile'"
+ dockerdir=$(dirname "${DOCKERFILE}")
+ dockfile=$(basename "${DOCKERFILE}")
+ pushd "${dockerdir}" >/dev/null
+ gitfilerev=$("${GIT}" log -n 1 --pretty=format:%h -- "${dockfile}" 2>/dev/null)
+ popd >/dev/null
+ if [[ -z ${gitfilerev} ]]; then
+ gitfilerev=$(date "+%F")
+ gitfilerev="date${gitfilerev}"
+ fi
+ (
+ echo "### TEST_PATCH_PRIVATE: dockerfile=${DOCKERFILE}"
+ echo "### TEST_PATCH_PRIVATE: gitrev=${gitfilerev}"
+ cat "${DOCKERFILE}"
+ # make sure we put some space between, just in case last
+ # line isn't an empty line or whatever
+ printf "\n\n"
+ cat "${BINDIR}/test-patch-docker/Dockerfile-endstub"
+
+ printf "\n\n"
+ ) > "${PATCH_DIR}/precommit/test-patch-docker/Dockerfile"
+ DOCKERFILE="${PATCH_DIR}/precommit/test-patch-docker/Dockerfile"
+ fi
+
+ popd >/dev/null
+}
+
+## @description If this patches actually patches test-patch.sh, then
+## @description run with the patched version for the test.
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return none; otherwise relaunches
+function check_reexec
+{
+ local commentfile=${PATCH_DIR}/tp.${RANDOM}
+ local tpdir
+ local copy=false
+ local testdir
+ local person
+ local debugflag
+
+ if [[ ${REEXECED} == true ]]; then
+ big_console_header "Re-exec mode detected. Continuing."
+ return
+ fi
+
+ for testdir in "${BINDIR}" \
+ "${PERSONALITY}" \
+ "${USER_PLUGIN_DIR}" \
+ "${DOCKERFILE}"; do
+ tpdir=$(relative_dir "${testdir}")
+ if [[ $? == 0
+ && ${CHANGED_FILES} =~ ${tpdir} ]]; then
+ copy=true
+ fi
+ done
+
+ if [[ ${copy} == true ]]; then
+ big_console_header "precommit patch detected"
+
+ if [[ ${RESETREPO} == false ]]; then
+ ((RESULT = RESULT + 1))
+ yetus_debug "can't destructively change the working directory. run with '--resetrepo' please. :("
+ add_vote_table -1 precommit "Couldn't test precommit changes because we aren't configured to destructively change the working directory."
+ else
+
+ apply_patch_file
+
+ if [[ ${JENKINS} == true ]]; then
+ rm "${commentfile}" 2>/dev/null
+ echo "(!) A patch to the testing environment has been detected. " > "${commentfile}"
+ echo "Re-executing against the patched versions to perform further tests. " >> "${commentfile}"
+ echo "The console is at ${BUILD_URL}console in case of problems." >> "${commentfile}"
+ write_comment "${commentfile}"
+ rm "${commentfile}"
+ fi
+ fi
+ fi
+
+ if [[ ${DOCKERSUPPORT} == false
+ && ${copy} == false ]]; then
+ return
+ fi
+
+ if [[ ${DOCKERSUPPORT} == true
+ && ${copy} == false ]]; then
+ big_console_header "Re-execing under Docker"
+ fi
+
+ # copy our universe
+ copytpbits
+
+ if [[ ${DOCKERSUPPORT} == true ]]; then
+ # if we are doing docker, then we re-exec, but underneath the
+ # container
+
+ if declare -f ${BUILDTOOL}_docker_support >/dev/null; then
+ "${BUILDTOOL}_docker_support"
+ fi
+
+ client=$(docker version | grep 'Client version' | cut -f2 -d: | tr -d ' ')
+ server=$(docker version | grep 'Server version' | cut -f2 -d: | tr -d ' ')
+
+ dockerversion="Client=${client} Server=${server}"
+
+ TESTPATCHMODE="${USER_PARAMS[*]}"
+ if [[ -n "${BUILD_URL}" ]]; then
+ TESTPATCHMODE="--build-url=${BUILD_URL} ${TESTPATCHMODE}"
+ fi
+ TESTPATCHMODE="--tpglobaltimer=${GLOBALTIMER} ${TESTPATCHMODE}"
+ TESTPATCHMODE="--tpreexectimer=${TIMER} ${TESTPATCHMODE}"
+ TESTPATCHMODE="--tpinstance=${INSTANCE} ${TESTPATCHMODE}"
+ TESTPATCHMODE="--tpperson=${PERSONALITY} ${TESTPATCHMODE}"
+ TESTPATCHMODE="--plugins=${ENABLED_PLUGINS// /,} ${TESTPATCHMODE}"
+ TESTPATCHMODE=" ${TESTPATCHMODE}"
+ export TESTPATCHMODE
+
+ patchdir=$(relative_dir "${PATCH_DIR}")
+
+ if [[ ${TP_SHELL_SCRIPT_DEBUG} = true ]]; then
+ debugflag="--debug"
+ fi
+
+ cd "${BASEDIR}"
+ #shellcheck disable=SC2093
+ exec bash "${PATCH_DIR}/precommit/test-patch-docker/test-patch-docker.sh" \
+ ${debugflag} \
+ --dockerversion="${dockerversion}" \
+ --java-home="${JAVA_HOME}" \
+ --patch-dir="${patchdir}" \
+ --project="${PROJECT_NAME}"
+
+ else
+
+ # if we aren't doing docker, then just call ourselves
+ # but from the new path with the new flags
+ #shellcheck disable=SC2093
+ cd "${PATCH_DIR}/precommit/"
+ exec "${PATCH_DIR}/precommit/test-patch.sh" \
+ "${USER_PARAMS[@]}" \
+ --reexec \
+ --basedir="${BASEDIR}" \
+ --branch="${PATCH_BRANCH}" \
+ --patch-dir="${PATCH_DIR}" \
+ --tpglobaltimer="${GLOBALTIMER}" \
+ --tpreexectimer="${TIMER}" \
+ --personality="${PERSONALITY}" \
+ --tpinstance="${INSTANCE}" \
+ --user-plugins="${USER_PLUGIN_DIR}"
+ fi
+}
+
+## @description Reset the test results
+## @audience public
+## @stability evolving
+## @replaceable no
+function modules_reset
+{
+ MODULE_STATUS=()
+ MODULE_STATUS_TIMER=()
+ MODULE_STATUS_MSG=()
+ MODULE_STATUS_LOG=()
+ MODULE_COMPILE_LOG=()
+}
+
+## @description Utility to print standard module errors
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param repostatus
+## @param testtype
+## @param mvncmdline
+function modules_messages
+{
+ local repostatus=$1
+ local testtype=$2
+ local summarymode=$3
+ shift 2
+ local modindex=0
+ local repo
+ local goodtime=0
+ local failure=false
+ local oldtimer
+ local statusjdk
+ local multijdkmode=false
+
+ if [[ ${repostatus} == branch ]]; then
+ repo=${PATCH_BRANCH}
+ else
+ repo="the patch"
+ fi
+
+ verify_multijdk_test "${testtype}"
+ if [[ $? == 1 ]]; then
+ multijdkmode=true
+ fi
+
+ oldtimer=${TIMER}
+
+ if [[ ${summarymode} == true
+ && ${ALLOWSUMMARIES} == true ]]; then
+
+ until [[ ${modindex} -eq ${#MODULE[@]} ]]; do
+
+ if [[ ${multijdkmode} == true ]]; then
+ statusjdk=${MODULE_STATUS_JDK[${modindex}]}
+ fi
+
+ if [[ "${MODULE_STATUS[${modindex}]}" == '+1' ]]; then
+ ((goodtime=goodtime + ${MODULE_STATUS_TIMER[${modindex}]}))
+ else
+ failure=true
+ start_clock
+ echo ""
+ echo "${MODULE_STATUS_MSG[${modindex}]}"
+ echo ""
+ offset_clock "${MODULE_STATUS_TIMER[${modindex}]}"
+ add_vote_table "${MODULE_STATUS[${modindex}]}" "${testtype}" "${MODULE_STATUS_MSG[${modindex}]}"
+ if [[ ${MODULE_STATUS[${modindex}]} == -1
+ && -n "${MODULE_STATUS_LOG[${modindex}]}" ]]; then
+ add_footer_table "${testtype}" "@@BASE@@/${MODULE_STATUS_LOG[${modindex}]}"
+ fi
+ fi
+ ((modindex=modindex+1))
+ done
+
+ if [[ ${failure} == false ]]; then
+ start_clock
+ offset_clock "${goodtime}"
+ add_vote_table +1 "${testtype}" "${repo} passed${statusjdk}"
+ fi
+ else
+ until [[ ${modindex} -eq ${#MODULE[@]} ]]; do
+ start_clock
+ echo ""
+ echo "${MODULE_STATUS_MSG[${modindex}]}"
+ echo ""
+ offset_clock "${MODULE_STATUS_TIMER[${modindex}]}"
+ add_vote_table "${MODULE_STATUS[${modindex}]}" "${testtype}" "${MODULE_STATUS_MSG[${modindex}]}"
+ if [[ ${MODULE_STATUS[${modindex}]} == -1
+ && -n "${MODULE_STATUS_LOG[${modindex}]}" ]]; then
+ add_footer_table "${testtype}" "@@BASE@@/${MODULE_STATUS_LOG[${modindex}]}"
+ fi
+ ((modindex=modindex+1))
+ done
+ fi
+ TIMER=${oldtimer}
+}
+
+## @description Add a test result
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param module
+## @param runtime
+function module_status
+{
+ local index=$1
+ local value=$2
+ local log=$3
+ shift 3
+
+ local jdk
+
+ jdk=$(report_jvm_version "${JAVA_HOME}")
+
+ if [[ -n ${index}
+ && ${index} =~ ^[0-9]+$ ]]; then
+ MODULE_STATUS[${index}]="${value}"
+ MODULE_STATUS_LOG[${index}]="${log}"
+ MODULE_STATUS_JDK[${index}]=" with JDK v${jdk}"
+ MODULE_STATUS_MSG[${index}]="${*}"
+ else
+ yetus_error "ASSERT: module_status given bad index: ${index}"
+ yetus_error "ASSERT: module_stats $*"
+ generate_stack
+ exit 1
+ fi
+}
+
+## @description run the tests for the queued modules
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param repostatus
+## @param testtype
+## @param mvncmdline
+function modules_workers
+{
+ local repostatus=$1
+ local testtype=$2
+ shift 2
+ local modindex=0
+ local fn
+ local savestart=${TIMER}
+ local savestop
+ local repo
+ local modulesuffix
+ local jdk=""
+ local jdkindex=0
+ local statusjdk
+ local result=0
+
+ if [[ ${repostatus} == branch ]]; then
+ repo=${PATCH_BRANCH}
+ else
+ repo="the patch"
+ fi
+
+ modules_reset
+
+ verify_multijdk_test "${testtype}"
+ if [[ $? == 1 ]]; then
+ jdk=$(report_jvm_version "${JAVA_HOME}")
+ statusjdk=" with JDK v${jdk}"
+ jdk="-jdk${jdk}"
+ jdk=${jdk// /}
+ yetus_debug "Starting MultiJDK mode${statusjdk} on ${testtype}"
+ fi
+
+ until [[ ${modindex} -eq ${#MODULE[@]} ]]; do
+ start_clock
+
+ fn=$(module_file_fragment "${MODULE[${modindex}]}")
+ fn="${fn}${jdk}"
+ modulesuffix=$(basename "${MODULE[${modindex}]}")
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ pushd "${BASEDIR}/${MODULE[${modindex}]}" >/dev/null
+ fi
+
+ if [[ ${modulesuffix} == . ]]; then
+ modulesuffix="root"
+ fi
+
+ if [[ $? != 0 ]]; then
+ echo "${BASEDIR}/${MODULE[${modindex}]} no longer exists. Skipping."
+ ((modindex=modindex+1))
+ continue
+ fi
+
+ # shellcheck disable=2086,2046
+ echo_and_redirect "${PATCH_DIR}/${repostatus}-${testtype}-${fn}.txt" \
+ $("${BUILDTOOL}_executor") \
+ ${MODULEEXTRAPARAM[${modindex}]//@@@MODULEFN@@@/${fn}} \
+ "${@//@@@MODULEFN@@@/${fn}}"
+
+ if [[ $? == 0 ]] ; then
+ module_status \
+ ${modindex} \
+ +1 \
+ "${repostatus}-${testtype}-${fn}.txt" \
+ "${modulesuffix} in ${repo} passed${statusjdk}."
+ else
+ module_status \
+ ${modindex} \
+ -1 \
+ "${repostatus}-${testtype}-${fn}.txt" \
+ "${modulesuffix} in ${repo} failed${statusjdk}."
+ ((result = result + 1))
+ fi
+
+ # compile is special
+ if [[ ${testtype} = compile ]]; then
+ MODULE_COMPILE_LOG[${modindex}]="${PATCH_DIR}/${repostatus}-${testtype}-${fn}.txt"
+ yetus_debug "Comile log set to ${MODULE_COMPILE_LOG[${modindex}]}"
+ fi
+
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${modindex}]=${savestop}
+ # shellcheck disable=SC2086
+ echo "Elapsed: $(clock_display ${savestop})"
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ popd >/dev/null
+ fi
+ ((modindex=modindex+1))
+ done
+
+ TIMER=${savestart}
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Reset the queue for tests
+## @audience public
+## @stability evolving
+## @replaceable no
+function clear_personality_queue
+{
+ yetus_debug "Personality: clear queue"
+ MODCOUNT=0
+ MODULE=()
+}
+
+## @description Build the queue for tests
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param module
+## @param profiles/flags/etc
+function personality_enqueue_module
+{
+ yetus_debug "Personality: enqueue $*"
+ local module=$1
+ shift
+
+ MODULE[${MODCOUNT}]=${module}
+ MODULEEXTRAPARAM[${MODCOUNT}]=${*}
+ ((MODCOUNT=MODCOUNT+1))
+}
+
+## @description Utility to push many tests into the failure list
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param testdesc
+## @param testlist
+function populate_test_table
+{
+ local reason=$1
+ shift
+ local first=""
+ local i
+
+ for i in "$@"; do
+ if [[ -z "${first}" ]]; then
+ add_test_table "${reason}" "${i}"
+ first="${reason}"
+ else
+ add_test_table " " "${i}"
+ fi
+ done
+}
+
+## @description Run and verify the output of the appropriate unit tests
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function check_unittests
+{
+ local i
+ local testsys
+ local test_logfile
+ local result=0
+ local -r savejavahome=${JAVA_HOME}
+ local multijdkmode=false
+ local jdk=""
+ local jdkindex=0
+ local statusjdk
+ local formatresult=0
+ local needlog
+ local unitlogs
+
+ verify_needed_test unit
+
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Running unit tests"
+
+ verify_multijdk_test unit
+ if [[ $? == 1 ]]; then
+ multijdkmode=true
+ fi
+
+ for jdkindex in ${JDK_DIR_LIST}; do
+ if [[ ${multijdkmode} == true ]]; then
+ JAVA_HOME=${jdkindex}
+ jdk=$(report_jvm_version "${JAVA_HOME}")
+ statusjdk="JDK v${jdk} "
+ jdk="-jdk${jdk}"
+ jdk=${jdk// /}
+ fi
+
+ personality_modules patch unit
+ "${BUILDTOOL}_modules_worker" patch unit
+
+ ((result=result+$?))
+
+ modules_messages patch unit false
+ if [[ ${result} == 0 ]]; then
+ continue
+ fi
+
+ i=0
+ until [[ $i -eq ${#MODULE[@]} ]]; do
+ module=${MODULE[${i}]}
+ fn=$(module_file_fragment "${module}")
+ fn="${fn}${jdk}"
+ test_logfile="${PATCH_DIR}/patch-unit-${fn}.txt"
+
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ pushd "${MODULE[${i}]}" >/dev/null
+ fi
+
+ needlog=0
+ for testsys in ${TESTFORMATS}; do
+ if declare -f ${testsys}_process_tests >/dev/null; then
+ yetus_debug "Calling ${testsys}_process_tests"
+ "${testsys}_process_tests" "${module}" "${test_logfile}" "${fn}"
+ formatresult=$?
+ ((result=result+formatresult))
+ if [[ "${formatresult}" != 0 ]]; then
+ needlog=1
+ fi
+ fi
+ done
+
+ if [[ ${needlog} == 1 ]]; then
+ unitlogs="${unitlogs} @@BASE@@/patch-unit-${fn}.txt"
+ fi
+
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ popd >/dev/null
+ fi
+
+ ((i=i+1))
+ done
+
+ done
+ JAVA_HOME=${savejavahome}
+
+ if [[ -n "${unitlogs}" ]]; then
+ add_footer_table "unit test logs" "${unitlogs}"
+ fi
+
+ if [[ ${JENKINS} == true ]]; then
+ add_footer_table "${statusjdk} Test Results" "${BUILD_URL}testReport/"
+ fi
+
+ for testsys in ${TESTFORMATS}; do
+ if declare -f ${testsys}_finalize_results >/dev/null; then
+ yetus_debug "Calling ${testsys}_finalize_results"
+ "${testsys}_finalize_results" "${statusjdk}"
+ fi
+ done
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Write comments onto bug systems that have code review support.
+## @description File should be in the form of "file:line:comment"
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param filename
+function bugsystem_linecomments
+{
+ declare title=$1
+ declare fn=$2
+ declare line
+ declare bugs
+ declare realline
+ declare text
+ declare idxline
+ declare uniline
+
+ if [[ ! -f "${GITUNIDIFFLINES}" ]]; then
+ return
+ fi
+
+ while read -r line;do
+ file=$(echo "${line}" | cut -f1 -d:)
+ realline=$(echo "${line}" | cut -f2 -d:)
+ text=$(echo "${line}" | cut -f3- -d:)
+ idxline="${file}:${realline}:"
+ uniline=$(${GREP} "${idxline}" "${GITUNIDIFFLINES}" | cut -f3 -d: )
+
+ for bugs in ${BUGLINECOMMENTS}; do
+ if declare -f ${bugs}_linecomments >/dev/null;then
+ "${bugs}_linecomments" "${title}" "${file}" "${realline}" "${uniline}" "${text}"
+ fi
+ done
+ done < "${fn}"
+}
+
+## @description Write the final output to the selected bug system
+## @audience private
+## @stability evolving
+## @replaceable no
+function bugsystem_finalreport
+{
+ declare bugs
+
+ add_footer_table "Powered by" "Apache Yetus http://yetus.apache.org"
+
+ for bugs in ${BUGCOMMENTS}; do
+ if declare -f ${bugs}_finalreport >/dev/null;then
+ "${bugs}_finalreport" "${@}"
+ fi
+ done
+}
+
+## @description Clean the filesystem as appropriate and then exit
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param runresult
+function cleanup_and_exit
+{
+ local result=$1
+
+ if [[ ${JENKINS} == "true" && ${RELOCATE_PATCH_DIR} == "true" && \
+ -e ${PATCH_DIR} && -d ${PATCH_DIR} ]] ; then
+ # if PATCH_DIR is already inside BASEDIR, then
+ # there is no need to move it since we assume that
+ # Jenkins or whatever already knows where it is at
+ # since it told us to put it there!
+ relative_dir "${PATCH_DIR}" >/dev/null
+ if [[ $? == 1 ]]; then
+ yetus_debug "mv ${PATCH_DIR} ${BASEDIR}"
+ mv "${PATCH_DIR}" "${BASEDIR}"
+ fi
+ fi
+ big_console_header "Finished build."
+
+ # shellcheck disable=SC2086
+ exit ${result}
+}
+
+## @description Driver to execute _tests routines
+## @audience private
+## @stability evolving
+## @replaceable no
+function runtests
+{
+ local plugin
+
+ ### Run tests for Jenkins or if explictly asked for by a developer
+ if [[ ${JENKINS} == "true" || ${RUN_TESTS} == "true" ]] ; then
+
+ verify_patchdir_still_exists
+ check_unittests
+
+ (( RESULT = RESULT + $? ))
+ fi
+
+ for plugin in ${TESTTYPES}; do
+ verify_patchdir_still_exists
+ if declare -f ${plugin}_tests >/dev/null 2>&1; then
+ modules_reset
+ yetus_debug "Running ${plugin}_tests"
+ #shellcheck disable=SC2086
+ ${plugin}_tests
+ (( RESULT = RESULT + $? ))
+ fi
+ done
+}
+
+## @description Calculate the differences between the specified files
+## @description and output it to stdout.
+## @audience public
+## @stability evolving
+## @replaceable no
+function calcdiffs
+{
+ local orig=$1
+ local new=$2
+ local tmp=${PATCH_DIR}/pl.$$.${RANDOM}
+ local count=0
+ local j
+
+ # first, pull out just the errors
+ # shellcheck disable=SC2016
+ ${AWK} -F: '{print $NF}' "${orig}" > "${tmp}.branch"
+
+ # shellcheck disable=SC2016
+ ${AWK} -F: '{print $NF}' "${new}" > "${tmp}.patch"
+
+ # compare the errors, generating a string of line
+ # numbers. Sorry portability: GNU diff makes this too easy
+ ${DIFF} --unchanged-line-format="" \
+ --old-line-format="" \
+ --new-line-format="%dn " \
+ "${tmp}.branch" \
+ "${tmp}.patch" > "${tmp}.lined"
+
+ # now, pull out those lines of the raw output
+ # shellcheck disable=SC2013
+ for j in $(cat "${tmp}.lined"); do
+ # shellcheck disable=SC2086
+ head -${j} "${new}" | tail -1
+ done
+
+ rm "${tmp}.branch" "${tmp}.patch" "${tmp}.lined" 2>/dev/null
+}
+
+
+## @description Helper routine for plugins to ask projects, etc
+## @description to count problems in a log file
+## @description and output it to stdout.
+## @audience public
+## @stability evolving
+## @replaceable no
+## @return number of issues
+function generic_count_probs
+{
+ declare testtype=$1
+ declare input=$2
+
+ if declare -f ${PROJECT_NAME}_${testtype}_count_probs >/dev/null; then
+ "${PROJECT_NAME}_${testtype}_count_probs" "${input}"
+ elif declare -f ${BUILDTOOL}_${testtype}_count_probs >/dev/null; then
+ "${BUILDTOOL}_${testtype}_count_probs" "${input}"
+ elif declare -f ${testtype}_count_probs >/dev/null; then
+ "${testtype}_count_probs" "${input}"
+ else
+ yetus_error "ERROR: ${testtype}: No function defined to count problems."
+ echo 0
+ fi
+}
+
+## @description Helper routine for plugins to do a pre-patch prun
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param testype
+## @param multijdk
+## @return 1 on failure
+## @return 0 on success
+function generic_pre_handler
+{
+ declare testtype=$1
+ declare multijdkmode=$2
+ declare result=0
+ declare -r savejavahome=${JAVA_HOME}
+ declare multijdkmode=false
+ declare jdkindex=0
+
+ verify_needed_test "${testtype}"
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Pre-patch ${testtype} verification on ${PATCH_BRANCH}"
+
+ verify_multijdk_test "${testtype}"
+ if [[ $? == 1 ]]; then
+ multijdkmode=true
+ fi
+
+ for jdkindex in ${JDK_DIR_LIST}; do
+ if [[ ${multijdkmode} == true ]]; then
+ JAVA_HOME=${jdkindex}
+ fi
+
+ personality_modules branch "${testtype}"
+ "${BUILDTOOL}_modules_worker" branch "${testtype}"
+
+ ((result=result + $?))
+ modules_messages branch "${testtype}" true
+
+ done
+ JAVA_HOME=${savejavahome}
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Generic post-patch log handler
+## @audience public
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+## @param origlog
+## @param testtype
+## @param multijdkmode
+function generic_postlog_compare
+{
+ declare origlog=$1
+ declare testtype=$2
+ declare multijdk=$3
+ declare result=0
+ declare i
+ declare fn
+ declare jdk
+ declare statusjdk
+
+ if [[ ${multijdk} == true ]]; then
+ jdk=$(report_jvm_version "${JAVA_HOME}")
+ statusjdk=" with JDK v${jdk}"
+ jdk="-jdk${jdk}"
+ jdk=${jdk// /}
+ fi
+
+ i=0
+ until [[ ${i} -eq ${#MODULE[@]} ]]; do
+ if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
+ ((result=result+1))
+ ((i=i+1))
+ continue
+ fi
+
+ fn=$(module_file_fragment "${MODULE[${i}]}")
+ fn="${fn}${jdk}"
+ module_suffix=$(basename "${MODULE[${i}]}")
+ if [[ ${module_suffix} == \. ]]; then
+ module_suffix=root
+ fi
+
+ yetus_debug "${testtype}: branch-${origlog}-${fn}.txt vs. patch-${origlog}-${fn}.txt"
+
+ # if it was a new module, this won't exist.
+ if [[ -f "${PATCH_DIR}/branch-${origlog}-${fn}.txt" ]]; then
+ ${GREP} -i warning "${PATCH_DIR}/branch-${origlog}-${fn}.txt" \
+ > "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt"
+ else
+ touch "${PATCH_DIR}/branch-${origlog}-${fn}.txt" \
+ "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt"
+ fi
+
+ if [[ -f "${PATCH_DIR}/patch-${origlog}-${fn}.txt" ]]; then
+ ${GREP} -i warning "${PATCH_DIR}/patch-${origlog}-${fn}.txt" \
+ > "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt"
+ else
+ touch "${PATCH_DIR}/patch-${origlog}-${fn}.txt" \
+ "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt"
+ fi
+
+ numbranch=$("generic_count_probs" "${testtype}" "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt")
+ numpatch=$("generic_count_probs" "${testtype}" "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt")
+
+ yetus_debug "${testtype}: old: ${numbranch} vs new: ${numpatch}"
+
+ if [[ -n ${numbranch}
+ && -n ${numpatch}
+ && ${numpatch} -gt ${numbranch} ]]; then
+
+ ${DIFF} -u "${PATCH_DIR}/branch-${testtype}-${fn}-warning.txt" \
+ "${PATCH_DIR}/patch-${testtype}-${fn}-warning.txt" \
+ > "${PATCH_DIR}/${testtype}-${fn}-diff.txt"
+
+ add_vote_table -1 "${testtype}" "${fn}${statusjdk} has problems."
+ add_footer_table "${testtype}" "${fn}: @@BASE@@/${testtype}-${fn}-diff.txt"
+
+ ((result=result+1))
+ fi
+ ((i=i+1))
+ done
+ modules_messages patch "${testtype}" true
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Generic post-patch handler
+## @audience public
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+## @param origlog
+## @param testtype
+## @param multijdkmode
+## @param run commands
+function generic_post_handler
+{
+ declare origlog=$1
+ declare testtype=$2
+ declare multijdkmode=$3
+ declare need2run=$4
+ declare i
+ declare result=0
+ declare fn
+ declare -r savejavahome=${JAVA_HOME}
+ declare jdk=""
+ declare jdkindex=0
+ declare statusjdk
+ declare -i numbranch=0
+ declare -i numpatch=0
+
+ verify_needed_test "${testtype}"
+ if [[ $? == 0 ]]; then
+ yetus_debug "${testtype} not needed"
+ return 0
+ fi
+
+ big_console_header "Patch ${testtype} verification"
+
+ for jdkindex in ${JDK_DIR_LIST}; do
+ if [[ ${multijdkmode} == true ]]; then
+ JAVA_HOME=${jdkindex}
+ yetus_debug "Using ${JAVA_HOME} to run this set of tests"
+ fi
+
+ if [[ ${need2run} = true ]]; then
+ personality_modules "${codebase}" "${testtype}"
+ "${BUILDTOOL}_modules_worker" "${codebase}" "${testtype}"
+
+ if [[ ${UNSUPPORTED_TEST} = true ]]; then
+ return 0
+ fi
+ fi
+
+ generic_postlog_compare "${origlog}" "${testtype}" "${multijdkmode}"
+ ((result=result+$?))
+ done
+ JAVA_HOME=${savejavahome}
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Execute the compile phase. This will callout
+## @description to _compile
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param branch|patch
+## @return 0 on success
+## @return 1 on failure
+function compile
+{
+ declare codebase=$1
+ declare result=0
+ declare -r savejavahome=${JAVA_HOME}
+ declare multijdkmode=false
+ declare jdkindex=0
+
+ verify_needed_test compile
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ if [[ ${codebase} = "branch" ]]; then
+ big_console_header "Pre-patch ${PATCH_BRANCH} compilation"
+ else
+ big_console_header "Patch compilation"
+ fi
+
+ verify_multijdk_test compile
+ if [[ $? == 1 ]]; then
+ multijdkmode=true
+ fi
+
+ for jdkindex in ${JDK_DIR_LIST}; do
+ if [[ ${multijdkmode} == true ]]; then
+ JAVA_HOME=${jdkindex}
+ fi
+
+ personality_modules "${codebase}" compile
+ "${BUILDTOOL}_modules_worker" "${codebase}" compile
+ modules_messages "${codebase}" compile true
+
+ for plugin in ${TESTTYPES}; do
+ verify_patchdir_still_exists
+ if declare -f ${plugin}_compile >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_compile ${codebase} ${multijdkmode}"
+ "${plugin}_compile" "${codebase}" "${multijdkmode}"
+ ((result = result + $?))
+ fi
+ done
+
+ done
+ JAVA_HOME=${savejavahome}
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Execute the static analysis test cycle.
+## @description This will callout to _precompile, compile, _postcompile and _rebuild
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param branch|patch
+## @return 0 on success
+## @return 1 on failure
+function compile_cycle
+{
+ declare codebase=$1
+ declare result=0
+ declare plugin
+
+ find_changed_modules
+
+ for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
+ if declare -f ${plugin}_precompile >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_precompile"
+ #shellcheck disable=SC2086
+ ${plugin}_precompile ${codebase}
+ if [[ $? -gt 0 ]]; then
+ ((result = result+1))
+ fi
+ fi
+ done
+
+ compile "${codebase}"
+
+ for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
+ if declare -f ${plugin}_postcompile >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_postcompile"
+ #shellcheck disable=SC2086
+ ${plugin}_postcompile ${codebase}
+ if [[ $? -gt 0 ]]; then
+ ((result = result+1))
+ fi
+ fi
+ done
+
+ for plugin in ${PROJECT_NAME} ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
+ if declare -f ${plugin}_rebuild >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_rebuild"
+ #shellcheck disable=SC2086
+ ${plugin}_rebuild ${codebase}
+ if [[ $? -gt 0 ]]; then
+ ((result = result+1))
+ fi
+ fi
+ done
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Execute the patch file test phase. Calls out to
+## @description to _patchfile
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param branch|patch
+## @return 0 on success
+## @return 1 on failure
+function patchfiletests
+{
+ declare plugin
+ declare result=0
+
+ for plugin in ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
+ if declare -f ${plugin}_patchfile >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_patchfile"
+ #shellcheck disable=SC2086
+ ${plugin}_patchfile "${PATCH_DIR}/patch"
+ if [[ $? -gt 0 ]]; then
+ ((result = result+1))
+ fi
+ fi
+ done
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+
+## @description Wipe the repo clean to not invalidate tests
+## @audience public
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function distclean
+{
+ declare result=0
+ declare plugin
+
+ personality_modules branch distclean
+
+ for plugin in ${TESTTYPES} ${TESTFORMATS}; do
+ if declare -f ${plugin}_clean >/dev/null 2>&1; then
+ yetus_debug "Running ${plugin}_distclean"
+ #shellcheck disable=SC2086
+ ${plugin}_clean
+ if [[ $? -gt 0 ]]; then
+ ((result = result+1))
+ fi
+ fi
+ done
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Setup to execute
+## @audience public
+## @stability evolving
+## @replaceable no
+## @param $@
+## @return 0 on success
+## @return 1 on failure
+function initialize
+{
+ setup_defaults
+
+ parse_args "$@"
+
+ importplugins
+
+ parse_args_plugins "$@"
+
+ BUGCOMMENTS=${BUGCOMMENTS:-${BUGSYSTEMS}}
+ if [[ ! ${BUGCOMMENTS} =~ console ]]; then
+ BUGCOMMENTS="${BUGCOMMENTS} console"
+ fi
+
+ BUGLINECOMMENTS=${BUGLINECOMMENTS:-${BUGCOMMENTS}}
+
+ plugins_initialize
+
+ finish_docker_stats
+
+ locate_patch
+
+ # from here on out, we'll be in ${BASEDIR} for cwd
+ # plugins need to pushd/popd if they change.
+ git_checkout
+
+ patchfile_dryrun_driver "${PATCH_DIR}/patch"
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: ${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}."
+ cleanup_and_exit 1
+ fi
+
+ determine_issue
+ if [[ "${ISSUE}" == 'Unknown' ]]; then
+ echo "Testing patch on ${PATCH_BRANCH}."
+ else
+ echo "Testing ${ISSUE} patch on ${PATCH_BRANCH}."
+ fi
+
+ find_changed_files
+
+ check_reexec
+
+ determine_needed_tests
+
+ prepopulate_footer
+}
+
+## @description perform prechecks
+## @audience private
+## @stability evolving
+## @return exits on failure
+function prechecks
+{
+ declare plugin
+ declare result=0
+
+ for plugin in ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
+ verify_patchdir_still_exists
+
+ if declare -f ${plugin}_precheck >/dev/null 2>&1; then
+
+ yetus_debug "Running ${plugin}_precheck"
+ #shellcheck disable=SC2086
+ ${plugin}_precheck
+
+ (( result = result + $? ))
+ if [[ ${result} != 0 ]] ; then
+ bugsystem_finalreport 1
+ cleanup_and_exit 1
+ fi
+ fi
+ done
+}
+
+## @description import core library routines
+## @audience private
+## @stability evolving
+function import_core
+{
+ declare filename
+
+ for filename in "${BINDIR}/core.d"/*; do
+ # shellcheck disable=SC1091
+ # shellcheck source=core.d/00-yetuslib.sh
+ # shellcheck source=core.d/01-common.sh
+ . "${filename}"
+ done
+}
+
+###############################################################################
+###############################################################################
+###############################################################################
+
+import_core
+
+initialize "$@"
+
+prechecks
+
+patchfiletests
+((RESULT=RESULT+$?))
+
+compile_cycle branch
+((RESULT=RESULT+$?))
+
+distclean
+
+apply_patch_file
+
+compute_gitdiff
+
+compile_cycle patch
+((RESULT=RESULT+$?))
+
+runtests
+((RESULT=RESULT+$?))
+
+finish_vote_table
+
+finish_footer_table
+
+bugsystem_finalreport ${RESULT}
+cleanup_and_exit ${RESULT}
[05/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/core.d/builtin-bugsystem.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/builtin-bugsystem.sh b/precommit/core.d/builtin-bugsystem.sh
new file mode 100755
index 0000000..f6e25f1
--- /dev/null
+++ b/precommit/core.d/builtin-bugsystem.sh
@@ -0,0 +1,149 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# This bug system handles the output on the screen.
+
+add_bugsystem console
+
+## @description Print out the finished details on the console
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param runresult
+## @return 0 on success
+## @return 1 on failure
+function console_finalreport
+{
+ declare result=$1
+ shift
+ declare i=0
+ declare ourstring
+ declare vote
+ declare subs
+ declare ela
+ declare comment
+ declare commentfile1="${PATCH_DIR}/comment.1"
+ declare commentfile2="${PATCH_DIR}/comment.2"
+ declare normaltop
+ declare line
+ declare seccoladj=0
+ declare spcfx=${PATCH_DIR}/spcl.txt
+
+ if [[ ${result} == 0 ]]; then
+ if [[ ${JENKINS} == false ]]; then
+ if declare -f ${PROJECT_NAME}_console_success >/dev/null; then
+ ${PROJECT_NAME}_console_success > "${spcfx}"
+ else
+ {
+ printf "IF9fX18gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfIAovIF9fX3wg";
+ printf "XyAgIF8gIF9fXyBfX18gX19fICBfX18gX19ffCB8ClxfX18gXHwgfCB8IHwv";
+ printf "IF9fLyBfXy8gXyBcLyBfXy8gX198IHwKIF9fXykgfCB8X3wgfCAoX3wgKF98";
+ printf "ICBfXy9cX18gXF9fIFxffAp8X19fXy8gXF9fLF98XF9fX1xfX19cX19ffHxf";
+ printf "X18vX19fKF8pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg";
+ printf "ICAK";
+ } > "${spcfx}"
+ fi
+ fi
+ printf "\n\n+1 overall\n\n"
+ else
+ if [[ ${JENKINS} == false ]]; then
+ if declare -f ${PROJECT_NAME}_console_failure >/dev/null; then
+ ${PROJECT_NAME}_console_failure > "${spcfx}"
+ else
+ {
+ printf "IF9fX19fICAgICBfIF8gICAgICAgICAgICAgICAgXyAKfCAgX19ffF8gXyhf";
+ printf "KSB8XyAgIF8gXyBfXyBfX198IHwKfCB8XyAvIF9gIHwgfCB8IHwgfCB8ICdf";
+ printf "Xy8gXyBcIHwKfCAgX3wgKF98IHwgfCB8IHxffCB8IHwgfCAgX18vX3wKfF98";
+ printf "ICBcX18sX3xffF98XF9fLF98X3wgIFxfX18oXykKICAgICAgICAgICAgICAg";
+ printf "ICAgICAgICAgICAgICAgICAK"
+ } > "${spcfx}"
+ fi
+ fi
+ printf "\n\n-1 overall\n\n"
+ fi
+
+ if [[ -f ${spcfx} ]]; then
+ if which base64 >/dev/null 2>&1; then
+ base64 --decode "${spcfx}" 2>/dev/null
+ elif which openssl >/dev/null 2>&1; then
+ openssl enc -A -d -base64 -in "${spcfx}" 2>/dev/null
+ fi
+ echo
+ echo
+ rm "${spcfx}"
+ fi
+
+ seccoladj=$(findlargest 2 "${TP_VOTE_TABLE[@]}")
+ if [[ ${seccoladj} -lt 10 ]]; then
+ seccoladj=10
+ fi
+
+ seccoladj=$((seccoladj + 2 ))
+ i=0
+ until [[ $i -eq ${#TP_HEADER[@]} ]]; do
+ printf "%s\n" "${TP_HEADER[${i}]}"
+ ((i=i+1))
+ done
+
+ printf "| %s | %*s | %s | %s\n" "Vote" ${seccoladj} Subsystem Runtime "Comment"
+ echo "============================================================================"
+ i=0
+ until [[ $i -eq ${#TP_VOTE_TABLE[@]} ]]; do
+ ourstring=$(echo "${TP_VOTE_TABLE[${i}]}" | tr -s ' ')
+ vote=$(echo "${ourstring}" | cut -f2 -d\|)
+ subs=$(echo "${ourstring}" | cut -f3 -d\|)
+ ela=$(echo "${ourstring}" | cut -f4 -d\|)
+ comment=$(echo "${ourstring}" | cut -f5 -d\|)
+
+ echo "${comment}" | fold -s -w $((78-seccoladj-22)) > "${commentfile1}"
+ normaltop=$(head -1 "${commentfile1}")
+ ${SED} -e '1d' "${commentfile1}" > "${commentfile2}"
+
+ printf "| %4s | %*s | %-10s |%-s\n" "${vote}" ${seccoladj} \
+ "${subs}" "${ela}" "${normaltop}"
+ while read -r line; do
+ printf "| | %*s | | %-s\n" ${seccoladj} " " "${line}"
+ done < "${commentfile2}"
+
+ ((i=i+1))
+ rm "${commentfile2}" "${commentfile1}" 2>/dev/null
+ done
+
+ if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
+ seccoladj=$(findlargest 1 "${TP_TEST_TABLE[@]}")
+ printf "\n\n%*s | Tests\n" "${seccoladj}" "Reason"
+ i=0
+ until [[ $i -eq ${#TP_TEST_TABLE[@]} ]]; do
+ ourstring=$(echo "${TP_TEST_TABLE[${i}]}" | tr -s ' ')
+ vote=$(echo "${ourstring}" | cut -f2 -d\|)
+ subs=$(echo "${ourstring}" | cut -f3 -d\|)
+ printf "%*s | %s\n" "${seccoladj}" "${vote}" "${subs}"
+ ((i=i+1))
+ done
+ fi
+
+ printf "\n\n|| Subsystem || Report/Notes ||\n"
+ echo "============================================================================"
+ i=0
+
+ until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
+ comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
+ ${SED} -e "s,@@BASE@@,${PATCH_DIR},g")
+ printf "%s\n" "${comment}"
+ ((i=i+1))
+ done
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/core.d/builtin-personality.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/builtin-personality.sh b/precommit/core.d/builtin-personality.sh
new file mode 100755
index 0000000..1258d46
--- /dev/null
+++ b/precommit/core.d/builtin-personality.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+function personality_modules
+{
+ if declare -f "${BUILDTOOL}_builtin_personality_modules" >/dev/null; then
+ "${BUILDTOOL}_builtin_personality_modules" "$@"
+ fi
+}
+
+function personality_file_tests
+{
+ if declare -f "${BUILDTOOL}_builtin_personality_file_tests" >/dev/null; then
+ "${BUILDTOOL}_builtin_personality_file_tests" "$@"
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/core.d/patchfiles.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/patchfiles.sh b/precommit/core.d/patchfiles.sh
new file mode 100755
index 0000000..7bb2f8b
--- /dev/null
+++ b/precommit/core.d/patchfiles.sh
@@ -0,0 +1,330 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+## @description Use curl to download the patch as a last resort
+## @audience private
+## @stability evolving
+## @param patchloc
+## @param output
+## @return 0 got something
+## @return 1 error
+function generic_locate_patch
+{
+ declare input=$1
+ declare output=$2
+
+ if [[ "${OFFLINE}" == true ]]; then
+ yetus_debug "generic_locate_patch: offline, skipping"
+ return 1
+ fi
+
+ ${CURL} --silent \
+ --output "${output}" \
+ "${input}"
+ if [[ $? != 0 ]]; then
+ yetus_debug "generic_locate_patch: failed to download the patch."
+ return 1
+ fi
+ return 0
+}
+
+## @description Given a possible patch file, guess if it's a patch file
+## @description only using the more intense verify if we really need to
+## @audience private
+## @stability evolving
+## @param path to patch file to test
+## @return 0 we think it's a patch file
+## @return 1 we think it's not a patch file
+function guess_patch_file
+{
+ declare patch=$1
+ declare fileOutput
+
+ if [[ ! -f ${patch} ]]; then
+ return 1
+ fi
+
+ yetus_debug "Trying to guess if ${patch} is a patch file."
+ fileOutput=$("${FILE}" "${patch}")
+ if [[ $fileOutput =~ \ diff\ ]]; then
+ yetus_debug "file magic says it's a diff."
+ return 0
+ fi
+
+ fileOutput=$(head -n 1 "${patch}" | "${GREP}" -E "^(From [a-z0-9]* Mon Sep 17 00:00:00 2001)|(diff .*)|(Index: .*)$")
+ if [[ $? == 0 ]]; then
+ yetus_debug "first line looks like a patch file."
+ return 0
+ fi
+
+ patchfile_dryrun_driver "${patch}"
+}
+
+## @description Given ${PATCH_OR_ISSUE}, determine what type of patch file is in use,
+## @description and do the necessary work to place it into ${PATCH_DIR}/patch.
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure, may exit
+function locate_patch
+{
+ declare bugsys
+ declare patchfile=""
+ declare gotit=false
+
+ yetus_debug "locate patch"
+
+ if [[ -z "${PATCH_OR_ISSUE}" ]]; then
+ yetus_error "ERROR: No patch provided."
+ cleanup_and_exit 1
+ fi
+
+ echo "Processing: ${PATCH_OR_ISSUE}"
+ # it's a declarely provided file
+ if [[ -f ${PATCH_OR_ISSUE} ]]; then
+ patchfile="${PATCH_OR_ISSUE}"
+ else
+ # run through the bug systems. maybe they know?
+ for bugsys in ${BUGSYSTEMS}; do
+ if declare -f ${bugsys}_locate_patch >/dev/null 2>&1; then
+ "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
+ if [[ $? == 0 ]]; then
+ gotit=true
+ fi
+ fi
+ done
+
+ # ok, none of the bug systems know. let's see how smart we are
+ if [[ ${gotit} == false ]]; then
+ generic_locate_patch "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
+ if [[ $? != 0 ]]; then
+ yetus_error "ERROR: Unsure how to process ${PATCH_OR_ISSUE}."
+ cleanup_and_exit 1
+ fi
+ fi
+ fi
+
+ if [[ ! -f "${PATCH_DIR}/patch"
+ && -f "${patchfile}" ]]; then
+ cp "${patchfile}" "${PATCH_DIR}/patch"
+ if [[ $? == 0 ]] ; then
+ echo "Patch file ${patchfile} copied to ${PATCH_DIR}"
+ else
+ yetus_error "ERROR: Could not copy ${patchfile} to ${PATCH_DIR}"
+ cleanup_and_exit 1
+ fi
+ fi
+}
+
+## @description if patch-level zero, then verify we aren't
+## @description just adding files
+## @audience public
+## @stability stable
+## @param log filename
+## @replaceable no
+## @returns $?
+function patchfile_verify_zero
+{
+ declare logfile=$1
+ shift
+ declare dir
+ declare changed_files1
+ declare changed_files2
+ declare filename
+
+ # don't return /dev/null
+ # shellcheck disable=SC2016
+ changed_files1=$(${AWK} 'function p(s){if(s!~"^/dev/null"){print s}}
+ /^diff --git / { p($3); p($4) }
+ /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
+
+ # maybe we interpreted the patch wrong? check the log file
+ # shellcheck disable=SC2016
+ changed_files2=$(${GREP} -E '^[cC]heck' "${logfile}" \
+ | ${AWK} '{print $3}' \
+ | ${SED} -e 's,\.\.\.$,,g')
+
+ for filename in ${changed_files1} ${changed_files2}; do
+
+ # leading prefix = bad
+ if [[ ${filename} =~ ^(a|b)/ ]]; then
+ return 1
+ fi
+
+ # touching an existing file is proof enough
+ # that pl=0 is good
+ if [[ -f ${filename} ]]; then
+ return 0
+ fi
+
+ dir=$(dirname "${filename}" 2>/dev/null)
+ if [[ -n ${dir} && -d ${dir} ]]; then
+ return 0
+ fi
+ done
+
+ # ¯\_(ツ)_/¯ - no way for us to know, all new files with no prefix!
+ yetus_error "WARNING: Patch only adds files; using patch level ${PATCH_LEVEL}"
+ return 0
+}
+
+## @description git apply dryrun
+## @replaceable no
+## @audience private
+## @stability evolving
+## @param path to patch file to dryrun
+function gitapply_dryrun
+{
+ declare patchfile=$1
+ declare prefixsize=${2:-0}
+
+ while [[ ${prefixsize} -lt 4
+ && -z ${PATCH_METHOD} ]]; do
+ yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+ "${GIT}" apply --binary -v --check "-p${prefixsize}" "${patchfile}"
+ if [[ $? == 0 ]]; then
+ PATCH_LEVEL=${prefixsize}
+ PATCH_METHOD=gitapply
+ break
+ fi
+ ((prefixsize=prefixsize+1))
+ done
+
+ if [[ ${prefixsize} -eq 0 ]]; then
+ patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
+ if [[ $? != 0 ]]; then
+ PATCH_METHOD=""
+ PATCH_LEVEL=""
+ gitapply_dryrun "${patchfile}" 1
+ fi
+ fi
+}
+
+## @description patch patch dryrun
+## @replaceable no
+## @audience private
+## @stability evolving
+## @param path to patch file to dryrun
+function patchcmd_dryrun
+{
+ declare patchfile=$1
+ declare prefixsize=${2:-0}
+
+ while [[ ${prefixsize} -lt 4
+ && -z ${PATCH_METHOD} ]]; do
+ # shellcheck disable=SC2153
+ yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+ "${PATCH}" "-p${prefixsize}" -E --dry-run < "${patchfile}"
+ if [[ $? == 0 ]]; then
+ PATCH_LEVEL=${prefixsize}
+ PATCH_METHOD=patchcmd
+ break
+ fi
+ ((prefixsize=prefixsize+1))
+ done
+
+ if [[ ${prefixsize} -eq 0 ]]; then
+ patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"
+ if [[ $? != 0 ]]; then
+ PATCH_METHOD=""
+ PATCH_LEVEL=""
+ patchcmd_dryrun "${patchfile}" 1
+ fi
+ fi
+}
+
+## @description driver for dryrun methods
+## @replaceable no
+## @audience private
+## @stability evolving
+## @param path to patch file to dryrun
+function patchfile_dryrun_driver
+{
+ declare patchfile=$1
+ declare method
+
+ #shellcheck disable=SC2153
+ for method in "${PATCH_METHODS[@]}"; do
+ if declare -f ${method}_dryrun >/dev/null; then
+ "${method}_dryrun" "${patchfile}"
+ fi
+ if [[ -n ${PATCH_METHOD} ]]; then
+ break
+ fi
+ done
+
+ if [[ -n ${PATCH_METHOD} ]]; then
+ return 0
+ fi
+ return 1
+}
+
+## @description git patch apply
+## @replaceable no
+## @audience private
+## @stability evolving
+## @param path to patch file to apply
+function gitapply_apply
+{
+ declare patchfile=$1
+ declare extraopts
+
+ if [[ "${COMMITMODE}" = true ]]; then
+ extraopts="--whitespace=fix"
+ fi
+
+ echo "Applying the patch:"
+ yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-apply.log" \
+ "${GIT}" apply --binary ${extraopts} -v --stat --apply "-p${PATCH_LEVEL}" "${patchfile}"
+ ${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-apply.log"
+}
+
+## @description patch patch apply
+## @replaceable no
+## @audience private
+## @stability evolving
+## @param path to patch file to apply
+function patchcmd_apply
+{
+ declare patchfile=$1
+
+ echo "Applying the patch:"
+ yetus_run_and_redirect "${PATCH_DIR}/apply-patch-patch-apply.log" \
+ "${PATCH}" "-p${PATCH_LEVEL}" -E < "${patchfile}"
+ cat "${PATCH_DIR}/apply-patch-patch-apply.log"
+}
+
+## @description driver for patch apply methods
+## @replaceable no
+## @audience private
+## @stability evolving
+## @param path to patch file to apply
+function patchfile_apply_driver
+{
+ declare patchfile=$1
+
+ if declare -f ${PATCH_METHOD}_apply >/dev/null; then
+ "${PATCH_METHOD}_apply" "${patchfile}"
+ if [[ $? -gt 0 ]]; then
+ return 1
+ fi
+ else
+ yetus_error "ERROR: Patching method ${PATCH_METHOD} does not have a way to apply patches!"
+ return 1
+ fi
+ return 0
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/bigtop.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/bigtop.sh b/precommit/personality/bigtop.sh
new file mode 100755
index 0000000..3854f6b
--- /dev/null
+++ b/precommit/personality/bigtop.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+personality_plugins "all,-checkstyle,-findbugs"
+
+function personality_globals
+{
+ # shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=master
+ # shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^BIGTOP-[0-9]+$'
+ # shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE=""
+ # shellcheck disable=SC2034
+ BUILDTOOL=gradle
+ # shellcheck disable=SC2034
+ GITHUB_REPO="apache/bigtop"
+ # shellcheck disable=SC2034
+ BIGTOP_PUPPETSETUP=false
+}
+
+add_test_type bigtop
+
+function bigtop_usage
+{
+ echo "Bigtop specific:"
+ echo "--bigtop-puppet=[false|true] execute the bigtop puppet setup (needs sudo to root)"
+}
+
+function bigtop_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --bigtop-puppet=*)
+ BIGTOP_PUPPETSETUP=${i#*=}
+ ;;
+ esac
+ done
+}
+
+function bigtop_precheck_postinstall
+{
+ if [[ ${BIGTOP_PUPPETSETUP} = "true" ]]; then
+ pushd "${BASEDIR}" >/dev/null
+ echo_and_redirect "${PATCH_DIR}/bigtop-branch-toolchain.txt" "${GRADLEW}" toolchain
+ popd >/dev/null
+ fi
+}
+
+function bigtop_postapply_postinstall
+{
+ if [[ ${BIGTOP_PUPPETSETUP} = "true" ]]; then
+ pushd "${BASEDIR}" >/dev/null
+ echo_and_redirect "${PATCH_DIR}/bigtop-patch-toolchain.txt" "${GRADLEW}" toolchain
+ popd >/dev/null
+ fi
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/flink.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/flink.sh b/precommit/personality/flink.sh
new file mode 100755
index 0000000..356c76b
--- /dev/null
+++ b/precommit/personality/flink.sh
@@ -0,0 +1,115 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+personality_plugins "all"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=master
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^FLINK-[0-9]+$'
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/flink"
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE=""
+}
+
+add_test_type flinklib
+
+function flinklib_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.java$
+ || ${filename} =~ \.scala$
+ || ${filename} =~ pom.xml$ ]]; then
+ add_test flinklib
+ fi
+}
+
+function flinklib_count
+{
+ find "${BASEDIR}" \
+ | ${GREP} "/lib/" \
+ | ${GREP} -v "_qa_workdir" \
+ | wc -l
+}
+
+function flinklib_preapply
+{
+ start_clock
+ big_console_header "${PATCH_BRANCH} flink library dependencies"
+
+ verify_needed_test flinklib
+ if [[ $? == 0 ]]; then
+ echo "Patch does not need flinklib testing."
+ return 0
+ fi
+
+ pushd "${BASEDIR}" >/dev/null
+ echo_and_redirect "${PATCH_DIR}/branch-flinklib-root.txt" \
+ "${MAVEN}" "${MAVEN_ARGS[@]}" package -DskipTests -Dmaven.javadoc.skip=true -Ptest-patch
+ if [[ $? != 0 ]]; then
+ add_vote_table -1 flinklib "Unable to determine flink libs in ${PATCH_BRANCH}."
+ fi
+ FLINK_PRE_LIB_FILES=$(flinklib_count)
+ popd >/dev/null
+}
+
+function flinklib_postapply
+{
+ start_clock
+ big_console_header "Patch flink library dependencies"
+
+ verify_needed_test flinklib
+ if [[ $? == 0 ]]; then
+ echo "Patch does not need flinklib testing."
+ return 0
+ fi
+
+ pushd "${BASEDIR}" >/dev/null
+ echo_and_redirect "${PATCH_DIR}/patch-flinklib-root.txt" \
+ "${MAVEN}" "${MAVEN_ARGS[@]}" package -DskipTests -Dmaven.javadoc.skip=true -Ptest-patch
+ FLINK_POST_LIB_FILES=$(flinklib_count)
+ popd >/dev/null
+
+
+ if [[ "${FLINK_POST_LIB_FILES}" -gt "${FLINK_PRE_LIB_FILES}" ]]; then
+ add_vote_table -1 flinklib "Patch increases lib folder dependencies from " \
+ "${FLINK_PRE_LIB_FILES} to ${FLINK_POST_LIB_FILES}"
+ return 1
+ elif [[ "${FLINK_POST_LIB_FILES}" -eq "${FLINK_PRE_LIB_FILES}" ]]; then
+ add_vote_table 0 flinklib "Patch did not change lib dependencies" \
+ " (still ${FLINK_PRE_LIB_FILES})"
+ else
+ add_vote_table +1 flinklib "Patch decreases lib folder dependencies by " \
+ "$((FLINK_PRE_LIB_FILES-FLINK_POST_LIB_FILES))."
+ fi
+ return 0
+}
+
+function flinklib_rebuild
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ flinklib_preapply
+ else
+ flinklib_postinstall
+ fi
+}
+
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/geode.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/geode.sh b/precommit/personality/geode.sh
new file mode 100644
index 0000000..f16e431
--- /dev/null
+++ b/precommit/personality/geode.sh
@@ -0,0 +1,18 @@
+personality_plugins "all,-ant,-javac,-scalac,-scaladoc"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=develop
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/GEODE/How+to+Contribute"
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^(GEODE)-[0-9]+$'
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/incubator-geode"
+ #shellcheck disable=SC2034
+ BUILDTOOL=gradle
+# PYLINT_OPTIONS="--indent-string=' '"
+
+# HADOOP_MODULES=""
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/hadoop.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/hadoop.sh b/precommit/personality/hadoop.sh
new file mode 100755
index 0000000..f958f0c
--- /dev/null
+++ b/precommit/personality/hadoop.sh
@@ -0,0 +1,376 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Override these to match Apache Hadoop's requirements
+
+personality_plugins "all,-ant,-gradle,-scalac,-scaladoc"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=trunk
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE="https://wiki.apache.org/hadoop/HowToContribute"
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^(HADOOP|YARN|MAPREDUCE|HDFS)-[0-9]+$'
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/hadoop"
+ #shellcheck disable=SC2034
+ PYLINT_OPTIONS="--indent-string=' '"
+
+ HADOOP_MODULES=""
+}
+
+function hadoop_module_manipulation
+{
+ local startingmodules=${1:-normal}
+ local module
+ local hdfs_modules
+ local mapred_modules
+ local yarn_modules
+ local ordered_modules
+ local tools_modules
+ local passed_modules
+ local flags
+
+ yetus_debug "hmm in: ${startingmodules}"
+
+ if [[ ${startingmodules} = normal ]]; then
+ startingmodules=${CHANGED_MODULES}
+ elif [[ ${startingmodules} = union ]]; then
+ startingmodules=${CHANGED_UNION_MODULES}
+ fi
+
+ yetus_debug "hmm expanded to: ${startingmodules}"
+
+ if [[ ${startingmodules} = "." ]]; then
+ yetus_debug "hmm shortcut since ."
+ HADOOP_MODULES=.
+ return
+ fi
+
+ # ${startingmodules} is already sorted and uniq'd.
+ # let's remove child modules if we're going to
+ # touch their parent.
+ passed_modules=${startingmodules}
+ for module in ${startingmodules}; do
+ yetus_debug "Stripping ${module}"
+ # shellcheck disable=SC2086
+ passed_modules=$(echo ${passed_modules} | tr ' ' '\n' | ${GREP} -v ${module}/ )
+ done
+
+ yetus_debug "hmm pre-ordering: ${startingmodules}"
+
+ # Hadoop's compilation rules are complex
+ # Precedence: common > [hdfs|yarn] > mapred > tools
+ # - everything depends upon common
+ # - hdfs needs common's native bits for unit tests
+ # - mapred depends upon yarn since it is a yarn app
+ # - tools can require anything
+
+ for module in ${passed_modules}; do
+ yetus_debug "Personality ordering ${module}"
+ if [[ ${module} = "." ]]; then
+ HADOOP_MODULES=.
+ break
+ fi
+
+ if [[ ${module} = hadoop-hdfs-project* ]]; then
+ hdfs_modules="${hdfs_modules} ${module}"
+ elif [[ ${module} = hadoop-common-project/hadoop-common
+ || ${module} = hadoop-common-project ]]; then
+ ordered_modules="${ordered_modules} ${module}"
+ elif [[ ${module} = hadoop-tools* ]]; then
+ tools_modules="${tools_modules} ${module}"
+ elif [[ ${module} = hadoop-mapreduce-project* ]]; then
+ mapred_modules="${mapred_modules} ${module}"
+ elif [[ ${module} = hadoop-yarn-project* ]]; then
+ yarn_modules="${yarn_modules} ${module}"
+ else
+ ordered_modules="${ordered_modules} ${module}"
+ fi
+ done
+
+ HADOOP_MODULES="${ordered_modules} ${hdfs_modules} ${yarn_modules} ${mapred_modules} ${tools_modules}"
+
+ yetus_debug "hmm out: ${HADOOP_MODULES}"
+}
+
+function hadoop_unittest_prereqs
+{
+ local need_common=0
+ local building_common=0
+ local module
+ local flags
+ local fn
+
+ for module in ${HADOOP_MODULES}; do
+ if [[ ${module} = hadoop-hdfs-project* ]]; then
+ need_common=1
+ elif [[ ${module} = hadoop-common-project/hadoop-common
+ || ${module} = hadoop-common-project ]]; then
+ building_common=1
+ fi
+ done
+
+ if [[ ${need_common} -eq 1
+ && ${building_common} -eq 0 ]]; then
+ echo "unit test pre-reqs:"
+ module="hadoop-common-project/hadoop-common"
+ fn=$(module_file_fragment "${module}")
+ flags=$(hadoop_native_flags)
+ pushd "${BASEDIR}/${module}" >/dev/null
+ # shellcheck disable=SC2086
+ echo_and_redirect "${PATCH_DIR}/maven-unit-prereq-${fn}-install.txt" \
+ "${MAVEN}" "${MAVEN_ARGS[@]}" install -DskipTests ${flags}
+ popd >/dev/null
+ fi
+}
+
+function hadoop_native_flags
+{
+
+ if [[ ${BUILD_NATIVE} != true ]]; then
+ return
+ fi
+
+ # Based upon HADOOP-11937
+ #
+ # Some notes:
+ #
+ # - getting fuse to compile on anything but Linux
+ # is always tricky.
+ # - Darwin assumes homebrew is in use.
+ # - HADOOP-12027 required for bzip2 on OS X.
+ # - bzip2 is broken in lots of places.
+ # e.g, HADOOP-12027 for OS X. so no -Drequire.bzip2
+ #
+
+ # current build servers are pretty limited in
+ # what they support
+ if [[ ${JENKINS} = true
+ && ${DOCKERSUPPORT} = false ]]; then
+ # shellcheck disable=SC2086
+ echo -Pnative \
+ -Drequire.snappy -Drequire.openssl -Drequire.fuse \
+ -Drequire.test.libhadoop
+ return
+ fi
+
+ case ${OSTYPE} in
+ Linux)
+ # shellcheck disable=SC2086
+ echo -Pnative -Drequire.libwebhdfs \
+ -Drequire.snappy -Drequire.openssl -Drequire.fuse \
+ -Drequire.test.libhadoop
+ ;;
+ Darwin)
+ JANSSON_INCLUDE_DIR=/usr/local/opt/jansson/include
+ JANSSON_LIBRARY=/usr/local/opt/jansson/lib
+ export JANSSON_LIBRARY JANSSON_INCLUDE_DIR
+ # shellcheck disable=SC2086
+ echo \
+ -Pnative -Drequire.snappy \
+ -Drequire.openssl \
+ -Dopenssl.prefix=/usr/local/opt/openssl/ \
+ -Dopenssl.include=/usr/local/opt/openssl/include \
+ -Dopenssl.lib=/usr/local/opt/openssl/lib \
+ -Drequire.libwebhdfs -Drequire.test.libhadoop
+ ;;
+ *)
+ # shellcheck disable=SC2086
+ echo \
+ -Pnative \
+ -Drequire.snappy -Drequire.openssl \
+ -Drequire.libwebhdfs -Drequire.test.libhadoop
+ ;;
+ esac
+}
+
+function personality_modules
+{
+ local repostatus=$1
+ local testtype=$2
+ local extra=""
+ local ordering="normal"
+ local needflags=false
+ local flags
+ local fn
+ local i
+
+ yetus_debug "Personality: ${repostatus} ${testtype}"
+
+ clear_personality_queue
+
+ case ${testtype} in
+ asflicense)
+ # this is very fast and provides the full path if we do it from
+ # the root of the source
+ personality_enqueue_module .
+ return
+ ;;
+ checkstyle)
+ ordering="union"
+ extra="-DskipTests"
+ ;;
+ compile)
+ ordering="union"
+ extra="-DskipTests"
+ needflags=true
+
+ # if something in common changed, we build the whole world
+ if [[ ${CHANGED_MODULES} =~ hadoop-common ]]; then
+ yetus_debug "hadoop personality: javac + hadoop-common = ordering set to . "
+ ordering="."
+ fi
+ ;;
+ distclean)
+ ordering="."
+ extra="-DskipTests"
+ ;;
+ javadoc)
+ if [[ ${repostatus} = patch ]]; then
+ echo "javadoc pre-reqs:"
+ for i in hadoop-project \
+ hadoop-common-project/hadoop-annotations; do
+ fn=$(module_file_fragment "${i}")
+ pushd "${BASEDIR}/${i}" >/dev/null
+ echo "cd ${i}"
+ echo_and_redirect "${PATCH_DIR}/maven-${fn}-install.txt" \
+ "${MAVEN}" "${MAVEN_ARGS[@]}" install
+ popd >/dev/null
+ done
+ fi
+ extra="-Pdocs -DskipTests"
+ ;;
+ mvninstall)
+ extra="-DskipTests"
+ if [[ ${repostatus} = branch ]]; then
+ ordering=.
+ fi
+ ;;
+ unit)
+ if [[ ${TEST_PARALLEL} = "true" ]] ; then
+ extra="-Pparallel-tests"
+ if [[ -n ${TEST_THREADS:-} ]]; then
+ extra="${extra} -DtestsThreadCount=${TEST_THREADS}"
+ fi
+ fi
+ needflags=true
+ hadoop_unittest_prereqs
+
+ verify_needed_test javac
+ if [[ $? == 0 ]]; then
+ yetus_debug "hadoop: javac not requested"
+ verify_needed_test native
+ if [[ $? == 0 ]]; then
+ yetus_debug "hadoop: native not requested"
+ yetus_debug "hadoop: adding -DskipTests to unit test"
+ extra="-DskipTests"
+ fi
+ fi
+
+ verify_needed_test shellcheck
+ if [[ $? == 0
+ && ! ${CHANGED_FILES} =~ \.bats ]]; then
+ yetus_debug "hadoop: NO shell code change detected; disabling shelltest profile"
+ extra="${extra} -P!shelltest"
+ else
+ extra="${extra} -Pshelltest"
+ fi
+ ;;
+ *)
+ extra="-DskipTests"
+ ;;
+ esac
+
+ if [[ ${needflags} = true ]]; then
+ flags=$(hadoop_native_flags)
+ extra="${extra} ${flags}"
+ fi
+
+ hadoop_module_manipulation ${ordering}
+
+ for module in ${HADOOP_MODULES}; do
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module} ${extra}
+ done
+}
+
+function personality_file_tests
+{
+ local filename=$1
+
+ yetus_debug "Using Hadoop-specific personality_file_tests"
+
+ if [[ ${filename} =~ src/main/webapp ]]; then
+ yetus_debug "tests/webapp: ${filename}"
+ elif [[ ${filename} =~ \.sh
+ || ${filename} =~ \.cmd
+ || ${filename} =~ src/scripts
+ || ${filename} =~ src/test/scripts
+ ]]; then
+ yetus_debug "tests/shell: ${filename}"
+ add_test unit
+ elif [[ ${filename} =~ \.md$
+ || ${filename} =~ \.md\.vm$
+ || ${filename} =~ src/site
+ ]]; then
+ yetus_debug "tests/site: ${filename}"
+ add_test site
+ elif [[ ${filename} =~ \.c$
+ || ${filename} =~ \.cc$
+ || ${filename} =~ \.h$
+ || ${filename} =~ \.hh$
+ || ${filename} =~ \.proto$
+ || ${filename} =~ \.cmake$
+ || ${filename} =~ CMakeLists.txt
+ ]]; then
+ yetus_debug "tests/units: ${filename}"
+ add_test cc
+ add_test unit
+ add_test javac
+ elif [[ ${filename} =~ build.xml$
+ || ${filename} =~ pom.xml$
+ || ${filename} =~ \.java$
+ || ${filename} =~ src/main
+ ]]; then
+ yetus_debug "tests/javadoc+units: ${filename}"
+ add_test javac
+ add_test javadoc
+ add_test mvninstall
+ add_test unit
+ fi
+
+ if [[ ${filename} =~ src/test ]]; then
+ yetus_debug "tests"
+ add_test unit
+ fi
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ add_test findbugs
+ fi
+}
+
+function hadoop_console_success
+{
+ printf "IF9fX19fX19fX18gCjwgU3VjY2VzcyEgPgogLS0tLS0tLS0tLSAKIFwgICAg";
+ printf "IC9cICBfX18gIC9cCiAgXCAgIC8vIFwvICAgXC8gXFwKICAgICAoKCAgICBP";
+ printf "IE8gICAgKSkKICAgICAgXFwgLyAgICAgXCAvLwogICAgICAgXC8gIHwgfCAg";
+ printf "XC8gCiAgICAgICAgfCAgfCB8ICB8ICAKICAgICAgICB8ICB8IHwgIHwgIAog";
+ printf "ICAgICAgIHwgICBvICAgfCAgCiAgICAgICAgfCB8ICAgfCB8ICAKICAgICAg";
+ printf "ICB8bXwgICB8bXwgIAo"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/hbase.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/hbase.sh b/precommit/personality/hbase.sh
new file mode 100755
index 0000000..8451f17
--- /dev/null
+++ b/precommit/personality/hbase.sh
@@ -0,0 +1,236 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+personality_plugins "all"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=master
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^HBASE-[0-9]+$'
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/hbase"
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE=""
+
+ # All supported Hadoop versions that we want to test the compilation with
+ HBASE_HADOOP_VERSIONS="2.4.1 2.5.2 2.6.0"
+
+ # Override the maven options
+ MAVEN_OPTS="${MAVEN_OPTS:-"-Xmx3100M"}"
+}
+
+function personality_modules
+{
+ local repostatus=$1
+ local testtype=$2
+ local extra=""
+
+ yetus_debug "Personality: ${repostatus} ${testtype}"
+
+ clear_personality_queue
+
+ extra="-DHBasePatchProcess"
+
+ if [[ ${repostatus} == branch
+ && ${testtype} == mvninstall ]];then
+ personality_enqueue_module . ${extra}
+ return
+ fi
+
+ if [[ ${testtype} = findbugs ]]; then
+ for module in ${CHANGED_MODULES}; do
+ # skip findbugs on hbase-shell
+ if [[ ${module} == hbase-shell ]]; then
+ continue
+ else
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module} ${extra}
+ fi
+ done
+ return
+ fi
+
+ for module in ${CHANGED_MODULES}; do
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module} ${extra}
+ done
+}
+
+###################################################
+
+add_test_type hadoopcheck
+
+function hadoopcheck_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ add_test hadoopcheck
+ fi
+}
+
+function hadoopcheck_rebuild
+{
+ local repostatus=$1
+ local hadoopver
+ local logfile
+ local count
+ local result=0
+
+ if [[ "${repostatus}" = branch ]]; then
+ return 0
+ fi
+
+ big_console_header "Compiling against various Hadoop versions"
+
+ export MAVEN_OPTS="${MAVEN_OPTS}"
+ for hadoopver in ${HBASE_HADOOP_VERSIONS}; do
+ logfile="${PATCH_DIR}/patch-javac-${hadoopver}.txt"
+ echo_and_redirect "${logfile}" \
+ "${MAVEN}" clean install \
+ -DskipTests -DHBasePatchProcess \
+ -Dhadoop-two.version="${hadoopver}"
+ count=$(${GREP} -c ERROR "${logfile}")
+ if [[ ${count} -gt 0 ]]; then
+ add_vote_table -1 hadoopcheck "Patch causes ${count} errors with Hadoop v${hadoopver}."
+ ((result=result+1))
+ fi
+ done
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+
+ add_vote_table +1 hadoopcheck "Patch does not cause any errors with Hadoop ${HBASE_HADOOP_VERSIONS}."
+ return 0
+}
+
+######################################
+
+add_test_type hbaseprotoc
+
+function hbaseprotoc_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.proto$ ]]; then
+ add_test hbaseprotoc
+ fi
+}
+
+function hbaseprotoc_rebuild
+{
+ local i=0
+ local fn
+ local module
+ local logfile
+ local count
+ local result
+
+ if [[ "${repostatus}" = branch ]]; then
+ return 0
+ fi
+
+ verify_needed_test hbaseprotoc
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Patch HBase protoc plugin"
+
+ start_clock
+
+
+ personality_modules patch hbaseprotoc
+ modules_workers patch hbaseprotoc compile -DskipTests -Pcompile-protobuf -X -DHBasePatchProcess
+
+ # shellcheck disable=SC2153
+ until [[ $i -eq ${#MODULE[@]} ]]; do
+ if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
+ ((result=result+1))
+ ((i=i+1))
+ continue
+ fi
+ module=${MODULE[$i]}
+ fn=$(module_file_fragment "${module}")
+ logfile="${PATCH_DIR}/patch-hbaseprotoc-${fn}.txt"
+
+ count=$(${GREP} -c ERROR "${logfile}")
+
+ if [[ ${count} -gt 0 ]]; then
+ module_status ${i} -1 "patch-hbaseprotoc-${fn}.txt" "Patch generated "\
+ "${count} new protoc errors in ${module}."
+ ((result=result+1))
+ fi
+ ((i=i+1))
+ done
+
+ modules_messages patch hbaseprotoc true
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+######################################
+
+add_test_type hbaseanti
+
+function hbaseanti_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ add_test hbaseanti
+ fi
+}
+
+function hbaseanti_patchfile
+{
+ local patchfile=$1
+ local warnings
+ local result
+
+ verify_needed_test hbaseanti
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Checking for known anti-patterns"
+
+ start_clock
+
+ warnings=$(${GREP} 'new TreeMap<byte.*()' "${patchfile}")
+ if [[ ${warnings} -gt 0 ]]; then
+ add_vote_table -1 hbaseanti "" "The patch appears to have anti-pattern where BYTES_COMPARATOR was omitted: ${warnings}."
+ ((result=result+1))
+ fi
+
+ warnings=$(${GREP} 'import org.apache.hadoop.classification' "${patchfile}")
+ if [[ ${warnings} -gt 0 ]]; then
+ add_vote_table -1 hbaseanti "" "The patch appears use Hadoop classification instead of HBase: ${warnings}."
+ ((result=result+1))
+ fi
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+
+ add_vote_table +1 hbaseanti "" "Patch does not have any anti-patterns."
+ return 0
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/kafka.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/kafka.sh b/precommit/personality/kafka.sh
new file mode 100755
index 0000000..cc4bf09
--- /dev/null
+++ b/precommit/personality/kafka.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+personality_plugins "all,-checkstyle,-asflicense"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=trunk
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^KAFKA-[0-9]+$'
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE="http://kafka.apache.org/contributing.html"
+ # shellcheck disable=SC2034
+ BUILDTOOL=gradle
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/kafka"
+}
+
+function personality_modules
+{
+ declare repostatus=$1
+ declare testtype=$2
+ declare module
+ declare extra=""
+
+ yetus_debug "Using kafka personality_modules"
+ yetus_debug "Personality: ${repostatus} ${testtype}"
+
+ clear_personality_queue
+
+ case ${testtype} in
+ gradleboot)
+ # kafka's bootstrap is broken
+ if [[ ${testtype} == gradleboot ]]; then
+ pushd "${BASEDIR}" >/dev/null
+ echo_and_redirect "${PATCH_DIR}/kafka-configure-gradle.txt" gradle
+ popd >/dev/null
+ fi
+ ;;
+ compile)
+ extra="clean jar"
+ ;;
+ esac
+
+ for module in ${CHANGED_MODULES}; do
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module} ${extra}
+ done
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/pig.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/pig.sh b/precommit/personality/pig.sh
new file mode 100755
index 0000000..50ea52f
--- /dev/null
+++ b/precommit/personality/pig.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+personality_plugins "all"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=trunk
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^PIG-[0-9]+$'
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/pig"
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE=""
+ #shellcheck disable=SC2034
+ BUILDTOOL=ant
+}
+
+function personality_modules
+{
+ local repostatus=$1
+ local testtype=$2
+ local extra=""
+
+ yetus_debug "Personality: ${repostatus} ${testtype}"
+
+ clear_personality_queue
+
+ extra="-DPigPatchProcess= "
+
+ case ${testtype} in
+ findbugs)
+ # shellcheck disable=SC2034
+ ANT_FINDBUGSXML="${BASEDIR}/build/test/findbugs/pig-findbugs-report.xml"
+ extra="-Dfindbugs.home=${FINDBUGS_HOME}"
+ ;;
+ compile)
+ extra="${extra} -Djavac.args=-Xlint -Dcompile.c++=yes clean piggybank"
+ ;;
+ javadoc)
+ extra="${extra} -Dforrest.home=${FORREST_HOME}"
+ ;;
+ unit)
+ extra="${extra} -Dtest.junit.output.format=xml -Dcompile.c++=yes -Dtest.output=yes test-core"
+ ;;
+ esac
+
+ # shellcheck disable=SC2086
+ personality_enqueue_module . ${extra}
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/samza.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/samza.sh b/precommit/personality/samza.sh
new file mode 100755
index 0000000..131e73e
--- /dev/null
+++ b/precommit/personality/samza.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+personality_plugins "all,-checkstyle"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=master
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^SAMZA-[0-9]+$'
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/SAMZA/Contributor's+Corner"
+ # shellcheck disable=SC2034
+ BUILDTOOL=gradle
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/samza"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/tajo.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/tajo.sh b/precommit/personality/tajo.sh
new file mode 100755
index 0000000..aa5fc48
--- /dev/null
+++ b/precommit/personality/tajo.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+personality_plugins "all"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=master
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^TAJO-[0-9]+$'
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/tajo"
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/TAJO/How+to+Contribute+to+Tajo"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/personality/tez.sh
----------------------------------------------------------------------
diff --git a/precommit/personality/tez.sh b/precommit/personality/tez.sh
new file mode 100755
index 0000000..584865e
--- /dev/null
+++ b/precommit/personality/tez.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+personality_plugins "all"
+
+function personality_globals
+{
+ #shellcheck disable=SC2034
+ PATCH_BRANCH_DEFAULT=master
+ #shellcheck disable=SC2034
+ JIRA_ISSUE_RE='^TEZ-[0-9]+$'
+ #shellcheck disable=SC2034
+ GITHUB_REPO="apache/tez"
+ #shellcheck disable=SC2034
+ HOW_TO_CONTRIBUTE="https://cwiki.apache.org/confluence/display/TEZ/How+to+Contribute+to+Tez"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/smart-apply-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/smart-apply-patch.sh b/precommit/smart-apply-patch.sh
new file mode 100755
index 0000000..ee06030
--- /dev/null
+++ b/precommit/smart-apply-patch.sh
@@ -0,0 +1,251 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Make sure that bash version meets the pre-requisite
+
+if [[ -z "${BASH_VERSINFO}" ]] \
+ || [[ "${BASH_VERSINFO[0]}" -lt 3 ]] \
+ || [[ "${BASH_VERSINFO[0]}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then
+ echo "bash v3.2+ is required. Sorry."
+ exit 1
+fi
+
+this="${BASH_SOURCE-$0}"
+BINDIR=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+#shellcheck disable=SC2034
+QATESTMODE=false
+
+# dummy functions
+function add_vote_table
+{
+ true
+}
+
+function add_footer_table
+{
+ true
+}
+
+function big_console_header
+{
+ true
+}
+
+function add_test
+{
+ true
+}
+
+## @description Clean the filesystem as appropriate and then exit
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param runresult
+function cleanup_and_exit
+{
+ local result=$1
+
+ if [[ ${PATCH_DIR} =~ ^/tmp/yetus
+ && -d ${PATCH_DIR} ]]; then
+ rm -rf "${PATCH_DIR}"
+ fi
+
+ # shellcheck disable=SC2086
+ exit ${result}
+}
+
+## @description Setup the default global variables
+## @audience public
+## @stability stable
+## @replaceable no
+function setup_defaults
+{
+ common_defaults
+}
+
+## @description Print the usage information
+## @audience public
+## @stability stable
+## @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 ""
+ 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')"
+
+ importplugins
+
+ unset TESTFORMATS
+ unset TESTTYPES
+ unset BUILDTOOLS
+
+ for plugin in ${BUGSYSTEMS}; do
+ if declare -f ${plugin}_usage >/dev/null 2>&1; then
+ echo
+ "${plugin}_usage"
+ fi
+ done
+}
+
+## @description Interpret the command line parameters
+## @audience private
+## @stability stable
+## @replaceable no
+## @params $@
+## @return May exit on failure
+function parse_args
+{
+ local i
+
+ common_args "$@"
+
+ for i in "$@"; do
+ case ${i} in
+ --committer)
+ COMMITMODE=true
+ ;;
+ --dry-run)
+ PATCH_DRYRUNMODE=true
+ ;;
+ --*)
+ ## PATCH_OR_ISSUE can't be a --. So this is probably
+ ## a plugin thing.
+ continue
+ ;;
+ *)
+ PATCH_OR_ISSUE=${i#*=}
+ ;;
+ esac
+ done
+
+ if [[ ! -d ${PATCH_DIR} ]]; then
+ mkdir -p "${PATCH_DIR}"
+ if [[ $? != 0 ]] ; then
+ yetus_error "ERROR: Unable to create ${PATCH_DIR}"
+ cleanup_and_exit 1
+ fi
+ fi
+}
+
+## @description git am dryrun
+## @replaceable no
+## @audience private
+## @stability evolving
+function gitam_dryrun
+{
+
+ # there is no dryrun method for git-am, so just
+ # use apply instead.
+ gitapply_dryrun "$@"
+
+ if [[ ${PATCH_METHOD} = "gitapply" ]]; then
+ PATCH_METHOD="gitam"
+ fi
+}
+
+## @description git am signoff
+## @replaceable no
+## @audience private
+## @stability evolving
+function gitam_apply
+{
+ declare patchfile=$1
+
+ echo "Applying the patch:"
+ yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-am.log" \
+ "${GIT}" am --signoff --whitespace=fix "-p${PATCH_LEVEL}" "${patchfile}"
+ ${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-am.log"
+}
+
+## @description import core library routines
+## @audience private
+## @stability evolving
+function import_core
+{
+ declare filename
+
+ for filename in "${BINDIR}/core.d"/*; do
+ # shellcheck disable=SC1091
+ # shellcheck source=core.d/01-common.sh
+ . "${filename}"
+ done
+}
+
+trap "cleanup_and_exit 1" HUP INT QUIT TERM
+
+import_core
+
+setup_defaults
+
+parse_args "$@"
+
+importplugins
+yetus_debug "Removing BUILDTOOLS, TESTTYPES, and TESTFORMATS from installed plug-in list"
+unset BUILDTOOLS
+unset TESTTYPES
+unset TESTFORMATS
+
+parse_args_plugins "$@"
+
+plugins_initialize
+
+locate_patch
+
+if [[ ${COMMITMODE} = true ]]; then
+ PATCH_METHODS=("gitam" "${PATCH_METHODS[@]}")
+fi
+
+patchfile_dryrun_driver "${PATCH_DIR}/patch"
+RESULT=$?
+
+if [[ ${RESULT} -gt 0 ]]; then
+ yetus_error "ERROR: Aborting! ${PATCH_OR_ISSUE} cannot be verified."
+ cleanup_and_exit ${RESULT}
+fi
+
+if [[ ${PATCH_DRYRUNMODE} == false ]]; then
+ patchfile_apply_driver "${PATCH_DIR}/patch"
+ RESULT=$?
+fi
+
+if [[ ${COMMITMODE} = true
+ && ${PATCH_METHOD} != "gitam" ]]; then
+ yetus_debug "Running git add -A"
+ git add -A
+fi
+
+cleanup_and_exit ${RESULT}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch-docker/Dockerfile-endstub
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/Dockerfile-endstub b/precommit/test-patch-docker/Dockerfile-endstub
new file mode 100644
index 0000000..aa0463e
--- /dev/null
+++ b/precommit/test-patch-docker/Dockerfile-endstub
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ADD launch-test-patch.sh /testptch/launch-test-patch.sh
+RUN chmod a+rx /testptch/launch-test-patch.sh
+CMD /testptch/launch-test-patch.sh
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch-docker/Dockerfile-startstub
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/Dockerfile-startstub b/precommit/test-patch-docker/Dockerfile-startstub
new file mode 100644
index 0000000..d191285
--- /dev/null
+++ b/precommit/test-patch-docker/Dockerfile-startstub
@@ -0,0 +1,91 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu:trusty
+
+WORKDIR /root
+
+######
+# Install common dependencies from packages
+######
+RUN apt-get update && apt-get install --no-install-recommends -y \
+ git curl ant make maven \
+ cmake gcc g++ protobuf-compiler \
+ build-essential libtool \
+ zlib1g-dev pkg-config libssl-dev \
+ snappy libsnappy-dev \
+ bzip2 libbz2-dev \
+ libjansson-dev \
+ fuse libfuse-dev \
+ libcurl4-openssl-dev \
+ python python2.7 pylint \
+ ruby \
+ openjdk-7-jdk \
+ libperl-critic-perl
+
+# Fixing the Apache commons / Maven dependency problem under Ubuntu:
+# See http://wiki.apache.org/commons/VfsProblems
+RUN cd /usr/share/maven/lib && ln -s ../../java/commons-lang.jar .
+
+#######
+# Oracle Java
+#######
+
+RUN apt-get install -y software-properties-common
+RUN add-apt-repository -y ppa:webupd8team/java
+RUN apt-get update
+
+
+# Auto-accept the Oracle JDK license
+RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
+RUN apt-get install -y oracle-java7-installer
+
+# Auto-accept the Oracle JDK license
+RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
+RUN apt-get install -y oracle-java8-installer
+
+######
+# Install findbugs
+######
+RUN mkdir -p /opt/findbugs && \
+ curl -L https://sourceforge.net/projects/findbugs/files/findbugs/3.0.1/findbugs-noUpdateChecks-3.0.1.tar.gz/download \
+ -o /opt/findbugs.tar.gz && \
+ tar xzf /opt/findbugs.tar.gz --strip-components 1 -C /opt/findbugs
+ENV FINDBUGS_HOME /opt/findbugs
+
+####
+# Install shellcheck
+####
+RUN apt-get install -y cabal-install
+RUN cabal update && cabal install shellcheck --global
+
+####
+# Install rubocop
+###
+RUN gem install rubocop
+
+####
+# Install ruby-lint
+###
+RUN gem install ruby-lint
+
+####
+# Install bats
+####
+RUN add-apt-repository -y ppa:duggan/bats
+RUN apt-get update
+RUN apt-get install -y bats
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/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
new file mode 100755
index 0000000..ac976ad
--- /dev/null
+++ b/precommit/test-patch-docker/launch-test-patch.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+cd "${BASEDIR}"
+
+if [[ -n ${JAVA_HOME}
+ && ! -d ${JAVA_HOME} ]]; then
+ echo "JAVA_HOME: ${JAVA_HOME} does not exist. Dockermode: attempting to switch to another." 1>&2
+ JAVA_HOME=""
+fi
+
+if [[ -z ${JAVA_HOME} ]]; then
+ JAVA_HOME=$(find /usr/lib/jvm/ -name "java-*" -type d | tail -1)
+ export JAVA_HOME
+fi
+
+# Avoid out of memory errors in builds
+MAVEN_OPTS=${MAVEN_OPTS:-"-Xms256m -Xmx1g"}
+export MAVEN_OPTS
+
+# strip out --docker param to prevent re-exec again
+TESTPATCHMODE=${TESTPATCHMODE/--docker }
+
+
+cd "${BASEDIR}"
+PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
+
+cd "${PATCH_DIR}/precommit/"
+#shellcheck disable=SC2086
+"${PATCH_DIR}/precommit/test-patch.sh" \
+ --reexec \
+ --dockermode ${TESTPATCHMODE} \
+ --basedir="${BASEDIR}" \
+ --patch-dir="${PATCH_DIR}" \
+ --java-home="${JAVA_HOME}" \
+ --personality="${PATCH_DIR}/precommit/personality/provided.sh" \
+ --user-plugins="${PATCH_DIR}/precommit/user-plugins"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch-docker/test-patch-docker.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/test-patch-docker.sh b/precommit/test-patch-docker/test-patch-docker.sh
new file mode 100755
index 0000000..8b19502
--- /dev/null
+++ b/precommit/test-patch-docker/test-patch-docker.sh
@@ -0,0 +1,388 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DID=${RANDOM}
+
+## @description Print a message to stderr if --debug is turned on
+## @audience private
+## @stability stable
+## @replaceable no
+## @param string
+function yetus_debug
+{
+ if [[ "${YETUS_SHELL_SCRIPT_DEBUG}" = true ]]; then
+ echo "[$(date) DEBUG]: $*" 1>&2
+ fi
+}
+
+## @description Run docker with some arguments, and
+## @description optionally send to debug
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function dockercmd
+{
+ yetus_debug "docker $*"
+ docker "$@"
+}
+
+## @description Handle command line arguments
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --debug)
+ YETUS_SHELL_SCRIPT_DEBUG=true
+ ;;
+ --dockerversion=*)
+ DOCKER_VERSION=${i#*=}
+ ;;
+ --help|-help|-h|help|--h|--\?|-\?|\?)
+ yetus_usage
+ exit 0
+ ;;
+ --java-home=*)
+ JAVA_HOME=${i#*=}
+ ;;
+ --patch-dir=*)
+ PATCH_DIR=${i#*=}
+ ;;
+ --project=*)
+ PROJECT_NAME=${i#*=}
+ ;;
+ *)
+ ;;
+ esac
+ done
+}
+
+## @description Stop and delete all defunct containers
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function stop_exited_containers
+{
+ local line
+ local id
+ local value
+ local size
+
+ echo "Docker containers in exit state:"
+
+ dockercmd ps -a | grep Exited
+
+ # stop *all* containers that are in exit state for
+ # more than > 8 hours
+ while read line; do
+ id=$(echo "${line}" | cut -f1 -d' ')
+ value=$(echo "${line}" | cut -f2 -d' ')
+ size=$(echo "${line}" | cut -f3 -d' ')
+
+ if [[ ${size} =~ day
+ || ${size} =~ week
+ || ${size} =~ month
+ || ${size} =~ year ]]; then
+ echo "Removing docker ${id}"
+ dockercmd rm "${id}"
+ fi
+
+ if [[ ${size} =~ hours
+ && ${value} -gt 8 ]]; then
+ echo "Removing docker ${id}"
+ dockercmd rm "${id}"
+ fi
+ done < <(
+ dockercmd ps -a \
+ | grep Exited \
+ | sed -e 's,ago,,g' \
+ | awk '{print $1" "$(NF - 2)" "$(NF - 1)}')
+}
+
+## @description Remove all containers that are not
+## @description are not running + older than 1 day
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function rm_old_containers
+{
+ local line
+ local id
+ local value
+ local size
+
+ while read line; do
+ id=$(echo "${line}" | cut -f1 -d, )
+ state=$(echo "${line}" | cut -f2 -d, )
+ stoptime=$(echo "${line}" | cut -f3 -d, | cut -f1 -d. )
+
+ # believe it or not, date is not even close to standardized...
+ if [[ $(uname -s) == Linux ]]; then
+
+ # GNU date
+ stoptime=$(date -d "${stoptime}" "+%s")
+ else
+
+ # BSD date
+ stoptime=$(date -j -f "%Y-%m-%dT%H:%M:%S" "${stoptime}" "+%s")
+ fi
+
+ if [[ ${state} == false ]]; then
+ curtime=$(date "+%s")
+ ((difftime = curtime - stoptime))
+ if [[ ${difftime} -gt 86400 ]]; then
+ echo "Removing docker ${id}"
+ dockercmd rm "${id}"
+ fi
+ fi
+ done < <(
+ # see https://github.com/koalaman/shellcheck/issues/375
+ # shellcheck disable=SC2046
+ dockercmd inspect \
+ -f '{{.Id}},{{.State.Running}},{{.State.FinishedAt}}' \
+ $(dockercmd ps -qa) 2>/dev/null)
+}
+
+## @description Remove untagged/unused images
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function remove_untagged_images
+{
+ # this way is a bit more compatible with older docker versions
+ dockercmd images | tail -n +2 | awk '$1 == "<none>" {print $3}' | \
+ xargs --no-run-if-empty docker rmi
+}
+
+## @description Remove defunct tagged images
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function remove_old_tagged_images
+{
+ local line
+ local id
+ local created
+
+ while read line; do
+ id=$(echo "${line}" | awk '{print $1}')
+ created=$(echo "${line}" | awk '{print $5}')
+
+ if [[ ${created} =~ week
+ || ${created} =~ month
+ || ${created} =~ year ]]; then
+ echo "Removing docker image ${id}"
+ dockercmd rmi "${id}"
+ fi
+
+ if [[ ${id} =~ test-patch-base-${PROJECT_NAME}-date ]]; then
+ if [[ ${created} =~ day
+ || ${created} =~ hours ]]; then
+ echo "Removing docker image ${id}"
+ dockercmd rmi "${id}"
+ fi
+ fi
+ done < <(dockercmd images)
+
+}
+
+## @description Performance docker maintenance on Jenkins
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function cleanup_apache_jenkins_docker
+{
+ echo "=========================="
+ echo "Docker Images:"
+ dockercmd images
+ echo "=========================="
+ echo "Docker Containers:"
+ dockercmd ps -a
+ echo "=========================="
+
+ stop_exited_containers
+
+ rm_old_containers
+
+ remove_untagged_images
+
+ remove_old_tagged_images
+}
+
+## @description Clean up our old images used for patch testing
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function cleanup_test_patch_images
+{
+ local images
+ local imagecount
+ local rmimage
+ local rmi
+
+ # we always want to leave at least one of our images
+ # so that the whole thing doesn't have to be rebuilt.
+ # This also let's us purge any old images so that
+ # we can get fresh stuff sometimes
+ images=$(dockercmd images | grep --color=none "test-patch-tp-${PROJECT_NAME}" | awk '{print $1}') 2>&1
+
+ # shellcheck disable=SC2086
+ imagecount=$(echo ${images} | tr ' ' '\n' | wc -l)
+ ((imagecount = imagecount - 1 ))
+
+ # shellcheck disable=SC2086
+ rmimage=$(echo ${images} | tr ' ' '\n' | tail -${imagecount})
+ for rmi in ${rmimage}
+ do
+ echo "Removing image ${rmi}"
+ dockercmd rmi "${rmi}"
+ done
+}
+
+## @description Perform pre-run maintenance to free up
+## @description resources. With --jenkins, it is a lot
+## @description more destructive.
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function cleanup
+{
+ if [[ ${TESTPATCHMODE} =~ jenkins ]]; then
+ cleanup_apache_jenkins_docker
+ fi
+
+ cleanup_test_patch_images
+}
+
+## @description Deterine the user name and user id of the user
+## @description that the docker container should use
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function determine_user
+{
+ # On the Apache Jenkins hosts, $USER is pretty much untrustable beacuse some
+ # ... person ... sets it to an account that doesn't actually exist.
+ # so instead, we need to try and override it with something that's
+ # probably close to reality.
+ if [[ ${TESTPATCHMODE} =~ jenkins ]]; then
+ USER=$(id | cut -f2 -d\( | cut -f1 -d\))
+ fi
+
+ if [[ "$(uname -s)" == "Linux" ]]; then
+ USER_NAME=${SUDO_USER:=$USER}
+ USER_ID=$(id -u "${USER_NAME}")
+ GROUP_ID=$(id -g "${USER_NAME}")
+ else # boot2docker uid and gid
+ USER_NAME=${USER}
+ USER_ID=1000
+ GROUP_ID=50
+ fi
+}
+
+## @description Determine the revision of a dockerfile
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function getdockerfilerev
+{
+ grep 'TEST_PATCH_PRIVATE: gitrev=' \
+ "${PATCH_DIR}/precommit/test-patch-docker/Dockerfile" \
+ | cut -f2 -d=
+}
+
+## @description Start a test patch docker container
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param args
+function run_image
+{
+ local dockerfilerev
+ local baseimagename
+
+ dockerfilerev=$(getdockerfilerev)
+
+ baseimagename="test-patch-base-${PROJECT_NAME}-${dockerfilerev}"
+
+ # make a base image, if it isn't available
+ dockercmd build -t "${baseimagename}" "${PATCH_DIR}/precommit/test-patch-docker"
+
+ # using the base image, make one that is patch specific
+ dockercmd build -t "test-patch-tp-${PROJECT_NAME}-${DID}" - <<PatchSpecificDocker
+FROM ${baseimagename}
+RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
+RUN useradd -g ${GROUP_ID} -u ${USER_ID} -m ${USER_NAME}
+RUN chown -R ${USER_NAME} /home/${USER_NAME}
+ENV HOME /home/${USER_NAME}
+USER ${USER_NAME}
+PatchSpecificDocker
+
+ if [[ -f "${PATCH_DIR}/buildtool-docker-params.txt" ]]; then
+ extraargs=$(cat "${PATCH_DIR}/buildtool-docker-params.txt")
+ else
+ extraargs=""
+ fi
+
+ if [[ ${PATCH_DIR} =~ ^/ ]]; then
+ dockercmd run --rm=true -i \
+ ${extraargs} \
+ -v "${PWD}:/testptch/${PROJECT_NAME}" \
+ -v "${PATCH_DIR}:/testptch/patchprocess" \
+ -u "${USER_NAME}" \
+ -w "/testptch/${PROJECT_NAME}" \
+ --env=BASEDIR="/testptch/${PROJECT_NAME}" \
+ --env=DOCKER_VERSION="${DOCKER_VERSION} Image:${baseimagename}" \
+ --env=JAVA_HOME="${JAVA_HOME}" \
+ --env=PATCH_DIR=/testptch/patchprocess \
+ --env=PROJECT_NAME="${PROJECT_NAME}" \
+ --env=TESTPATCHMODE="${TESTPATCHMODE}" \
+ "test-patch-tp-${PROJECT_NAME}-${DID}"
+ else
+ dockercmd run --rm=true -i \
+ ${extraargs} \
+ -v "${PWD}:/testptch/${PROJECT_NAME}" \
+ -u "${USER_NAME}" \
+ -w "/testptch/${PROJECT_NAME}" \
+ --env=BASEDIR="/testptch/${PROJECT_NAME}" \
+ --env=DOCKER_VERSION="${DOCKER_VERSION} Image:${baseimagename}" \
+ --env=JAVA_HOME="${JAVA_HOME}" \
+ --env=PATCH_DIR="${PATCH_DIR}" \
+ --env=PROJECT_NAME="${PROJECT_NAME}" \
+ --env=TESTPATCHMODE="${TESTPATCHMODE}" \
+ "test-patch-tp-${PROJECT_NAME}-${DID}"
+ fi
+}
+
+parse_args "$@"
+cleanup
+determine_user
+run_image
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/ant.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/ant.sh b/precommit/test-patch.d/ant.sh
new file mode 100755
index 0000000..9d931a5
--- /dev/null
+++ b/precommit/test-patch.d/ant.sh
@@ -0,0 +1,201 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [[ -z "${ANT_HOME:-}" ]]; then
+ ANT=ant
+else
+ ANT=${ANT_HOME}/bin/ant
+fi
+
+add_build_tool ant
+
+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')"
+}
+
+function ant_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --ant-cmd=*)
+ ANT=${i#*=}
+ ;;
+ esac
+ done
+
+ # if we requested offline, pass that to ant
+ if [[ ${OFFLINE} == "true" ]]; then
+ ANT_ARGS=("${ANT_ARGS[@]}" -Doffline=)
+ fi
+}
+
+function ant_initialize
+{
+ # we need to do this before docker kicks in
+ if [[ -e "${HOME}/.ivy2"
+ && ! -d "${HOME}/.ivy2" ]]; then
+ yetus_error "ERROR: ${HOME}/.ivy2 is not a directory."
+ return 1
+ elif [[ ! -e "${HOME}/.ivy2" ]]; then
+ yetus_debug "Creating ${HOME}/.ivy2"
+ mkdir -p "${HOME}/.ivy2"
+ fi
+}
+
+function ant_buildfile
+{
+ echo "build.xml"
+}
+
+function ant_executor
+{
+ echo "${ANT}" "${ANT_ARGS[@]}"
+}
+
+function ant_modules_worker
+{
+ declare repostatus=$1
+ declare tst=$2
+ shift 2
+
+ # shellcheck disable=SC2034
+ UNSUPPORTED_TEST=false
+
+ case ${tst} in
+ findbugs)
+ modules_workers "${repostatus}" findbugs findbugs
+ ;;
+ compile)
+ modules_workers "${repostatus}" compile
+ ;;
+ distclean)
+ modules_workers "${repostatus}" distclean clean
+ ;;
+ javadoc)
+ modules_workers "${repostatus}" javadoc clean javadoc
+ ;;
+ unit)
+ modules_workers "${repostatus}" unit
+ ;;
+ *)
+ # shellcheck disable=SC2034
+ UNSUPPORTED_TEST=true
+ if [[ ${repostatus} = patch ]]; then
+ add_footer_table "${tst}" "not supported by the ${BUILDTOOL} plugin"
+ fi
+ yetus_error "WARNING: ${tst} is unsupported by ${BUILDTOOL}"
+ return 1
+ ;;
+ esac
+}
+
+function ant_javac_count_probs
+{
+ declare warningfile=$1
+ declare val1
+ declare val2
+
+ #shellcheck disable=SC2016
+ val1=$(${GREP} -E "\[javac\] [0-9]+ errors?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
+ #shellcheck disable=SC2016
+ val2=$(${GREP} -E "\[javac\] [0-9]+ warnings?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
+ echo $((val1+val2))
+}
+
+## @description Helper for check_patch_javadoc
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function ant_javadoc_count_probs
+{
+ local warningfile=$1
+ local val1
+ local val2
+
+ #shellcheck disable=SC2016
+ val1=$(${GREP} -E "\[javadoc\] [0-9]+ errors?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
+ #shellcheck disable=SC2016
+ val2=$(${GREP} -E "\[javadoc\] [0-9]+ warnings?$" "${warningfile}" | ${AWK} '{sum+=$2} END {print sum}')
+ echo $((val1+val2))
+}
+
+function ant_builtin_personality_modules
+{
+ local repostatus=$1
+ local testtype=$2
+
+ local module
+
+ yetus_debug "Using builtin personality_modules"
+ yetus_debug "Personality: ${repostatus} ${testtype}"
+
+ clear_personality_queue
+
+ for module in ${CHANGED_MODULES}; do
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module}
+ done
+}
+
+function ant_builtin_personality_file_tests
+{
+ local filename=$1
+
+ yetus_debug "Using builtin ant personality_file_tests"
+
+ if [[ ${filename} =~ \.sh
+ || ${filename} =~ \.cmd
+ ]]; then
+ yetus_debug "tests/shell: ${filename}"
+ elif [[ ${filename} =~ \.c$
+ || ${filename} =~ \.cc$
+ || ${filename} =~ \.h$
+ || ${filename} =~ \.hh$
+ || ${filename} =~ \.proto$
+ || ${filename} =~ src/test
+ || ${filename} =~ \.cmake$
+ || ${filename} =~ CMakeLists.txt
+ ]]; then
+ yetus_debug "tests/units: ${filename}"
+ add_test javac
+ add_test unit
+ elif [[ ${filename} =~ build.xml
+ || ${filename} =~ ivy.xml
+ || ${filename} =~ \.java$
+ ]]; then
+ yetus_debug "tests/javadoc+units: ${filename}"
+ add_test javac
+ add_test javadoc
+ add_test unit
+ fi
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ add_test findbugs
+ fi
+}
+
+function ant_docker_support
+{
+ echo "-v ${HOME}/.ivy2:${HOME}/.ivy2" > "${PATCH_DIR}/buildtool-docker-params.txt"
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/asflicense.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/asflicense.sh b/precommit/test-patch.d/asflicense.sh
new file mode 100755
index 0000000..befe7a1
--- /dev/null
+++ b/precommit/test-patch.d/asflicense.sh
@@ -0,0 +1,194 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+add_test_type asflicense
+add_test asflicense
+
+function asflicense_parse_args
+{
+ declare i
+
+ for i in "$@"; do
+ case ${i} in
+ --asflicense-rat-excludes=*)
+ ASFLICENSE_RAT_EXCLUDES=${i#*=}
+ ;;
+ --asflicense-rat-jar=*)
+ ASFLICENSE_RAT_JAR=${i#*=}
+ ;;
+ esac
+ done
+
+ case ${BUILDTOOL} in
+ ant|gradle|maven)
+ add_test asflicense
+ ;;
+ *)
+ if [[ -f "${ASFLICENSE_RAT_JAR}" ]]; then
+ add_test asflicense
+ fi
+ ;;
+ esac
+}
+
+## @description Verify all files have an Apache License
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function asflicense_tests
+{
+ local numpatch
+ local btfails=true
+ local asfex
+
+ big_console_header "Determining number of patched ASF License errors"
+
+ start_clock
+
+ personality_modules patch asflicense
+ case ${BUILDTOOL} in
+ ant)
+ modules_workers patch asflicense releaseaudit
+ ;;
+ gradle)
+ btfails=false
+ modules_workers patch asflicense rat
+ ;;
+ maven)
+ modules_workers patch asflicense apache-rat:check
+ ;;
+ *)
+ if [[ -z "${ASFLICENSE_RAT_JAR}" ]]; then
+ return 0
+ fi
+
+ if [[ -f ${ASFLICENSE_RAT_EXCLUDES} ]]; then
+ asfex="-E ${ASFLICENSE_RAT_EXCLUDES} -d ${BASEDIR}"
+ else
+ asfex="${BASEDIR}"
+ fi
+
+ asflicense_writexsl "${PATCH_DIR}/asf.xsl"
+ echo_and_redirect "${PATCH_DIR}/patch-asflicense.txt" \
+ "${JAVA_HOME}/bin/java" \
+ -jar "${ASFLICENSE_RAT_JAR}" \
+ -s "${PATCH_DIR}/asf.xsl" \
+ "${asfex}"
+ ;;
+ esac
+
+ # RAT fails the build if there are license problems.
+ # so let's take advantage of that a bit.
+ if [[ $? == 0 && ${btfails} = true ]]; then
+ add_vote_table 1 asflicense "Patch does not generate ASF License warnings."
+ return 0
+ fi
+
+ if [[ ! -f "${PATCH_DIR}/patch-asflicense.txt" ]]; then
+ #shellcheck disable=SC2038
+ find "${BASEDIR}" -name rat.txt \
+ -o -name releaseaudit_report.txt \
+ -o -name rat-report.txt \
+ | xargs cat > "${PATCH_DIR}/patch-asflicense.txt"
+ fi
+
+ if [[ ! -s "${PATCH_DIR}/patch-asflicense.txt" ]]; then
+ if [[ ${btfails} = true ]]; then
+ # if we're here, then build actually failed
+ modules_messages patch asflicense true
+ else
+ add_vote_table 0 asflicense "ASF License check generated no output?"
+ return 0
+ fi
+ fi
+
+ numpatch=$("${GREP}" -c '\!?????' "${PATCH_DIR}/patch-asflicense.txt")
+ echo ""
+ echo ""
+ echo "There appear to be ${numpatch} ASF License warnings after applying the patch."
+ if [[ -n ${numpatch}
+ && ${numpatch} -gt 0 ]] ; then
+ add_vote_table -1 asflicense "Patch generated ${numpatch} ASF License warnings."
+
+ echo "Lines that start with ????? in the ASF License "\
+ "report indicate files that do not have an Apache license header:" \
+ > "${PATCH_DIR}/patch-asflicense-problems.txt"
+
+ ${GREP} '\!?????' "${PATCH_DIR}/patch-asflicense.txt" \
+ >> "${PATCH_DIR}/patch-asflicense-problems.txt"
+
+ add_footer_table asflicense "@@BASE@@/patch-asflicense-problems.txt"
+ return 1
+ fi
+ add_vote_table 1 asflicense "Patch does not generate ASF License warnings."
+ return 0
+}
+
+function asflicense_writexsl
+{
+cat > "${1}" << EOF
+<?xml version='1.0' ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one *
+ or more contributor license agreements. See the NOTICE file *
+ distributed with this work for additional information *
+ regarding copyright ownership. The ASF licenses this file *
+ to you under the Apache License, Version 2.0 (the *
+ "License"); you may not use this file except in compliance *
+ with the License. You may obtain a copy of the License at *
+ *
+ http://www.apache.org/licenses/LICENSE-2.0 *
+ *
+ Unless required by applicable law or agreed to in writing, *
+ software distributed under the License is distributed on an *
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ KIND, either express or implied. See the License for the *
+ specific language governing permissions and limitations *
+ under the License. *
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method='text'/>
+<xsl:template match='/'>
+ Files with Apache License headers will be marked AL
+ Binary files (which do not require any license headers) will be marked B
+ Compressed archives will be marked A
+ Notices, licenses etc. will be marked N
+
+ <xsl:for-each select='descendant::resource'>
+ <xsl:choose>
+ <xsl:when test='license-approval/@name="false"'>!</xsl:when>
+ <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test='type/@name="notice"'>N </xsl:when>
+ <xsl:when test='type/@name="archive"'>A </xsl:when>
+ <xsl:when test='type/@name="binary"'>B </xsl:when>
+ <xsl:when test='type/@name="standard"'><xsl:value-of select='header-type/@name'/></xsl:when>
+ <xsl:otherwise>!!!!!</xsl:otherwise>
+ </xsl:choose>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select='@name'/>
+ <xsl:text>
+ </xsl:text>
+ </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
+EOF
+}
[04/10] yetus git commit: YETUS-6 Reoganize repository for split to
TLP.
Posted by bu...@apache.org.
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/author.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/author.sh b/precommit/test-patch.d/author.sh
new file mode 100755
index 0000000..d456bbb
--- /dev/null
+++ b/precommit/test-patch.d/author.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type author
+
+## @description Check the current directory for @author tags
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function author_patchfile
+{
+ declare patchfile=$1
+ declare authorTags
+ # shellcheck disable=SC2155
+ declare -r appname=$(basename "${BASH_SOURCE-$0}")
+
+ big_console_header "Checking there are no @author tags in the patch."
+
+ start_clock
+
+ if [[ ${CHANGED_FILES} =~ ${appname} ]]; then
+ echo "Skipping @author checks as ${appname} has been patched."
+ add_vote_table 0 @author "Skipping @author checks as ${appname} has been patched."
+ return 0
+ fi
+
+ authorTags=$("${GREP}" -c -i '^[^-].*@author' "${patchfile}")
+ echo "There appear to be ${authorTags} @author tags in the patch."
+ if [[ ${authorTags} != 0 ]] ; then
+ add_vote_table -1 @author \
+ "The patch appears to contain ${authorTags} @author tags which the" \
+ " community has agreed to not allow in code contributions."
+ return 1
+ fi
+ add_vote_table +1 @author "The patch does not contain any @author tags."
+ return 0
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/cc.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/cc.sh b/precommit/test-patch.d/cc.sh
new file mode 100755
index 0000000..cae91d3
--- /dev/null
+++ b/precommit/test-patch.d/cc.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type cc
+
+function cc_filefilter
+{
+ declare filename=$1
+
+ if [[ ${filename} =~ \.c$
+ || ${filename} =~ \.cc$
+ || ${filename} =~ \.cpp$
+ || ${filename} =~ \.cxx$
+ || ${filename} =~ \.h$
+ || ${filename} =~ \.hh$
+ ]]; then
+ yetus_debug "tests/cc: ${filename}"
+ add_test cc
+ add_test compile
+ fi
+}
+
+## @description check for C/C++ compiler errors
+## @audience private
+## @stability stable
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function cc_compile
+{
+ declare codebase=$1
+ declare multijdkmode=$2
+
+ verify_needed_test cc
+ if [[ $? = 0 ]]; then
+ return 0
+ fi
+
+ if [[ ${codebase} = patch ]]; then
+ generic_postlog_compare compile cc "${multijdkmode}"
+ fi
+}
+
+function cc_count_probs
+{
+ declare warningfile=$1
+
+ #shellcheck disable=SC2016,SC2046
+ ${GREP} -E '^.*\.(c|cc|h|hh)\:[[:digit:]]*\:' "${warningfile}" | ${AWK} '{sum+=1} END {print sum}'
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/checkstyle.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/checkstyle.sh b/precommit/test-patch.d/checkstyle.sh
new file mode 100755
index 0000000..24b9ffc
--- /dev/null
+++ b/precommit/test-patch.d/checkstyle.sh
@@ -0,0 +1,237 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type checkstyle
+
+CHECKSTYLE_TIMER=0
+
+function checkstyle_filefilter
+{
+ local filename=$1
+
+ if [[ ${BUILDTOOL} == maven
+ || ${BUILDTOOL} == ant ]]; then
+ if [[ ${filename} =~ \.java$ ]]; then
+ add_test checkstyle
+ fi
+ fi
+}
+
+function checkstyle_runner
+{
+ local repostatus=$1
+ local tmp=${PATCH_DIR}/$$.${RANDOM}
+ local j
+ local i=0
+ local fn
+ local savestart=${TIMER}
+ local savestop
+ local output
+ local logfile
+ local repo
+ local modulesuffix
+ local cmd
+
+ modules_reset
+
+ if [[ ${repostatus} == branch ]]; then
+ repo=${PATCH_BRANCH}
+ else
+ repo="the patch"
+ fi
+
+ #shellcheck disable=SC2153
+ until [[ $i -eq ${#MODULE[@]} ]]; do
+ start_clock
+ fn=$(module_file_fragment "${MODULE[${i}]}")
+ modulesuffix=$(basename "${MODULE[${i}]}")
+ output="${PATCH_DIR}/${repostatus}-checkstyle-${fn}.txt"
+ logfile="${PATCH_DIR}/maven-${repostatus}-checkstyle-${fn}.txt"
+
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ pushd "${BASEDIR}/${MODULE[${i}]}" >/dev/null
+ fi
+
+ case ${BUILDTOOL} in
+ ant)
+ cmd="${ANT} \
+ -Dcheckstyle.consoleOutput=true \
+ ${MODULEEXTRAPARAM[${i}]//@@@MODULEFN@@@/${fn}} \
+ ${ANT_ARGS[*]} checkstyle"
+ ;;
+ maven)
+ cmd="${MAVEN} ${MAVEN_ARGS[*]} \
+ checkstyle:checkstyle \
+ -Dcheckstyle.consoleOutput=true \
+ ${MODULEEXTRAPARAM[${i}]//@@@MODULEFN@@@/${fn}} -Ptest-patch"
+ ;;
+ *)
+ UNSUPPORTED_TEST=true
+ return 0
+ ;;
+ esac
+
+ #shellcheck disable=SC2086
+ echo ${cmd} "> ${logfile}"
+ #shellcheck disable=SC2086
+ ${cmd} 2>&1 \
+ | tee "${logfile}" \
+ | ${GREP} ^/ \
+ | ${SED} -e "s,${BASEDIR},.,g" \
+ > "${tmp}"
+
+ if [[ $? == 0 ]] ; then
+ module_status ${i} +1 "${logfile}" "${modulesuffix} in ${repo} passed checkstyle"
+ else
+ module_status ${i} -1 "${logfile}" "${modulesuffix} in ${repo} failed checkstyle"
+ ((result = result + 1))
+ fi
+ savestop=$(stop_clock)
+ #shellcheck disable=SC2034
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+
+ for j in ${CHANGED_FILES}; do
+ ${GREP} "${j}" "${tmp}" >> "${output}"
+ done
+
+ rm "${tmp}" 2>/dev/null
+
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ popd >/dev/null
+ fi
+ ((i=i+1))
+ done
+
+ TIMER=${savestart}
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function checkstyle_postcompile
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ checkstyle_preapply
+ else
+ checkstyle_postapply
+ fi
+}
+
+function checkstyle_preapply
+{
+ local result
+
+ verify_needed_test checkstyle
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "${PATCH_BRANCH} checkstyle"
+
+ start_clock
+
+ personality_modules branch checkstyle
+ checkstyle_runner branch
+ result=$?
+ modules_messages branch checkstyle true
+
+ # keep track of how much as elapsed for us already
+ CHECKSTYLE_TIMER=$(stop_clock)
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function checkstyle_postapply
+{
+ local result
+ local module
+ local mod
+ local fn
+ local i=0
+ local numprepatch=0
+ local numpostpatch=0
+ local diffpostpatch=0
+
+ verify_needed_test checkstyle
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Patch checkstyle plugin"
+
+ start_clock
+
+ personality_modules patch checkstyle
+ checkstyle_runner patch
+ result=$?
+
+ if [[ ${UNSUPPORTED_TEST} = true ]]; then
+ return 0
+ fi
+
+ # add our previous elapsed to our new timer
+ # by setting the clock back
+ offset_clock "${CHECKSTYLE_TIMER}"
+
+ until [[ $i -eq ${#MODULE[@]} ]]; do
+ if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
+ ((result=result+1))
+ ((i=i+1))
+ continue
+ fi
+ module=${MODULE[$i]}
+ fn=$(module_file_fragment "${module}")
+
+ if [[ ! -f "${PATCH_DIR}/branch-checkstyle-${fn}.txt" ]]; then
+ touch "${PATCH_DIR}/branch-checkstyle-${fn}.txt"
+ fi
+
+ calcdiffs "${PATCH_DIR}/branch-checkstyle-${fn}.txt" "${PATCH_DIR}/patch-checkstyle-${fn}.txt" > "${PATCH_DIR}/diff-checkstyle-${fn}.txt"
+ #shellcheck disable=SC2016
+ diffpostpatch=$(wc -l "${PATCH_DIR}/diff-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
+
+ if [[ ${diffpostpatch} -gt 0 ]] ; then
+ ((result = result + 1))
+
+ # shellcheck disable=SC2016
+ numprepatch=$(wc -l "${PATCH_DIR}/branch-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
+ # shellcheck disable=SC2016
+ numpostpatch=$(wc -l "${PATCH_DIR}/patch-checkstyle-${fn}.txt" | ${AWK} '{print $1}')
+
+ mod=${module}
+ if [[ ${mod} == . ]]; then
+ mod=root
+ fi
+ module_status ${i} -1 "diff-checkstyle-${fn}.txt" "Patch generated "\
+ "${diffpostpatch} new checkstyle issues in "\
+ "${mod} (total was ${numprepatch}, now ${numpostpatch})."
+ fi
+ ((i=i+1))
+ done
+
+ modules_messages patch checkstyle true
+
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/findbugs.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/findbugs.sh b/precommit/test-patch.d/findbugs.sh
new file mode 100755
index 0000000..ae18893
--- /dev/null
+++ b/precommit/test-patch.d/findbugs.sh
@@ -0,0 +1,411 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+FINDBUGS_HOME=${FINDBUGS_HOME:-}
+FINDBUGS_WARNINGS_FAIL_PRECHECK=false
+
+add_test_type findbugs
+
+function findbugs_filefilter
+{
+ local filename=$1
+
+ if [[ ${BUILDTOOL} == maven
+ || ${BUILDTOOL} == ant ]]; then
+ if [[ ${filename} =~ \.java$
+ || ${filename} =~ (^|/)findbugs-exclude.xml$ ]]; then
+ add_test findbugs
+ fi
+ fi
+}
+
+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"
+}
+
+function findbugs_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --findbugs-home=*)
+ FINDBUGS_HOME=${i#*=}
+ ;;
+ --findbugs-strict-precheck)
+ FINDBUGS_WARNINGS_FAIL_PRECHECK=true
+ ;;
+ esac
+ done
+}
+
+## @description are the needed bits for findbugs present?
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 findbugs will work for our use
+## @return 1 findbugs is missing some component
+function findbugs_is_installed
+{
+ declare exec
+ declare status=0
+
+ for exec in findbugs \
+ computeBugHistory \
+ convertXmlToText \
+ filterBugs \
+ setBugDatabaseInfo; do
+ if [[ ! -x "${FINDBUGS_HOME}/bin/${exec}" ]]; then
+ yetus_error "ERROR: ${FINDBUGS_HOME}/bin/${exec} is not executable."
+ status=1
+ fi
+ done
+ return ${status}
+}
+
+## @description Run the maven findbugs plugin and record found issues in a bug database
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function findbugs_runner
+{
+ local name=$1
+ local module
+ local result=0
+ local fn
+ local warnings_file
+ local i=0
+ local savestop
+
+ personality_modules "${name}" findbugs
+ "${BUILDTOOL}_modules_worker" "${name}" findbugs
+
+ if [[ ${UNSUPPORTED_TEST} = true ]]; then
+ return 0
+ fi
+
+ #shellcheck disable=SC2153
+ until [[ ${i} -eq ${#MODULE[@]} ]]; do
+ if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
+ ((result=result+1))
+ ((i=i+1))
+ continue
+ fi
+ start_clock
+ offset_clock "${MODULE_STATUS_TIMER[${i}]}"
+ module="${MODULE[${i}]}"
+ fn=$(module_file_fragment "${module}")
+
+ case ${BUILDTOOL} in
+ maven)
+ file="${module}/target/findbugsXml.xml"
+ ;;
+ ant)
+ file="${ANT_FINDBUGSXML}"
+ ;;
+ esac
+
+
+ if [[ ! -f ${file} ]]; then
+ module_status ${i} -1 "" "${name}/${module} no findbugs output file (${file})"
+ ((i=i+1))
+ continue
+ fi
+
+ warnings_file="${PATCH_DIR}/${name}-findbugs-${fn}-warnings"
+
+ cp -p "${file}" "${warnings_file}.xml"
+
+ if [[ ${name} == branch ]]; then
+ "${FINDBUGS_HOME}/bin/setBugDatabaseInfo" -name "${PATCH_BRANCH}" \
+ "${warnings_file}.xml" "${warnings_file}.xml"
+ else
+ "${FINDBUGS_HOME}/bin/setBugDatabaseInfo" -name patch \
+ "${warnings_file}.xml" "${warnings_file}.xml"
+ fi
+ if [[ $? != 0 ]]; then
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ module_status ${i} -1 "" "${name}/${module} cannot run setBugDatabaseInfo from findbugs"
+ ((result=result+1))
+ ((i=i+1))
+ continue
+ fi
+
+ "${FINDBUGS_HOME}/bin/convertXmlToText" -html \
+ "${warnings_file}.xml" \
+ "${warnings_file}.html"
+ if [[ $? != 0 ]]; then
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ module_status ${i} -1 "" "${name}/${module} cannot run convertXmlToText from findbugs"
+ ((result=result+1))
+ fi
+
+ if [[ -z ${FINDBUGS_VERSION}
+ && ${name} == branch ]]; then
+ FINDBUGS_VERSION=$(${GREP} -i "BugCollection version=" "${warnings_file}.xml" \
+ | cut -f2 -d\" \
+ | cut -f1 -d\" )
+ if [[ -n ${FINDBUGS_VERSION} ]]; then
+ add_footer_table findbugs "v${FINDBUGS_VERSION}"
+ fi
+ fi
+
+ ((i=i+1))
+ done
+ return ${result}
+}
+
+## @description Track pre-existing findbugs warnings
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function findbugs_preapply
+{
+ local fn
+ local module
+ local i=0
+ local warnings_file
+ local module_findbugs_warnings
+ local result=0
+
+ verify_needed_test findbugs
+
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ findbugs_is_installed
+ if [[ $? != 0 ]]; then
+ add_vote_table 0 findbugs "findbugs executables are not available."
+ return 0
+ fi
+
+ big_console_header "Pre-patch findbugs detection"
+
+ findbugs_runner branch
+ result=$?
+
+ if [[ ${UNSUPPORTED_TEST} = true ]]; then
+ return 0
+ fi
+
+ if [[ "${FINDBUGS_WARNINGS_FAIL_PRECHECK}" == "true" ]]; then
+ until [[ $i -eq ${#MODULE[@]} ]]; do
+ if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
+ ((result=result+1))
+ ((i=i+1))
+ continue
+ fi
+ module=${MODULE[${i}]}
+ start_clock
+ offset_clock "${MODULE_STATUS_TIMER[${i}]}"
+ fn=$(module_file_fragment "${module}")
+ warnings_file="${PATCH_DIR}/branch-findbugs-${fn}-warnings"
+ # shellcheck disable=SC2016
+ module_findbugs_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -first \
+ "${PATCH_BRANCH}" \
+ "${warnings_file}.xml" \
+ "${warnings_file}.xml" \
+ | ${AWK} '{print $1}')
+
+ if [[ ${module_findbugs_warnings} -gt 0 ]] ; then
+ module_status ${i} -1 "branch-findbugs-${fn}.html" "${module} in ${PATCH_BRANCH} cannot run convertXmlToText from findbugs"
+ ((result=result+1))
+ fi
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ ((i=i+1))
+ done
+ modules_messages branch findbugs true
+ fi
+
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Verify patch does not trigger any findbugs warnings
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function findbugs_postinstall
+{
+ local module
+ local fn
+ local combined_xml
+ local branchxml
+ local patchxml
+ local newbugsbase
+ local fixedbugsbase
+ local new_findbugs_warnings
+ local fixed_findbugs_warnings
+ local line
+ local firstpart
+ local secondpart
+ local i=0
+ local result=0
+ local savestop
+
+ verify_needed_test findbugs
+
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ findbugs_is_installed
+ if [[ $? != 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Patch findbugs detection"
+
+ findbugs_runner patch
+
+ if [[ ${UNSUPPORTED_TEST} = true ]]; then
+ return 0
+ fi
+
+ until [[ $i -eq ${#MODULE[@]} ]]; do
+ if [[ ${MODULE_STATUS[${i}]} == -1 ]]; then
+ ((result=result+1))
+ ((i=i+1))
+ continue
+ fi
+ start_clock
+ offset_clock "${MODULE_STATUS_TIMER[${i}]}"
+ module="${MODULE[${i}]}"
+
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ pushd "${module}" >/dev/null
+ fi
+
+ fn=$(module_file_fragment "${module}")
+
+ combined_xml="${PATCH_DIR}/combined-findbugs-${fn}.xml"
+ branchxml="${PATCH_DIR}/branch-findbugs-${fn}-warnings.xml"
+ patchxml="${PATCH_DIR}/patch-findbugs-${fn}-warnings.xml"
+
+ if [[ ! -f "${branchxml}" ]]; then
+ branchxml=${patchxml}
+ fi
+
+ newbugsbase="${PATCH_DIR}/new-findbugs-${fn}"
+ fixedbugsbase="${PATCH_DIR}/fixed-findbugs-${fn}"
+
+ "${FINDBUGS_HOME}/bin/computeBugHistory" -useAnalysisTimes -withMessages \
+ -output "${combined_xml}" \
+ "${branchxml}" \
+ "${patchxml}"
+ if [[ $? != 0 ]]; then
+ if [[ ${BUILDTOOLCWD} == true ]]; then
+ popd >/dev/null
+ fi
+ module_status ${i} -1 "" "${module} cannot run computeBugHistory from findbugs"
+ ((result=result+1))
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ ((i=i+1))
+ continue
+ fi
+
+ #shellcheck disable=SC2016
+ new_findbugs_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -first patch \
+ "${combined_xml}" "${newbugsbase}.xml" | ${AWK} '{print $1}')
+ if [[ $? != 0 ]]; then
+ popd >/dev/null
+ module_status ${i} -1 "" "${module} cannot run filterBugs (#1) from findbugs"
+ ((result=result+1))
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ ((i=i+1))
+ continue
+ fi
+
+ #shellcheck disable=SC2016
+ fixed_findbugs_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -fixed patch \
+ "${combined_xml}" "${fixedbugsbase}.xml" | ${AWK} '{print $1}')
+ if [[ $? != 0 ]]; then
+ popd >/dev/null
+ module_status ${i} -1 "" "${module} cannot run filterBugs (#2) from findbugs"
+ ((result=result+1))
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ ((i=i+1))
+ continue
+ fi
+
+ echo "Found ${new_findbugs_warnings} new Findbugs warnings and ${fixed_findbugs_warnings} newly fixed warnings."
+
+ "${FINDBUGS_HOME}/bin/convertXmlToText" -html "${newbugsbase}.xml" \
+ "${newbugsbase}.html"
+ if [[ $? != 0 ]]; then
+ popd >/dev/null
+ module_status ${i} -1 "" "${module} cannot run convertXmlToText from findbugs"
+ ((result=result+1))
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ ((i=i+1))
+ continue
+ fi
+
+ if [[ ${new_findbugs_warnings} -gt 0 ]] ; then
+ populate_test_table FindBugs "module:${module}"
+ while read line; do
+ firstpart=$(echo "${line}" | cut -f2 -d:)
+ secondpart=$(echo "${line}" | cut -f9- -d' ')
+ add_test_table "" "${firstpart}:${secondpart}"
+ done < <("${FINDBUGS_HOME}/bin/convertXmlToText" "${newbugsbase}.xml")
+
+ module_status ${i} -1 "new-findbugs-${fn}.html" "${module} introduced "\
+ "${new_findbugs_warnings} new FindBugs issues."
+ ((result=result+1))
+ fi
+ savestop=$(stop_clock)
+ MODULE_STATUS_TIMER[${i}]=${savestop}
+ popd >/dev/null
+ ((i=i+1))
+ done
+
+ modules_messages patch findbugs true
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function findbugs_rebuild
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ findbugs_preapply
+ else
+ findbugs_postinstall
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/github.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/github.sh b/precommit/test-patch.d/github.sh
new file mode 100755
index 0000000..468a228
--- /dev/null
+++ b/precommit/test-patch.d/github.sh
@@ -0,0 +1,492 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This bug system provides github integration
+
+add_bugsystem github
+
+# personalities can override the following settings:
+
+# Web interface URL.
+GITHUB_BASE_URL="https://github.com"
+
+# API interface URL.
+GITHUB_API_URL="https://api.github.com"
+
+# user/repo
+GITHUB_REPO=""
+
+# user settings
+GITHUB_PASSWD=""
+GITHUB_TOKEN=""
+GITHUB_USER=""
+GITHUB_ISSUE=""
+
+# private globals...
+GITHUB_BRIDGED=false
+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"
+}
+
+function github_parse_args
+{
+ declare i
+
+ for i in "$@"; do
+ case ${i} in
+ --github-api-url=*)
+ GITHUB_API_URL=${i#*=}
+ ;;
+ --github-base-url=*)
+ GITHUB_BASE_URL=${i#*=}
+ ;;
+ --github-repo=*)
+ GITHUB_REPO=${i#*=}
+ ;;
+ --github-token=*)
+ GITHUB_TOKEN=${i#*=}
+ ;;
+ --github-password=*)
+ GITHUB_PASSWD=${i#*=}
+ ;;
+ --github-user=*)
+ GITHUB_USER=${i#*=}
+ ;;
+ esac
+ done
+}
+
+## @description this gets called when JIRA thinks this
+## @description issue is just a pointer to github
+## @description WARNING: Called from JIRA plugin!
+function github_jira_bridge
+{
+ declare fileloc=$1
+ declare urlfromjira
+
+ # we use this to prevent loops later on
+ GITHUB_BRIDGED=true
+
+ # the JIRA issue has already been downloaded. So let's find the URL.
+ # shellcheck disable=SC2016
+ urlfromjira=$(${AWK} "match(\$0,\"${GITHUB_BASE_URL}/[^ ]*patch\"){print substr(\$0,RSTART,RLENGTH)}" "${PATCH_DIR}/jira" | tail -1)
+ github_breakup_url "${urlfromjira}"
+ github_locate_patch "${GITHUB_ISSUE}" "${fileloc}"
+}
+
+## @description given a URL, break it up into github plugin globals
+## @description this will *override* any personality or yetus defaults
+## @params url
+function github_breakup_url
+{
+ declare url=$1
+ declare count
+ declare pos1
+ declare pos2
+
+ count=${url//[^\/]}
+ count=${#count}
+ ((pos2=count-3))
+ ((pos1=pos2))
+
+ GITHUB_BASE_URL=$(echo "${url}" | cut -f1-${pos2} -d/)
+
+ ((pos1=pos1+1))
+ ((pos2=pos1+1))
+
+ GITHUB_REPO=$(echo "${url}" | cut -f${pos1}-${pos2} -d/)
+
+ ((pos1=pos2+2))
+ unset pos2
+
+ GITHUB_ISSUE=$(echo "${url}" | cut -f${pos1}-${pos2} -d/ | cut -f1 -d.)
+}
+
+
+## @description based upon a github PR, attempt to link back to JIRA
+function github_find_jira_title
+{
+ declare title
+ declare maybe
+ declare retval
+
+ if [[ ! -f "${PATCH_DIR}/github-pull.json" ]]; then
+ return 1
+ fi
+
+ title=$(${GREP} title "${PATCH_DIR}/github-pull.json" \
+ | cut -f4 -d\")
+
+ # people typically do two types: JIRA-ISSUE: and [JIRA-ISSUE]
+ # JIRA_ISSUE_RE is pretty strict so we need to chop that stuff
+ # out first
+
+ maybe=$(echo "${title}" | cut -f2 -d\[ | cut -f1 -d\])
+ jira_determine_issue "${maybe}"
+ retval=$?
+
+ if [[ ${retval} == 0 ]]; then
+ return 0
+ fi
+
+ maybe=$(echo "${title}" | cut -f1 -d:)
+ jira_determine_issue "${maybe}"
+ retval=$?
+
+ if [[ ${retval} == 0 ]]; then
+ return 0
+ fi
+
+ return 1
+}
+
+function github_determine_issue
+{
+ declare input=$1
+
+ if [[ ${input} =~ ^[0-9]+$
+ && -n ${GITHUB_REPO} ]]; then
+ # shellcheck disable=SC2034
+ ISSUE=${input}
+ if [[ -z ${GITHUB_ISSUE} ]]; then
+ GITHUB_ISSUE=${input}
+ fi
+ fi
+
+ # if JIRA didn't call us, should we call it?
+ if [[ ${GITHUB_BRIDGED} == false ]]; then
+ github_find_jira_title
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+ fi
+
+ if [[ -n ${GITHUB_ISSUE} ]]; then
+ return 0
+ fi
+
+ return 1
+}
+
+## @description Try to guess the branch being tested using a variety of heuristics
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success, with PATCH_BRANCH updated appropriately
+## @return 1 on failure
+function github_determine_branch
+{
+ if [[ ! -f "${PATCH_DIR}/github-pull.json" ]]; then
+ return 1
+ fi
+
+ # shellcheck disable=SC2016
+ PATCH_BRANCH=$(${AWK} 'match($0,"\"ref\": \""){print $2}' "${PATCH_DIR}/github-pull.json"\
+ | cut -f2 -d\"\
+ | tail -1 )
+
+ yetus_debug "Github determine branch: starting with ${PATCH_BRANCH}"
+
+ verify_valid_branch "${PATCH_BRANCH}"
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+ return 1
+}
+
+function github_locate_patch
+{
+ declare input=$1
+ declare output=$2
+ declare githubauth
+
+ if [[ "${OFFLINE}" == true ]]; then
+ yetus_debug "github_locate_patch: offline, skipping"
+ return 1
+ fi
+
+
+ # https://github.com/your/repo/pull/##
+ if [[ ${input} =~ ^${GITHUB_BASE_URL}.*/pull/[0-9]+$ ]]; then
+ github_breakup_url "${input}.patch"
+ input=${GITHUB_ISSUE}
+ fi
+
+ # https://github.com/your/repo/pulls/##.patch
+ if [[ ${input} =~ ^${GITHUB_BASE_URL}.*patch$ ]]; then
+ github_breakup_url "${input}"
+ input=${GITHUB_ISSUE}
+ fi
+
+ # https://github.com/your/repo/pulls/##.diff
+ if [[ ${input} =~ ^${GITHUB_BASE_URL}.*diff$ ]]; then
+ github_breakup_url "${input}"
+ input=${GITHUB_ISSUE}
+ fi
+
+ # if it isn't a number at this point, no idea
+ # how to process
+ if [[ ! ${input} =~ ^[0-9]+$ ]]; then
+ yetus_debug "github: ${input} is not a pull request #"
+ return 1
+ fi
+
+ # we always pull the .patch version (even if .diff was given)
+ # with the assumption that this way binary files work.
+ # The downside of this is that the patch files are
+ # significantly larger and therefore take longer to process
+ PATCHURL="${GITHUB_BASE_URL}/${GITHUB_REPO}/pull/${input}.patch"
+ echo "GITHUB PR #${input} is being downloaded at $(date) from"
+ echo "${GITHUB_BASE_URL}/${GITHUB_REPO}/pull/${input}"
+
+ if [[ -n "${GITHUB_USER}"
+ && -n "${GITHUB_PASSWD}" ]]; then
+ githubauth="${GITHUB_USER}:${GITHUB_PASSWD}"
+ elif [[ -n "${GITHUB_TOKEN}" ]]; then
+ githubauth="Authorization: token ${GITHUB_TOKEN}"
+ else
+ githubauth="X-ignore-me: fake"
+ fi
+
+ # Let's pull the PR JSON for later use
+ ${CURL} --silent --fail \
+ -H "Accept: application/vnd.github.v3.full+json" \
+ -H "${githubauth}" \
+ --output "${PATCH_DIR}/github-pull.json" \
+ --location \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPO}/pulls/${input}"
+
+ echo "Patch from GITHUB PR #${input} is being downloaded at $(date) from"
+ echo "${PATCHURL}"
+
+ # the actual patch file
+ ${CURL} --silent --fail \
+ --output "${output}" \
+ --location \
+ -H "${githubauth}" \
+ "${PATCHURL}"
+
+ if [[ $? != 0 ]]; then
+ yetus_debug "github_locate_patch: not a github pull request."
+ return 1
+ fi
+
+ GITHUB_ISSUE=${input}
+
+ # github will translate this to be #(xx) !
+ add_footer_table "GITHUB PR" "${GITHUB_BASE_URL}/${GITHUB_REPO}/pull/${input}"
+
+ return 0
+}
+
+function github_linecomments
+{
+ declare plugin=$1
+ declare file=$2
+ # shellcheck disable=SC2034
+ declare realline=$3
+ declare uniline=$4
+ declare text=$5
+ declare tempfile="${PATCH_DIR}/ghcomment.$$.${RANDOM}"
+ declare githubauth
+
+ if [[ "${file}" =~ ^./ ]]; then
+ file=${file##./}
+ fi
+
+ if [[ -z "${GITHUB_COMMITSHA}" ]]; then
+ GITHUB_COMMITSHA=$(${GREP} \"sha\" "${PATCH_DIR}/github-pull.json" 2>/dev/null \
+ | head -1 \
+ | cut -f4 -d\")
+ fi
+
+ if [[ -z "${uniline}" ]]; then
+ return
+ fi
+
+ # build our REST post
+ {
+ printf "{\"body\":\""
+ echo "${plugin}: ${text}" \
+ | ${SED} -e 's,\\,\\\\,g' \
+ -e 's,\",\\\",g' \
+ -e 's,$,\\r\\n,g' \
+ | tr -d '\n'
+ echo "\","
+ echo "\"commit_id\":\"${GITHUB_COMMITSHA}\","
+ echo "\"path\":\"${file}\","
+ echo "\"position\":${uniline}"
+ echo "}"
+ } > "${tempfile}"
+
+ if [[ -n "${GITHUB_USER}"
+ && -n "${GITHUB_PASSWD}" ]]; then
+ githubauth="${GITHUB_USER}:${GITHUB_PASSWD}"
+ elif [[ -n "${GITHUB_TOKEN}" ]]; then
+ githubauth="Authorization: token ${GITHUB_TOKEN}"
+ else
+ return 0
+ fi
+
+ ${CURL} -X POST \
+ -H "Accept: application/vnd.github.v3.full+json" \
+ -H "Content-Type: application/json" \
+ -H "${githubauth}" \
+ -d @"${tempfile}" \
+ --silent --location \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPO}/pulls/${GITHUB_ISSUE}/comments" \
+ >/dev/null
+ rm "${tempfile}"
+}
+
+## @description Write the contents of a file to github
+## @params filename
+## @stability stable
+## @audience public
+function github_write_comment
+{
+ declare -r commentfile=${1}
+ declare retval=0
+ declare restfile="${PATCH_DIR}/ghcomment.$$"
+ declare githubauth
+
+ if [[ "${OFFLINE}" == true ]]; then
+ echo "Github Plugin: Running in offline, comment skipped."
+ return 0
+ fi
+
+ {
+ printf "{\"body\":\""
+ ${SED} -e 's,\\,\\\\,g' \
+ -e 's,\",\\\",g' \
+ -e 's,$,\\r\\n,g' "${commentfile}" \
+ | tr -d '\n'
+ echo "\"}"
+ } > "${restfile}"
+
+ if [[ -n "${GITHUB_USER}"
+ && -n "${GITHUB_PASSWD}" ]]; then
+ githubauth="${GITHUB_USER}:${GITHUB_PASSWD}"
+ elif [[ -n "${GITHUB_TOKEN}" ]]; then
+ githubauth="Authorization: token ${GITHUB_TOKEN}"
+ else
+ echo "Github Plugin: no credentials provided to write a comment."
+ return 0
+ fi
+
+ ${CURL} -X POST \
+ -H "Accept: application/vnd.github.v3.full+json" \
+ -H "Content-Type: application/json" \
+ -H "${githubauth}" \
+ -d @"${restfile}" \
+ --silent --location \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPO}/issues/${GITHUB_ISSUE}/comments" \
+ >/dev/null
+
+ retval=$?
+ rm "${restfile}"
+ return ${retval}
+}
+
+## @description Print out the finished details to the Github PR
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param runresult
+function github_finalreport
+{
+ declare result=$1
+ declare i
+ declare commentfile=${PATCH_DIR}/gitcommentfile.$$
+ declare comment
+
+ rm "${commentfile}" 2>/dev/null
+
+ if [[ ${JENKINS} != "true"
+ || -z ${GITHUB_ISSUE} ]] ; then
+ return 0
+ fi
+
+ big_console_header "Adding comment to Github"
+
+ add_footer_table "Console output" "${BUILD_URL}console"
+
+ if [[ ${result} == 0 ]]; then
+ echo ":confetti_ball: **+1 overall**" >> "${commentfile}"
+ else
+ echo ":broken_heart: **-1 overall**" >> "${commentfile}"
+ fi
+
+ printf "\n\n\n\n" >> "${commentfile}"
+
+ i=0
+ until [[ ${i} -eq ${#TP_HEADER[@]} ]]; do
+ printf "%s\n\n" "${TP_HEADER[${i}]}" >> "${commentfile}"
+ ((i=i+1))
+ done
+
+ {
+ printf "\n\n"
+ echo "| Vote | Subsystem | Runtime | Comment |"
+ echo "|:----:|----------:|--------:|:--------|"
+ } >> "${commentfile}"
+
+ i=0
+ until [[ ${i} -eq ${#TP_VOTE_TABLE[@]} ]]; do
+ echo "${TP_VOTE_TABLE[${i}]}" >> "${commentfile}"
+ ((i=i+1))
+ done
+
+ if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
+ {
+ printf "\n\n"
+ echo "| Reason | Tests |"
+ echo "|-------:|:------|"
+ } >> "${commentfile}"
+ i=0
+ until [[ ${i} -eq ${#TP_TEST_TABLE[@]} ]]; do
+ echo "${TP_TEST_TABLE[${i}]}" >> "${commentfile}"
+ ((i=i+1))
+ done
+ fi
+
+ {
+ printf "\n\n"
+ echo "| Subsystem | Report/Notes |"
+ echo "|----------:|:-------------|"
+ } >> "${commentfile}"
+
+ i=0
+ until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
+ comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
+ ${SED} -e "s,@@BASE@@,${BUILD_URL}artifact/patchprocess,g")
+ printf "%s\n" "${comment}" >> "${commentfile}"
+ ((i=i+1))
+ done
+
+ printf "\n\nThis message was automatically generated.\n\n" >> "${commentfile}"
+
+ github_write_comment "${commentfile}"
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/gradle.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/gradle.sh b/precommit/test-patch.d/gradle.sh
new file mode 100755
index 0000000..56da8d5
--- /dev/null
+++ b/precommit/test-patch.d/gradle.sh
@@ -0,0 +1,263 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_build_tool gradle
+
+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')"
+}
+
+function gradle_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --gradle-cmd=*)
+ GRADLE=${i#*=}
+ ;;
+ --gradlew-cmd=*)
+ GRADLEW=${i#*=}
+ ;;
+ esac
+ done
+
+ # if we requested offline, pass that to mvn
+ if [[ ${OFFLINE} == "true" ]]; then
+ GRADLE_ARGS=("${GRADLE_ARGS[@]}" --offline)
+ fi
+
+ GRADLE=${GRADLE:-gradle}
+ GRADLEW=${GRADLEW:-"${BASEDIR}/gradlew"}
+}
+
+function gradle_initialize
+{
+ if [[ "${BUILDTOOL}" = gradle ]]; then
+ # shellcheck disable=SC2034
+ BUILDTOOLCWD=false
+ fi
+
+ # we need to do this before docker kicks in
+ if [[ -e "${HOME}/.gradle"
+ && ! -d "${HOME}/.gradle" ]]; then
+ yetus_error "ERROR: ${HOME}/.gradle is not a directory."
+ return 1
+ elif [[ ! -e "${HOME}/.gradle" ]]; then
+ yetus_debug "Creating ${HOME}/.gradle"
+ mkdir -p "${HOME}/.gradle"
+ fi
+}
+
+function gradle_buildfile
+{
+ echo "gradlew"
+}
+
+function gradle_executor
+{
+ echo "${GRADLEW}" "${GRADLE_ARGS[@]}"
+}
+
+## @description Bootstrap gradle
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function gradle_precompile
+{
+ declare repostatus=$1
+ declare result=0
+
+ if [[ ${BUILDTOOL} != gradle ]]; then
+ return 0
+ fi
+
+ if [[ "${repostatus}" = branch ]]; then
+ # shellcheck disable=SC2153
+ big_console_header "${PATCH_BRANCH} gradle bootstrap"
+ else
+ big_console_header "Patch gradle bootstrap"
+ fi
+
+ personality_modules "${repostatus}" gradleboot
+
+ pushd "${BASEDIR}" >/dev/null
+ echo_and_redirect "${PATCH_DIR}/${repostatus}-gradle-bootstrap.txt" gradle -b bootstrap.gradle
+ popd >/dev/null
+
+ modules_workers "${repostatus}" gradleboot
+ result=$?
+ modules_messages "${repostatus}" gradleboot true
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function gradle_scalac_count_probs
+{
+ local warningfile=$1
+
+ #shellcheck disable=SC2016,SC2046
+ ${GREP} "^/.*.scala:[0-9]*:" "${warningfile}" | wc -l
+}
+
+function gradle_javac_count_probs
+{
+ echo 0
+}
+
+function gradle_javadoc_count_probs
+{
+ echo 0
+}
+
+## @description Helper for check_patch_javadoc
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function gradle_scaladoc_count_probs
+{
+ local warningfile=$1
+
+ #shellcheck disable=SC2016,SC2046
+ ${GREP} "^\[ant:scaladoc\]" "${warningfile}" | wc -l
+}
+
+function gradle_modules_worker
+{
+ declare repostatus=$1
+ declare tst=$2
+ shift 2
+
+ # shellcheck disable=SC2034
+ UNSUPPORTED_TEST=false
+
+ case ${tst} in
+ checkstyle)
+ modules_workers "${repostatus}" "${tst}" checkstyleMain checkstyleTest
+ ;;
+ compile)
+ modules_workers "${repostatus}" "${tst}"
+ ;;
+ distclean)
+ modules_workers "${repostatus}" clean
+ ;;
+ javadoc)
+ modules_workers "${repostatus}" "${tst}" javadoc
+ ;;
+ scaladoc)
+ modules_workers "${repostatus}" "${tst}" scaladoc
+ ;;
+ unit)
+ modules_workers "${repostatus}" "${tst}" test
+ ;;
+ *)
+ # shellcheck disable=SC2034
+ UNSUPPORTED_TEST=true
+ if [[ ${repostatus} = patch ]]; then
+ add_footer_table "${tst}" "not supported by the ${BUILDTOOL} plugin"
+ fi
+ yetus_error "WARNING: ${tst} is unsupported by ${BUILDTOOL}"
+ return 1
+ ;;
+ esac
+}
+
+function gradle_builtin_personality_modules
+{
+ local repostatus=$1
+ local testtype=$2
+
+ local module
+
+ yetus_debug "Using builtin personality_modules"
+ yetus_debug "Personality: ${repostatus} ${testtype}"
+
+ clear_personality_queue
+
+ for module in ${CHANGED_MODULES}; do
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module}
+ done
+}
+
+function gradle_builtin_personality_file_tests
+{
+ local filename=$1
+
+ yetus_debug "Using builtin gradle personality_file_tests"
+
+ if [[ ${filename} =~ src/main/webapp ]]; then
+ yetus_debug "tests/webapp: ${filename}"
+ elif [[ ${filename} =~ \.sh
+ || ${filename} =~ \.cmd
+ || ${filename} =~ src/main/scripts
+ || ${filename} =~ src/test/scripts
+ ]]; then
+ yetus_debug "tests/shell: ${filename}"
+ elif [[ ${filename} =~ \.c$
+ || ${filename} =~ \.cc$
+ || ${filename} =~ \.h$
+ || ${filename} =~ \.hh$
+ || ${filename} =~ \.proto$
+ || ${filename} =~ \.cmake$
+ || ${filename} =~ CMakeLists.txt
+ ]]; then
+ yetus_debug "tests/units: ${filename}"
+ add_test cc
+ add_test unit
+ elif [[ ${filename} =~ \.scala$ ]]; then
+ add_test scalac
+ add_test scaladoc
+ add_test unit
+ elif [[ ${filename} =~ build.xml$
+ || ${filename} =~ pom.xml$
+ || ${filename} =~ \.java$
+ ]]; then
+ yetus_debug "tests/javadoc+units: ${filename}"
+ add_test javac
+ add_test javadoc
+ add_test unit
+ elif [[ ${filename} =~ src/main ]]; then
+ yetus_debug "tests/generic+units: ${filename}"
+ add_test compile
+ add_test unit
+ fi
+
+ if [[ ${filename} =~ src/test ]]; then
+ yetus_debug "tests"
+ add_test unit
+ fi
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ add_test findbugs
+ fi
+}
+
+function gradle_docker_support
+{
+ echo "-v ${HOME}/.gradle:${HOME}/.gradle" > "${PATCH_DIR}/buildtool-docker-params.txt"
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/java.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/java.sh b/precommit/test-patch.d/java.sh
new file mode 100755
index 0000000..e1a73c7
--- /dev/null
+++ b/precommit/test-patch.d/java.sh
@@ -0,0 +1,168 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type javac
+add_test_type javadoc
+
+function javac_initialize
+{
+ local i
+ local jdkdir
+ local tmplist
+
+ # if we are in pre-docker mode, don't do any of
+ # this work since it's all going to be wrong anyway
+ if [[ "${DOCKERSUPPORT}" = "true" ]]; then
+ return 0
+ fi
+
+ if [[ -z ${JAVA_HOME:-} ]]; then
+ case ${OSTYPE} in
+ Darwin)
+ if [[ -z "${JAVA_HOME}" ]]; then
+ if [[ -x /usr/libexec/java_home ]]; then
+ JAVA_HOME="$(/usr/libexec/java_home)"
+ export JAVA_HOME
+ else
+ export JAVA_HOME=/Library/Java/Home
+ fi
+ fi
+ ;;
+ *)
+ yetus_error "WARNING: JAVA_HOME not defined. Disabling java tests."
+ delete_test javac
+ delete_test javadoc
+ return 1
+ ;;
+ esac
+ fi
+
+ JAVA_HOME=$(cd -P -- "${JAVA_HOME}" >/dev/null && pwd -P)
+
+ for i in ${JDK_DIR_LIST}; do
+ if [[ -d "${i}" ]]; then
+ jdkdir=$(cd -P -- "${i}" >/dev/null && pwd -P)
+ if [[ ${jdkdir} != "${JAVA_HOME}" ]]; then
+ tmplist="${tmplist} ${jdkdir}"
+ fi
+ else
+ yetus_error "WARNING: Cannot locate JDK directory ${i}: ignoring"
+ fi
+ done
+
+ JDK_DIR_LIST="${tmplist} ${JAVA_HOME}"
+ JDK_DIR_LIST=${JDK_DIR_LIST/ }
+}
+
+## @description Verify that ${JAVA_HOME} is defined
+## @audience public
+## @stability stable
+## @replaceable no
+## @return 1 - no JAVA_HOME
+## @return 0 - JAVA_HOME defined
+function javac_precheck
+{
+ declare javaversion
+ declare listofjdks
+ declare i
+
+ start_clock
+
+ if [[ -z ${JAVA_HOME:-} ]]; then
+ yetus_error "ERROR: JAVA_HOME is not defined."
+ add_vote_table -1 pre-patch "JAVA_HOME is not defined."
+ return 1
+ fi
+
+ javaversion=$(report_jvm_version "${JAVA_HOME}")
+ add_footer_table "Default Java" "${javaversion}"
+
+ if [[ -n ${JDK_DIR_LIST}
+ && ${JDK_DIR_LIST} != "${JAVA_HOME}" ]]; then
+ for i in ${JDK_DIR_LIST}; do
+ javaversion=$(report_jvm_version "${i}")
+ listofjdks="${listofjdks} ${i}:${javaversion}"
+ done
+ add_footer_table "Multi-JDK versions" "${listofjdks}"
+ fi
+ return 0
+}
+
+function javac_filefilter
+{
+ declare filename=$1
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ yetus_debug "tests/javac: ${filename}"
+ add_test javac
+ add_test compile
+ fi
+}
+
+function javadoc_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ yetus_debug "tests/javadoc: ${filename}"
+ add_test javadoc
+ fi
+}
+
+## @description
+## @audience private
+## @stability stable
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function javac_compile
+{
+ declare codebase=$1
+ declare multijdkmode=$2
+
+ verify_needed_test javac
+ if [[ $? = 0 ]]; then
+ return 0
+ fi
+
+ if [[ ${codebase} = patch ]]; then
+ yetus_debug "javac: calling generic_postlog_compare compile javac ${multijdkmode}"
+ generic_postlog_compare compile javac "${multijdkmode}"
+ fi
+}
+
+## @description Count and compare the number of JavaDoc warnings pre- and post- patch
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function javadoc_rebuild
+{
+ declare codebase=$1
+ declare multijdkmode
+
+ verify_multijdk_test javadoc
+ if [[ $? == 1 ]]; then
+ multijdkmode=true
+ fi
+
+ if [[ "${codebase}" = branch ]]; then
+ generic_pre_handler javadoc "${multijdkmode}"
+ else
+ generic_post_handler javadoc javadoc "${multijdkmode}" true
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/jira.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/jira.sh b/precommit/test-patch.d/jira.sh
new file mode 100755
index 0000000..e5fd550
--- /dev/null
+++ b/precommit/test-patch.d/jira.sh
@@ -0,0 +1,436 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# this bug system handles JIRA. Personalities
+# can override the following variables:
+
+# base JIRA URL
+JIRA_URL=${JIRA_URL:-"https://issues.apache.org/jira"}
+
+# Issue regex to help identify the project
+JIRA_ISSUE_RE=''
+
+# If the issue status is matched with this pattern, the attached patch is regarded as ready to be applied
+JIRA_STATUS_RE='Patch Available'
+
+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"
+}
+
+function jira_parse_args
+{
+ declare i
+
+ for i in "$@"; do
+ case ${i} in
+ --jira-base-url=*)
+ JIRA_URL=${i#*=}
+ ;;
+ --jira-issue-re=*)
+ JIRA_ISSUE_RE=${i#*=}
+ ;;
+ --jira-password=*)
+ JIRA_PASSWD=${i#*=}
+ ;;
+ --jira-status-re=*)
+ JIRA_STATUS_RE=${i#*=}
+ ;;
+ --jira-user=*)
+ JIRA_USER=${i#*=}
+ ;;
+ esac
+ done
+}
+
+## @description provides issue determination based upon the URL and more.
+## @description WARNING: called from the github plugin!
+function jira_determine_issue
+{
+ declare input=$1
+ declare patchnamechunk
+ declare maybeissue
+
+ if [[ -n ${JIRA_ISSUE} ]]; then
+ return 0
+ fi
+
+ # shellcheck disable=SC2016
+ patchnamechunk=$(echo "${input}" | ${AWK} -F/ '{print $NF}')
+
+ maybeissue=$(echo "${patchnamechunk}" | cut -f1,2 -d-)
+
+ if [[ ${maybeissue} =~ ${JIRA_ISSUE_RE} ]]; then
+ # shellcheck disable=SC2034
+ ISSUE=${maybeissue}
+ JIRA_ISSUE=${maybeissue}
+ add_footer_table "JIRA Issue" "${JIRA_ISSUE}"
+ return 0
+ fi
+
+ return 1
+}
+
+function jira_http_fetch
+{
+ declare input=$1
+ declare output=$2
+
+ if [[ -n "${JIRA_USER}"
+ && -n "${JIRA_PASSWD}" ]]; then
+ ${CURL} --silent --fail \
+ --user "${JIRA_USER}:${JIRA_PASSWD}" \
+ --output "${output}" \
+ --location \
+ "${JIRA_URL}/${input}"
+ else
+ ${CURL} --silent --fail \
+ --output "${output}" \
+ --location \
+ "${JIRA_URL}/${input}"
+ fi
+}
+
+function jira_locate_patch
+{
+ declare input=$1
+ declare fileloc=$2
+ declare relativeurl
+
+ yetus_debug "jira_locate_patch: trying ${JIRA_URL}/browse/${input}"
+
+ if [[ "${OFFLINE}" == true ]]; then
+ yetus_debug "jira_locate_patch: offline, skipping"
+ return 1
+ fi
+
+ jira_http_fetch "browse/${input}" "${PATCH_DIR}/jira"
+
+ if [[ $? != 0 ]]; then
+ yetus_debug "jira_locate_patch: not a JIRA."
+ return 1
+ fi
+
+ # if github is configured and we see what looks like a URL,
+ # send this to the github plugin to process.
+ if [[ -n "${GITHUB_BASE_URL}"
+ && $(${GREP} -c "${GITHUB_BASE_URL}"'[^ ]*patch' "${PATCH_DIR}/jira") != 0 ]]; then
+ jira_determine_issue "${input}"
+ echo "${input} appears to be a Github PR. Switching Modes."
+ github_jira_bridge "${fileloc}"
+ return $?
+ elif [[ $(${GREP} -c "${JIRA_STATUS_RE}" "${PATCH_DIR}/jira") == 0 ]]; then
+ if [[ ${JENKINS} == true ]]; then
+ yetus_error "ERROR: ${input} issue status is not matched with \"${JIRA_STATUS_RE}\"."
+ cleanup_and_exit 1
+ else
+ yetus_error "WARNING: ${input} issue status is not matched with \"${JIRA_STATUS_RE}\"."
+ fi
+ fi
+
+ #shellcheck disable=SC2016
+ relativeurl=$(${AWK} 'match($0,"/secure/attachment/[0-9]*/[^\"]*"){print substr($0,RSTART,RLENGTH)}' "${PATCH_DIR}/jira" |
+ ${GREP} -v -e 'htm[l]*$' | sort | tail -1 | ${SED} -e 's,[ ]*$,,g')
+ PATCHURL="${JIRA_URL}${relativeurl}"
+ if [[ ! ${PATCHURL} =~ \.patch$ ]]; then
+ guess_patch_file "${PATCH_DIR}/patch"
+ if [[ $? == 0 ]]; then
+ yetus_debug "The patch ${PATCHURL} was not named properly, but it looks like a patch file. Proceeding, but issue/branch matching might go awry."
+ add_vote_table 0 patch "The patch file was not named according to ${PROJECT_NAME}'s naming conventions. Please see ${HOW_TO_CONTRIBUTE} for instructions."
+ fi
+ fi
+ echo "${input} patch is being downloaded at $(date) from"
+ echo "${PATCHURL}"
+ add_footer_table "JIRA Patch URL" "${PATCHURL}"
+ jira_http_fetch "${relativeurl}" "${fileloc}"
+ if [[ $? != 0 ]];then
+ yetus_error "ERROR: ${input}/${PATCHURL} could not be downloaded."
+ cleanup_and_exit 1
+ fi
+ return 0
+}
+
+## @description Try to guess the branch being tested using a variety of heuristics
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success, with PATCH_BRANCH updated appropriately
+function jira_determine_branch
+{
+ declare patchnamechunk
+ declare total
+ declare count
+ declare hinttype
+
+ for hinttype in "${PATCHURL}" "${PATCH_OR_ISSUE}"; do
+ if [[ -z "${hinttype}" ]]; then
+ continue
+ fi
+
+ # If one of these matches the JIRA issue regex
+ # then we don't want it to trigger the branch
+ # detection since that's almost certainly not
+ # intended. In other words, if ISSUE-99 is the
+ # name of a branch, you want to test ISSUE-99
+ # against master, not ISSUE-99's branch
+ if [[ ${hinttype} =~ ${JIRA_ISSUE_RE} ]]; then
+ continue
+ fi
+
+ yetus_debug "Determine branch: starting with ${hinttype}"
+ patchnamechunk=$(echo "${hinttype}" \
+ | ${SED} -e 's,.*/\(.*\)$,\1,' \
+ -e 's,\.txt,.,' \
+ -e 's,.patch,.,g' \
+ -e 's,.diff,.,g' \
+ -e 's,\.\.,.,g' \
+ -e 's,\.$,,g' )
+
+ # ISSUE-branch-##
+ PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1,2 -d-)
+ yetus_debug "Determine branch: ISSUE-branch-## = ${PATCH_BRANCH}"
+ if [[ -n "${PATCH_BRANCH}" ]]; then
+ verify_valid_branch "${PATCH_BRANCH}"
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+ fi
+
+ # ISSUE-##[.##].branch
+ PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d. )
+ count="${PATCH_BRANCH//[^.]}"
+ total=${#count}
+ ((total = total + 3 ))
+ until [[ ${total} -lt 3 ]]; do
+ PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3-${total} -d.)
+ yetus_debug "Determine branch: ISSUE[.##].branch = ${PATCH_BRANCH}"
+ ((total=total-1))
+ if [[ -n "${PATCH_BRANCH}" ]]; then
+ verify_valid_branch "${PATCH_BRANCH}"
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+ fi
+ done
+
+ # ISSUE.branch.##
+ PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f2- -d. )
+ count="${PATCH_BRANCH//[^.]}"
+ total=${#count}
+ ((total = total + 3 ))
+ until [[ ${total} -lt 2 ]]; do
+ PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f2-${total} -d.)
+ yetus_debug "Determine branch: ISSUE.branch[.##] = ${PATCH_BRANCH}"
+ ((total=total-1))
+ if [[ -n "${PATCH_BRANCH}" ]]; then
+ verify_valid_branch "${PATCH_BRANCH}"
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+ fi
+ done
+
+ # ISSUE-branch.##
+ PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1- -d. )
+ count="${PATCH_BRANCH//[^.]}"
+ total=${#count}
+ ((total = total + 1 ))
+ until [[ ${total} -lt 1 ]]; do
+ PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1-${total} -d. )
+ yetus_debug "Determine branch: ISSUE-branch[.##] = ${PATCH_BRANCH}"
+ ((total=total-1))
+ if [[ -n "${PATCH_BRANCH}" ]]; then
+ verify_valid_branch "${PATCH_BRANCH}"
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+ fi
+ done
+ done
+
+ return 1
+}
+
+## @description Write the contents of a file to JIRA
+## @params filename
+## @stability stable
+## @audience public
+## @returns exit code from posting to jira
+function jira_write_comment
+{
+ declare -r commentfile=${1}
+ declare retval=0
+
+ if [[ "${OFFLINE}" == true ]]; then
+ echo "JIRA Plugin: Running in offline, comment skipped."
+ return 0
+ fi
+
+ if [[ -n ${JIRA_PASSWD}
+ && -n ${JIRA_USER} ]]; then
+
+ # RESTify the comment
+ {
+ echo "{\"body\":\""
+ ${SED} -e 's,\\,\\\\,g' \
+ -e 's,\",\\\",g' \
+ -e 's,$,\\r\\n,g' "${commentfile}" \
+ | tr -d '\n'
+ echo "\"}"
+ } > "${PATCH_DIR}/jiracomment.$$"
+
+ ${CURL} -X POST \
+ -H "Accept: application/json" \
+ -H "Content-Type: application/json" \
+ -u "${JIRA_USER}:${JIRA_PASSWD}" \
+ -d @"${PATCH_DIR}/jiracomment.$$" \
+ --silent --location \
+ "${JIRA_URL}/rest/api/2/issue/${JIRA_ISSUE}/comment" \
+ >/dev/null
+ retval=$?
+ rm "${PATCH_DIR}/jiracomment.$$"
+ else
+ echo "JIRA Plugin: no credentials provided to write a comment."
+ fi
+ return ${retval}
+}
+
+## @description Print out the finished details to the JIRA issue
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param runresult
+function jira_finalreport
+{
+ declare result=$1
+ declare i
+ declare commentfile=${PATCH_DIR}/jiracommentfile
+ declare comment
+ declare vote
+ declare ourstring
+ declare ela
+ declare subs
+ declare color
+ declare comment
+
+ rm "${commentfile}" 2>/dev/null
+
+ if [[ ${JENKINS} == "false"
+ || ${OFFLINE} == true ]] ; then
+ return 0
+ fi
+
+ if [[ -z "${JIRA_ISSUE}" ]]; then
+ return 0
+ fi
+
+ big_console_header "Adding comment to JIRA"
+
+ add_footer_table "Console output" "${BUILD_URL}console"
+
+ if [[ ${result} == 0 ]]; then
+ echo "| (/) *{color:green}+1 overall{color}* |" >> "${commentfile}"
+ else
+ echo "| (x) *{color:red}-1 overall{color}* |" >> "${commentfile}"
+ fi
+
+ echo "\\\\" >> "${commentfile}"
+
+ i=0
+ until [[ $i -eq ${#TP_HEADER[@]} ]]; do
+ printf "%s\n" "${TP_HEADER[${i}]}" >> "${commentfile}"
+ ((i=i+1))
+ done
+
+ echo "\\\\" >> "${commentfile}"
+
+ echo "|| Vote || Subsystem || Runtime || Comment ||" >> "${commentfile}"
+
+ i=0
+ until [[ $i -eq ${#TP_VOTE_TABLE[@]} ]]; do
+ ourstring=$(echo "${TP_VOTE_TABLE[${i}]}" | tr -s ' ')
+ vote=$(echo "${ourstring}" | cut -f2 -d\| | tr -d ' ')
+ subs=$(echo "${ourstring}" | cut -f3 -d\|)
+ ela=$(echo "${ourstring}" | cut -f4 -d\|)
+ comment=$(echo "${ourstring}" | cut -f5 -d\|)
+
+ # summary line
+ if [[ -z ${vote}
+ && -n ${ela} ]]; then
+ color="black"
+ elif [[ -z ${vote} ]]; then
+ # keep same color
+ true
+ else
+ # new vote line
+ case ${vote} in
+ 1|"+1")
+ color="green"
+ ;;
+ -1)
+ color="red"
+ ;;
+ 0)
+ color="blue"
+ ;;
+ *)
+ color="black"
+ ;;
+ esac
+ fi
+
+ printf "| {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} | {color:%s}%s{color} |\n" \
+ "${color}" "${vote}" \
+ "${color}" "${subs}" \
+ "${color}" "${ela}" \
+ "${color}" "${comment}" \
+ >> "${commentfile}"
+ ((i=i+1))
+ done
+
+ if [[ ${#TP_TEST_TABLE[@]} -gt 0 ]]; then
+ { echo "\\\\" ; echo "\\\\"; } >> "${commentfile}"
+
+ echo "|| Reason || Tests ||" >> "${commentfile}"
+ i=0
+ until [[ $i -eq ${#TP_TEST_TABLE[@]} ]]; do
+ printf "%s\n" "${TP_TEST_TABLE[${i}]}" >> "${commentfile}"
+ ((i=i+1))
+ done
+ fi
+
+ { echo "\\\\" ; echo "\\\\"; } >> "${commentfile}"
+
+ echo "|| Subsystem || Report/Notes ||" >> "${commentfile}"
+ i=0
+ until [[ $i -eq ${#TP_FOOTER_TABLE[@]} ]]; do
+ comment=$(echo "${TP_FOOTER_TABLE[${i}]}" |
+ ${SED} -e "s,@@BASE@@,${BUILD_URL}artifact/patchprocess,g")
+ printf "%s\n" "${comment}" >> "${commentfile}"
+ ((i=i+1))
+ done
+
+ printf "\n\nThis message was automatically generated.\n\n" >> "${commentfile}"
+
+ jira_write_comment "${commentfile}"
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/junit.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/junit.sh b/precommit/test-patch.d/junit.sh
new file mode 100755
index 0000000..4393511
--- /dev/null
+++ b/precommit/test-patch.d/junit.sh
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_format junit
+
+JUNIT_TEST_TIMEOUTS=""
+JUNIT_FAILED_TESTS=""
+
+function junit_process_tests
+{
+ # shellcheck disable=SC2034
+ declare module=$1
+ declare buildlogfile=$2
+ declare result=0
+ declare module_test_timeouts
+ declare module_failed_tests
+
+ # shellcheck disable=SC2016
+ module_test_timeouts=$(${AWK} '/^Running / { array[$NF] = 1 } /^Tests run: .* in / { delete array[$NF] } END { for (x in array) { print x } }' "${buildlogfile}")
+ if [[ -n "${module_test_timeouts}" ]] ; then
+ JUNIT_TEST_TIMEOUTS="${JUNIT_TEST_TIMEOUTS} ${module_test_timeouts}"
+ ((result=result+1))
+ fi
+
+ #shellcheck disable=SC2026,SC2038,SC2016
+ module_failed_tests=$(find . -name 'TEST*.xml'\
+ | xargs "${GREP}" -l -E "<failure|<error"\
+ | ${AWK} -F/ '{sub("TEST-org.apache.",""); sub(".xml",""); print $NF}')
+
+ if [[ -n "${module_failed_tests}" ]] ; then
+ JUNIT_FAILED_TESTS="${JUNIT_FAILED_TESTS} ${module_failed_tests}"
+ ((result=result+1))
+ fi
+
+ if [[ ${result} -gt 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function junit_finalize_results
+{
+ declare jdk=$1
+
+ if [[ -n "${JUNIT_FAILED_TESTS}" ]] ; then
+ # shellcheck disable=SC2086
+ populate_test_table "${jdk}Failed junit tests" ${JUNIT_FAILED_TESTS}
+ JUNIT_FAILED_TESTS=""
+ fi
+ if [[ -n "${JUNIT_TEST_TIMEOUTS}" ]] ; then
+ # shellcheck disable=SC2086
+ populate_test_table "${jdk}Timed out junit tests" ${JUNIT_TEST_TIMEOUTS}
+ JUNIT_TEST_TIMEOUTS=""
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/maven.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/maven.sh b/precommit/test-patch.d/maven.sh
new file mode 100755
index 0000000..019b64d
--- /dev/null
+++ b/precommit/test-patch.d/maven.sh
@@ -0,0 +1,440 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare -a MAVEN_ARGS=("--batch-mode")
+
+if [[ -z "${MAVEN_HOME:-}" ]]; then
+ MAVEN=mvn
+else
+ MAVEN=${MAVEN_HOME}/bin/mvn
+fi
+
+MAVEN_CUSTOM_REPOS=false
+MAVEN_CUSTOM_REPOS_DIR="${HOME}/yetus-m2"
+
+add_test_type mvnsite
+add_test_type mvneclipse
+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"
+}
+
+function maven_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --mvn-cmd=*)
+ MAVEN=${i#*=}
+ ;;
+ --mvn-custom-repos)
+ MAVEN_CUSTOM_REPOS=true
+ ;;
+ --mvn-custom-repos-dir=*)
+ MAVEN_CUSTOM_REPOS_DIR=${i#*=}
+ ;;
+ --mvn-settings=*)
+ MAVEN_SETTINGS=${i#*=}
+ if [[ -f ${MAVEN_SETTINGS} ]]; then
+ MAVEN_ARGS=("${MAVEN_ARGS[@]}" "--settings=${MAVEN_SETTINGS}")
+ else
+ yetus_error "WARNING: ${MAVEN_SETTINGS} not found. Ignorning."
+ fi
+ ;;
+ esac
+ done
+
+ if [[ ${OFFLINE} == "true" ]]; then
+ MAVEN_ARGS=("${MAVEN_ARGS[@]}" --offline)
+ fi
+}
+
+function maven_initialize
+{
+ # we need to do this before docker does it as root
+
+ if [[ ! ${MAVEN_CUSTOM_REPOS_DIR} =~ ^/ ]]; then
+ yetus_error "ERROR: --mvn-custom-repos-dir must be an absolute path."
+ return 1
+ fi
+
+ if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
+ MAVEN_LOCAL_REPO="${MAVEN_CUSTOM_REPOS_DIR}"
+ if [[ -e "${MAVEN_CUSTOM_REPOS_DIR}"
+ && ! -d "${MAVEN_CUSTOM_REPOS_DIR}" ]]; then
+ yetus_error "ERROR: ${MAVEN_CUSTOM_REPOS_DIR} is not a directory."
+ return 1
+ elif [[ ! -d "${MAVEN_CUSTOM_REPOS_DIR}" ]]; then
+ yetus_debug "Creating ${MAVEN_CUSTOM_REPOS_DIR}"
+ mkdir -p "${MAVEN_CUSTOM_REPOS_DIR}"
+ fi
+ fi
+
+ if [[ -e "${HOME}/.m2"
+ && ! -d "${HOME}/.m2" ]]; then
+ yetus_error "ERROR: ${HOME}/.m2 is not a directory."
+ return 1
+ elif [[ ! -e "${HOME}/.m2" ]]; then
+ yetus_debug "Creating ${HOME}/.m2"
+ mkdir -p "${HOME}/.m2"
+ fi
+}
+
+function maven_precheck
+{
+ declare logfile="${PATCH_DIR}/mvnrepoclean.log"
+ declare line
+
+ if [[ ! ${MAVEN_CUSTOM_REPOS_DIR} =~ ^/ ]]; then
+ yetus_error "ERROR: --mvn-custom-repos-dir must be an absolute path."
+ return 1
+ fi
+
+ if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
+ MAVEN_LOCAL_REPO="${MAVEN_CUSTOM_REPOS_DIR}/${PROJECT_NAME}-${PATCH_BRANCH}-${INSTANCE}"
+ if [[ -e "${MAVEN_LOCAL_REPO}"
+ && ! -d "${MAVEN_LOCAL_REPO}" ]]; then
+ yetus_error "ERROR: ${MAVEN_LOCAL_REPO} is not a directory."
+ return 1
+ fi
+
+ if [[ ! -d "${MAVEN_LOCAL_REPO}" ]]; then
+ yetus_debug "Creating ${MAVEN_LOCAL_REPO}"
+ mkdir -p "${MAVEN_LOCAL_REPO}"
+ if [[ $? -ne 0 ]]; then
+ yetus_error "ERROR: Unable to create ${MAVEN_LOCAL_REPO}"
+ return 1
+ fi
+ fi
+ touch "${MAVEN_LOCAL_REPO}"
+
+ # if we have a local settings.xml file, we copy it.
+ if [[ -f "${HOME}/.m2/settings.xml" ]]; then
+ cp -p "${HOME}/.m2/settings.xml" "${MAVEN_LOCAL_REPO}"
+ fi
+ MAVEN_ARGS=("${MAVEN_ARGS[@]}" "-Dmaven.repo.local=${MAVEN_LOCAL_REPO}")
+
+ # let's do some cleanup while we're here
+
+ find "${MAVEN_CUSTOM_REPOS_DIR}" \
+ -name '*-*-*' \
+ -type d \
+ -mtime +30 \
+ -maxdepth 1 \
+ -print \
+ > "${logfile}"
+
+ while read -r line; do
+ echo "Removing old maven repo ${line}"
+ rm -rf "${line}"
+ done < "${logfile}"
+ fi
+}
+
+function maven_buildfile
+{
+ echo "pom.xml"
+}
+
+function maven_executor
+{
+ echo "${MAVEN}" "${MAVEN_ARGS[@]}"
+}
+
+function mvnsite_filefilter
+{
+ local filename=$1
+
+ if [[ ${BUILDTOOL} = maven ]]; then
+ if [[ ${filename} =~ src/site ]]; then
+ yetus_debug "tests/mvnsite: ${filename}"
+ add_test mvnsite
+ fi
+ fi
+}
+
+function maven_modules_worker
+{
+ declare repostatus=$1
+ declare tst=$2
+
+ # shellcheck disable=SC2034
+ UNSUPPORTED_TEST=false
+
+ case ${tst} in
+ findbugs)
+ modules_workers "${repostatus}" findbugs test-compile findbugs:findbugs -DskipTests=true
+ ;;
+ compile)
+ modules_workers "${repostatus}" compile clean test-compile -DskipTests=true
+ ;;
+ distclean)
+ modules_workers "${repostatus}" distclean clean -DskipTests=true
+ ;;
+ javadoc)
+ modules_workers "${repostatus}" javadoc clean javadoc:javadoc -DskipTests=true
+ ;;
+ scaladoc)
+ modules_workers "${repostatus}" scaladoc clean scala:doc -DskipTests=true
+ ;;
+ unit)
+ modules_workers "${repostatus}" unit clean test -fae
+ ;;
+ *)
+ # shellcheck disable=SC2034
+ UNSUPPORTED_TEST=true
+ if [[ ${repostatus} = patch ]]; then
+ add_footer_table "${tst}" "not supported by the ${BUILDTOOL} plugin"
+ fi
+ yetus_error "WARNING: ${tst} is unsupported by ${BUILDTOOL}"
+ return 1
+ ;;
+ esac
+}
+
+function maven_javac_count_probs
+{
+ local warningfile=$1
+
+ #shellcheck disable=SC2016,SC2046
+ ${GREP} '\[WARNING\]' "${warningfile}" | ${AWK} '{sum+=1} END {print sum}'
+}
+
+function maven_scalac_count_probs
+{
+ echo 0
+}
+
+## @description Helper for check_patch_javadoc
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function maven_javadoc_count_probs
+{
+ local warningfile=$1
+
+ #shellcheck disable=SC2016,SC2046
+ ${GREP} -E "^[0-9]+ warnings?$" "${warningfile}" | ${AWK} '{sum+=$1} END {print sum}'
+}
+
+function maven_builtin_personality_modules
+{
+ local repostatus=$1
+ local testtype=$2
+
+ local module
+
+ yetus_debug "Using builtin personality_modules"
+ yetus_debug "Personality: ${repostatus} ${testtype}"
+
+ clear_personality_queue
+
+ # this always makes sure the local repo has a fresh
+ # copy of everything per pom rules.
+ if [[ ${repostatus} == branch
+ && ${testtype} == mvninstall ]];then
+ personality_enqueue_module .
+ return
+ fi
+
+ for module in ${CHANGED_MODULES}; do
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module}
+ done
+}
+
+function maven_builtin_personality_file_tests
+{
+ local filename=$1
+
+ yetus_debug "Using builtin mvn personality_file_tests"
+
+ if [[ ${filename} =~ src/main/webapp ]]; then
+ yetus_debug "tests/webapp: ${filename}"
+ elif [[ ${filename} =~ \.sh
+ || ${filename} =~ \.cmd
+ || ${filename} =~ src/main/scripts
+ || ${filename} =~ src/test/scripts
+ ]]; then
+ yetus_debug "tests/shell: ${filename}"
+ elif [[ ${filename} =~ \.c$
+ || ${filename} =~ \.cc$
+ || ${filename} =~ \.h$
+ || ${filename} =~ \.hh$
+ || ${filename} =~ \.proto$
+ || ${filename} =~ \.cmake$
+ || ${filename} =~ CMakeLists.txt
+ ]]; then
+ yetus_debug "tests/units: ${filename}"
+ add_test cc
+ add_test unit
+ elif [[ ${filename} =~ \.scala$
+ || ${filename} =~ src/scala ]]; then
+ add_test scalac
+ add_test scaladoc
+ add_test unit
+ elif [[ ${filename} =~ build.xml$
+ || ${filename} =~ pom.xml$
+ || ${filename} =~ \.java$
+ || ${filename} =~ src/main
+ ]]; then
+ yetus_debug "tests/javadoc+units: ${filename}"
+ add_test javac
+ add_test javadoc
+ add_test unit
+ fi
+
+ if [[ ${filename} =~ src/test ]]; then
+ yetus_debug "tests"
+ add_test unit
+ fi
+
+ if [[ ${filename} =~ \.java$ ]]; then
+ add_test findbugs
+ fi
+}
+
+## @description Confirm site pre-patch
+## @audience private
+## @stability stable
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function mvnsite_postcompile
+{
+ declare repostatus=$1
+ declare result=0
+
+ if [[ ${BUILDTOOL} != maven ]]; then
+ return 0
+ fi
+
+ verify_needed_test mvnsite
+ if [[ $? == 0 ]];then
+ return 0
+ fi
+
+ if [[ "${repostatus}" = branch ]]; then
+ big_console_header "Pre-patch ${PATCH_BRANCH} maven site verification"
+ else
+ big_console_header "Patch maven site verification"
+ fi
+
+
+ personality_modules "${repostatus}" mvnsite
+ modules_workers "${repostatus}" mvnsite clean site site:stage
+ result=$?
+ modules_messages "${repostatus}" mvnsite true
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Make sure Maven's eclipse generation works.
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function mvneclipse_postcompile
+{
+ declare repostatus=$1
+ declare result=0
+
+ if [[ ${BUILDTOOL} != maven ]]; then
+ return 0
+ fi
+
+ verify_needed_test javac
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ if [[ "${repostatus}" = branch ]]; then
+ big_console_header "Pre-patch ${PATCH_BRANCH} maven eclipse verification"
+ else
+ big_console_header "Patch maven eclipse verification"
+ fi
+
+ personality_modules "${repostatus}" mvneclipse
+ modules_workers "${repostatus}" mvneclipse eclipse:clean eclipse:eclipse
+ result=$?
+ modules_messages "${repostatus}" mvneclipse true
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+## @description Verify mvn install works
+## @audience private
+## @stability evolving
+## @replaceable no
+## @return 0 on success
+## @return 1 on failure
+function maven_precompile
+{
+ declare repostatus=$1
+ declare result=0
+
+ if [[ ${BUILDTOOL} != maven ]]; then
+ return 0
+ fi
+
+ verify_needed_test javadoc
+ result=$?
+
+ verify_needed_test javac
+ ((result = result + $? ))
+ if [[ ${result} == 0 ]]; then
+ return 0
+ fi
+
+ if [[ "${repostatus}" = branch ]]; then
+ big_console_header "Pre-patch ${PATCH_BRANCH} maven install"
+ else
+ big_console_header "Patch maven install"
+ fi
+
+ personality_modules "${repostatus}" mvninstall
+ modules_workers "${repostatus}" mvninstall -fae clean install -DskipTests=true -Dmaven.javadoc.skip=true
+ result=$?
+ modules_messages "${repostatus}" mvninstall true
+ if [[ ${result} != 0 ]]; then
+ return 1
+ fi
+ return 0
+}
+
+function maven_docker_support
+{
+ echo "-v ${HOME}/.m2:${HOME}/.m2" > "${PATCH_DIR}/buildtool-docker-params.txt"
+
+ if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
+ echo "-v ${MAVEN_CUSTOM_REPOS_DIR}:${MAVEN_CUSTOM_REPOS_DIR}" \
+ >> "${PATCH_DIR}/buildtool-docker-params.txt"
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/nobuild.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/nobuild.sh b/precommit/test-patch.d/nobuild.sh
new file mode 100644
index 0000000..74d35aa
--- /dev/null
+++ b/precommit/test-patch.d/nobuild.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_build_tool nobuild
+
+function nobuild_buildfile
+{
+ echo
+}
+
+function nobuild_executor
+{
+ echo "true"
+}
+
+function nobuild_modules_worker
+{
+ local status=$1
+ local testtype=$2
+ modules_workers "${status}" "${testtype}"
+}
+
+function nobuild_builtin_personality_modules
+{
+ local status=$1
+ local testtype=$2
+ yetus_debug "built-in personality for no build system: ${status} ${testtype}"
+
+ clear_personality_queue
+ for module in ${CHANGED_MODULES}; do
+ # shellcheck disable=SC2086
+ personality_enqueue_module ${module}
+ done
+}
+
+function nobuild_builtin_personality_file_tests
+{
+ local filename=$1
+
+ yetus_debug "Using built-in no build system personality_file_tests."
+ yetus_debug " given file ${filename}"
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/perlcritic.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/perlcritic.sh b/precommit/test-patch.d/perlcritic.sh
new file mode 100755
index 0000000..c55f01a
--- /dev/null
+++ b/precommit/test-patch.d/perlcritic.sh
@@ -0,0 +1,151 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type perlcritic
+
+PERLCRITIC_TIMER=0
+
+PERLCRITIC=${PERLCRITIC:-$(which perlcritic 2>/dev/null)}
+
+function perlcritic_usage
+{
+ echo "Perl::Critic specific:"
+ echo "--perlcritic=<path> path to perlcritic executable"
+}
+
+function perlcritic_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --perlcritic=*)
+ PERLCRITIC=${i#*=}
+ ;;
+ esac
+ done
+}
+
+function perlcritic_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.p[lm]$ ]]; then
+ add_test perlcritic
+ fi
+}
+
+function perlcritic_preapply
+{
+ local i
+
+ verify_needed_test perlcritic
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Perl::Critic plugin: prepatch"
+
+ if [[ ! -x ${PERLCRITIC} ]]; then
+ yetus_error "${PERLCRITIC} does not exist."
+ return 0
+ fi
+
+ start_clock
+
+ echo "Running perlcritic against modified perl scripts/modules."
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
+ ${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/branch-perlcritic-result.txt"
+ fi
+ done
+ popd >/dev/null
+ # keep track of how much as elapsed for us already
+ PERLCRITIC_TIMER=$(stop_clock)
+ return 0
+}
+
+function perlcritic_postapply
+{
+ local i
+ local numPrepatch
+ local numPostpatch
+ local diffPostpatch
+
+ verify_needed_test perlcritic
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "Perl::Critic plugin: postpatch"
+
+ if [[ ! -x ${PERLCRITIC} ]]; then
+ yetus_error "${PERLCRITIC} is not available."
+ add_vote_table 0 perlcritic "Perl::Critic was not available."
+ return 0
+ fi
+
+ start_clock
+
+ # add our previous elapsed to our new timer
+ # by setting the clock back
+ offset_clock "${PERLCRITIC_TIMER}"
+
+ echo "Running perlcritic against modified perl scripts/modules."
+ # we re-check this in case one has been added
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
+ ${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/patch-perlcritic-result.txt"
+ fi
+ done
+ popd >/dev/null
+
+ PERLCRITIC_VERSION=$(${PERLCRITIC} --version 2>/dev/null)
+ add_footer_table perlcritic "v${PERLCRITIC_VERSION}"
+
+ calcdiffs "${PATCH_DIR}/branch-perlcritic-result.txt" "${PATCH_DIR}/patch-perlcritic-result.txt" > "${PATCH_DIR}/diff-patch-perlcritic.txt"
+ # shellcheck disable=SC2016
+ diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-perlcritic.txt" | ${AWK} '{print $1}')
+
+ if [[ ${diffPostpatch} -gt 0 ]] ; then
+ # shellcheck disable=SC2016
+ numPrepatch=$(wc -l "${PATCH_DIR}/branch-perlcritic-result.txt" | ${AWK} '{print $1}')
+
+ # shellcheck disable=SC2016
+ numPostpatch=$(wc -l "${PATCH_DIR}/patch-perlcritic-result.txt" | ${AWK} '{print $1}')
+
+ add_vote_table -1 perlcritic "The applied patch generated "\
+ "${diffPostpatch} new Perl::Critic issues (total was ${numPrepatch}, now ${numPostpatch})."
+ add_footer_table perlcritic "@@BASE@@/diff-patch-perlcritic.txt"
+ return 1
+ fi
+
+ add_vote_table +1 perlcritic "There were no new perlcritic issues."
+ return 0
+}
+
+function perlcritic_postcompile
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ perlcritic_preapply
+ else
+ perlcritic_postapply
+ fi
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/6f38afa5/precommit/test-patch.d/pylint.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/pylint.sh b/precommit/test-patch.d/pylint.sh
new file mode 100755
index 0000000..d5af000
--- /dev/null
+++ b/precommit/test-patch.d/pylint.sh
@@ -0,0 +1,179 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type pylint
+
+PYLINT_TIMER=0
+
+PYLINT=${PYLINT:-$(which pylint 2>/dev/null)}
+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"
+}
+
+function pylint_parse_args
+{
+ local i
+
+ for i in "$@"; do
+ case ${i} in
+ --pylint=*)
+ PYLINT=${i#*=}
+ ;;
+ --pylint-options=*)
+ PYLINT_OPTIONS=${i#*=}
+ ;;
+ esac
+ done
+}
+
+function pylint_filefilter
+{
+ local filename=$1
+
+ if [[ ${filename} =~ \.py$ ]]; then
+ add_test pylint
+ fi
+}
+
+function pylint_preapply
+{
+ local i
+ local count
+ local tmp=${PATCH_DIR}/pylint.$$.${RANDOM}
+
+ verify_needed_test pylint
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "pylint plugin: prepatch"
+
+ if [[ ! -x ${PYLINT} ]]; then
+ yetus_error "${PYLINT} does not exist."
+ return 0
+ fi
+
+ start_clock
+
+ echo "Running pylint against modified python scripts."
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.py$ && -f ${i} ]]; then
+ # shellcheck disable=SC2086
+ eval "${PYLINT} ${PYLINT_OPTIONS} --output-format=parseable --reports=n ${i}" 2>${tmp} |
+ ${AWK} '1<NR' >> "${PATCH_DIR}/branch-pylint-result.txt"
+ fi
+ # shellcheck disable=SC2016
+ count=$(${GREP} -v "^No config file found" "${tmp}" | wc -l | ${AWK} '{print $1}')
+ if [[ ${count} -gt 0 ]]; then
+ add_footer_table pylint "prepatch stderr: ${tmp}"
+ return 1
+ fi
+ done
+ rm "${tmp}" 2>/dev/null
+ popd >/dev/null
+ # keep track of how much as elapsed for us already
+ PYLINT_TIMER=$(stop_clock)
+ return 0
+}
+
+function pylint_postapply
+{
+ local i
+ local count
+ local numPrepatch
+ local numPostpatch
+ local diffPostpatch
+ local tmp=${PATCH_DIR}/pylint.$$.${RANDOM}
+
+ verify_needed_test pylint
+ if [[ $? == 0 ]]; then
+ return 0
+ fi
+
+ big_console_header "pylint plugin: postpatch"
+
+ if [[ ! -x ${PYLINT} ]]; then
+ yetus_error "${PYLINT} is not available."
+ add_vote_table 0 pylint "Pylint was not available."
+ return 0
+ fi
+
+ start_clock
+
+ # add our previous elapsed to our new timer
+ # by setting the clock back
+ offset_clock "${PYLINT_TIMER}"
+
+ echo "Running pylint against modified python scripts."
+ # we re-check this in case one has been added
+ pushd "${BASEDIR}" >/dev/null
+ for i in ${CHANGED_FILES}; do
+ if [[ ${i} =~ \.py$ && -f ${i} ]]; then
+ # shellcheck disable=SC2086
+ eval "${PYLINT} ${PYLINT_OPTIONS} --output-format=parseable --reports=n ${i}" 2>${tmp} |
+ ${AWK} '1<NR' >> "${PATCH_DIR}/patch-pylint-result.txt"
+ fi
+ # shellcheck disable=SC2016
+ count=$(${GREP} -v "^No config file found" "${tmp}" | wc -l | ${AWK} '{print $1}')
+ if [[ ${count} -gt 0 ]]; then
+ add_vote_table -1 pylint "Something bad seems to have happened in running pylint. Please check pylint stderr files."
+ add_footer_table pylint "postpatch stderr: ${tmp}"
+ return 1
+ fi
+ done
+ rm "${tmp}" 2>/dev/null
+ popd >/dev/null
+
+ # shellcheck disable=SC2016
+ PYLINT_VERSION=$(${PYLINT} --version 2>/dev/null | ${GREP} pylint | ${AWK} '{print $NF}')
+ add_footer_table pylint "v${PYLINT_VERSION%,}"
+
+ calcdiffs "${PATCH_DIR}/branch-pylint-result.txt" "${PATCH_DIR}/patch-pylint-result.txt" > "${PATCH_DIR}/diff-patch-pylint.txt"
+ diffPostpatch=$(${GREP} -c "^.*:.*: \[.*\] " "${PATCH_DIR}/diff-patch-pylint.txt")
+
+ if [[ ${diffPostpatch} -gt 0 ]] ; then
+ # shellcheck disable=SC2016
+ numPrepatch=$(${GREP} -c "^.*:.*: \[.*\] " "${PATCH_DIR}/branch-pylint-result.txt")
+
+ # shellcheck disable=SC2016
+ numPostpatch=$(${GREP} -c "^.*:.*: \[.*\] " "${PATCH_DIR}/patch-pylint-result.txt")
+
+ add_vote_table -1 pylint "The applied patch generated "\
+ "${diffPostpatch} new pylint issues (total was ${numPrepatch}, now ${numPostpatch})."
+ add_footer_table pylint "@@BASE@@/diff-patch-pylint.txt"
+ return 1
+ fi
+
+ add_vote_table +1 pylint "There were no new pylint issues."
+ return 0
+}
+
+function pylint_postcompile
+{
+ declare repostatus=$1
+
+ if [[ "${repostatus}" = branch ]]; then
+ pylint_preapply
+ else
+ pylint_postapply
+ fi
+}