From 7d7e362d6f6d99152fe6cb6c38c955f6043b7081 Mon Sep 17 00:00:00 2001 From: Steve Rowe Date: Thu, 17 Nov 2016 12:54:33 -0500 Subject: [PATCH] LUCENE-7542: Release smoker should fail when CHANGES.txt has a release section for a future release --- dev-tools/scripts/smokeTestRelease.py | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/dev-tools/scripts/smokeTestRelease.py b/dev-tools/scripts/smokeTestRelease.py index 2e38e9b4144..2b1ff193e4d 100644 --- a/dev-tools/scripts/smokeTestRelease.py +++ b/dev-tools/scripts/smokeTestRelease.py @@ -431,6 +431,7 @@ reChangesSectionHREF = re.compile('(.*?)', re.IGNORECASE) reUnderbarNotDashHTML = re.compile(r'
  • (\s*(LUCENE|SOLR)_\d\d\d\d+)') reUnderbarNotDashTXT = re.compile(r'\s+((LUCENE|SOLR)_\d\d\d\d+)', re.MULTILINE) def checkChangesContent(s, version, name, project, isHTML): + currentVersionTuple = versionToTuple(version, name) if isHTML and s.find('Release %s' % version) == -1: raise RuntimeError('did not see "Release %s" in %s' % (version, name)) @@ -459,7 +460,8 @@ def checkChangesContent(s, version, name, project, isHTML): raise RuntimeError('did not see "%s" in %s' % (sub, name)) if isHTML: - # Make sure a section only appears once under each release: + # Make sure that a section only appears once under each release, + # and that each release is not greater than the current version seenIDs = set() seenText = set() @@ -468,6 +470,9 @@ def checkChangesContent(s, version, name, project, isHTML): if text.lower().startswith('release '): release = text[8:].strip() seenText.clear() + releaseTuple = versionToTuple(release, name) + if releaseTuple > currentVersionTuple: + raise RuntimeError('Future release %s is greater than %s in %s' % (release, version, name)) if id in seenIDs: raise RuntimeError('%s has duplicate section "%s" under release "%s"' % (name, text, release)) seenIDs.add(id) @@ -475,6 +480,27 @@ def checkChangesContent(s, version, name, project, isHTML): raise RuntimeError('%s has duplicate section "%s" under release "%s"' % (name, text, release)) seenText.add(text) + +reVersion = re.compile(r'(\d+)\.(\d+)(?:\.(\d+))?\s*(-alpha|-beta|final|RC\d+)?\s*(?:\[.*\])?', re.IGNORECASE) +def versionToTuple(version, name): + versionMatch = reVersion.match(version) + if versionMatch is None: + raise RuntimeError('Version %s in %s cannot be parsed' % (version, name)) + versionTuple = versionMatch.groups() + while versionTuple[-1] is None or versionTuple[-1] == '': + versionTuple = versionTuple[:-1] + if versionTuple[-1].lower() == '-alpha': + versionTuple = versionTuple[:-1] + ('0',) + elif versionTuple[-1].lower() == '-beta': + versionTuple = versionTuple[:-1] + ('1',) + elif versionTuple[-1].lower() == 'final': + versionTuple = versionTuple[:-2] + ('100',) + elif versionTuple[-1].lower()[:2] == 'rc': + versionTuple = versionTuple[:-2] + (versionTuple[-1][2:],) + print('%s: %s' % (version, versionTuple)) + return versionTuple + + reUnixPath = re.compile(r'\b[a-zA-Z_]+=(?:"(?:\\"|[^"])*"' + '|(?:\\\\.|[^"\'\\s])*' + r"|'(?:\\'|[^'])*')" \ + r'|(/(?:\\.|[^"\'\s])*)' \ + r'|("/(?:\\.|[^"])*")' \