LUCENE-8106: add cmdline option --no-git to avoid all git usage; replaces --no-fetch cmdline option

This commit is contained in:
Steve Rowe 2018-02-22 16:52:09 -05:00
parent d2d987fd74
commit edd54e551d
1 changed files with 34 additions and 31 deletions

View File

@ -63,8 +63,8 @@ def readConfig():
description=description)
parser.add_argument('url', metavar='URL',
help='Points to the Jenkins log to parse')
parser.add_argument('--no-fetch', dest='fetch', action='store_false', default=True,
help='Do not run "git fetch" prior to "git checkout"')
parser.add_argument('--no-git', dest='useGit', action='store_false', default=True,
help='Do not run "git" at all')
parser.add_argument('--iters', dest='testIters', type=int, default=defaultIters, metavar='N',
help='Number of iterations per test suite (default: %d)' % defaultIters)
return parser.parse_args()
@ -123,9 +123,9 @@ def fetchAndParseJenkinsLog(url):
sys.exit(0)
return tests
def prepareWorkspace(fetch, gitRef):
def prepareWorkspace(useGit, gitRef):
global gitCheckoutSucceeded
if fetch:
if useGit:
code = run('git fetch')
if 0 != code:
raise RuntimeError('ERROR: "git fetch" failed. See above.')
@ -135,6 +135,7 @@ def prepareWorkspace(fetch, gitRef):
raise RuntimeError('ERROR: "%s" failed. See above.' % checkoutCmd)
gitCheckoutSucceeded = True
run('git merge --ff-only', rememberFailure=False) # Ignore failure on non-branch ref
code = run('ant clean')
if 0 != code:
raise RuntimeError('ERROR: "ant clean" failed. See above.')
@ -207,14 +208,16 @@ def getLocalGitBranch():
def main():
config = readConfig()
tests = fetchAndParseJenkinsLog(config.url)
if config.useGit:
localGitBranch = getLocalGitBranch()
try:
prepareWorkspace(config.fetch, revisionFromLog)
prepareWorkspace(config.useGit, revisionFromLog)
modules = groupTestsByModule(tests)
runTests(config.testIters, modules, tests)
failures = printReport(config.testIters, '')
if config.useGit:
# Retest 100% failures at the tip of the branch
oldTests = tests
tests = {}
@ -246,7 +249,7 @@ def main():
print('[repro] %s' % traceback.format_exc())
sys.exit(1)
finally:
if gitCheckoutSucceeded:
if config.useGit and gitCheckoutSucceeded:
run('git checkout %s' % localGitBranch, rememberFailure=False) # Restore original git branch/sha
print('[repro] Exiting with code %d' % lastFailureCode)