when tests fail, print the output to stdout in addition to the log file

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1390581 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-09-26 15:55:27 +00:00
parent f86a366b97
commit 0c5a6b7bbc
1 changed files with 19 additions and 0 deletions

View File

@ -35,6 +35,7 @@ import platform
import checkJavaDocs
import checkJavadocLinks
import io
import codecs
# This tool expects to find /lucene and /solr off the base URL. You
# must have a working gpg, tar, unzip in your path. This has been
@ -389,6 +390,23 @@ def run(command, logFile):
if cygwin: command = cygwinifyPaths(command)
if os.system('%s > %s 2>&1' % (command, logFile)):
logPath = os.path.abspath(logFile)
print('\ncommand "%s" failed:' % command)
# Assume log file was written in system's default encoding, but
# even if we are wrong, we replace errors ... the ASCII chars
# (which is what we mostly care about eg for the test seed) should
# still survive:
txt = codecs.open(logPath, 'r', encoding=sys.getdefaultencoding(), errors='replace').read()
# Encode to our output encoding (likely also system's default
# encoding):
bytes = txt.encode(sys.stdout.encoding, errors='replace')
# Decode back to string and print... we should hit no exception here
# since all errors have been replaced:
print(codecs.getdecoder(sys.stdout.encoding)(bytes)[0])
print()
raise RuntimeError('command "%s" failed; see log file %s' % (command, logPath))
def verifyDigests(artifact, urlString, tmpDir):
@ -1191,6 +1209,7 @@ def smokeTest(baseURL, version, tmpDir, isSigned):
print('\nSUCCESS!\n')
if __name__ == '__main__':
print('NOTE: output encoding is %s' % sys.stdout.encoding)
try:
main()
except: