Skip to content

Commit

Permalink
[illumos-gate merge]
Browse files Browse the repository at this point in the history
commit 6d3b6de
    10462 nightly errors - libmakestate.so.1: open failed
commit 18ce2ef
    10386 pbchk should catch capitalised "illumos"
    10387 pbchk should check commit message spelling
  • Loading branch information
jjelinek committed Mar 1, 2019
2 parents 422ca05 + 6d3b6de commit 8548fe4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 17 deletions.
13 changes: 12 additions & 1 deletion usr/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,19 @@ sgs: rootdirs .WAIT sysheaders userheaders .WAIT \
#
setup: closedbins bldtools sgs mapfiles

#
# Always build tools as non-DEBUG.
# When nightly launches a build it first builds non-DEBUG tools and then
# configures the environment so that these tools are used for building
# subsequently. If a recursive build from usr/src then builds DEBUG tools,
# the tools will be rebuilt using themselves resulting in a race condition
# that can cause the build to fail - see https://www.illumos.org/issues/10462
# for more details.
# A manual build in usr/src/tools in a DEBUG bldenv will still do a DEBUG
# tools build.
#
bldtools:
@cd tools; pwd; $(MAKE) install
@cd tools; pwd; $(MAKE) RELEASE_BUILD= install

# /var/mail/:saved is a special case because of the colon in the name.
#
Expand Down
20 changes: 18 additions & 2 deletions usr/src/tools/onbld/Checks/Comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@
#

# Copyright 2007, 2010 Richard Lowe
# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.

#
# Check delta comments:
# - Have the correct form.
# - Have a synopsis matching that of the bug
# - Appear only once.
# - Do not contain common spelling errors.
#

import re, sys
from onbld.Checks.DbLookups import BugDB
from onbld.Checks.SpellCheck import spellcheck_line


bugre = re.compile(r'^(\d{2,7}|[A-Z]{1,7}-\d{1,7}) (.*)$')
Expand Down Expand Up @@ -71,12 +73,16 @@ def comchk(comments, check_db=True, output=sys.stderr):
'mutant': [],
'dup': [],
'nomatch': [],
'nonexistent': [] }
'nonexistent': [],
'spelling': [] }
bugs = {}
ret = 0
blanks = False

lineno = 0
for com in comments:
lineno += 1

# Our input must be newline-free, comments are line-wise.
if com.find('\n') != -1:
raise ValueError("newline in comment '%s'" % com)
Expand All @@ -89,6 +95,10 @@ def comchk(comments, check_db=True, output=sys.stderr):
blanks = True
continue

for err in spellcheck_line(com):
errors['spelling'].append(
'comment line {} - {}'.format(lineno, err))

match = bugre.search(com)
if match:
if match.group(1) not in bugs:
Expand Down Expand Up @@ -179,4 +189,10 @@ def comchk(comments, check_db=True, output=sys.stderr):
output.write(" should be: '%s'\n" % err[1])
output.write(" is: '%s'\n" % err[2])

if errors['spelling']:
ret = 1
output.write("Spellcheck:\n")
for err in errors['spelling']:
output.write('{}\n'.format(err))

return ret
43 changes: 29 additions & 14 deletions usr/src/tools/onbld/Checks/SpellCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

import re, sys

spellMsg = '%s: Line %d contains "%s", a common misspelling of "%s"\n'
altMsg = '%s: Line %d contains "%s"; please use "%s" instead for consistency with other documentation\n'
spellMsg = 'contains "{}", a common misspelling of "{}"'
altMsg = 'contains "{}"; please use "{}" instead for consistency with other documentation'
caseMsg = 'contains "{}"; please use "{}" instead'

misspellings = {
'absense': 'absence',
Expand Down Expand Up @@ -253,8 +254,13 @@
'writeable': 'writable'
}

case = {
'Illumos': 'illumos'
}

misspellingREs = []
alternateREs = []
caseREs = []

for misspelling, correct in misspellings.items():
regex = re.compile(r'\b%s\b' % (misspelling), re.IGNORECASE)
Expand All @@ -266,12 +272,23 @@
entry = (regex, alternate, correct)
alternateREs.append(entry)

def check(errmsg, output, filename, line, lineno, entry):
if entry[0].search(line):
output.write(errmsg % (filename, lineno, entry[1], entry[2]))
return 1
else:
return 0
for alternate, correct in case.items():
regex = re.compile(r'\b%s\b' % (alternate))
entry = (regex, alternate, correct)
caseREs.append(entry)

def spellcheck_line(line):
errs = []
for entry in misspellingREs:
if entry[0].search(line):
errs.append(spellMsg.format(entry[1], entry[2]))
for entry in alternateREs:
if entry[0].search(line):
errs.append(altMsg.format(entry[1], entry[2]))
for entry in caseREs:
if entry[0].search(line):
errs.append(caseMsg.format(entry[1], entry[2]))
return errs

def spellcheck(fh, filename=None, output=sys.stderr, **opts):
lineno = 1
Expand All @@ -283,12 +300,10 @@ def spellcheck(fh, filename=None, output=sys.stderr, **opts):
fh.seek(0)
for line in fh:
line = line.decode(errors='replace')
for entry in misspellingREs:
ret |= check(spellMsg, output, filename, line,
lineno, entry)
for entry in alternateREs:
ret |= check(altMsg, output, filename, line,
lineno, entry)
for err in spellcheck_line(line):
output.write('{}: Line {} {}\n'.format(
filename, lineno, err))
ret = 1
lineno += 1

return ret

0 comments on commit 8548fe4

Please sign in to comment.