DRTVWR-494: Merge copy-paste-friendly test output to tip

meow-7.2.2
Nat Goodspeed 2019-11-23 22:22:47 -05:00
commit b6befdf713
1 changed files with 13 additions and 6 deletions

View File

@ -87,7 +87,6 @@ def main(command, arguments=[], libpath=[], vars={}):
# might not exist; instead of KeyError, just use an empty string.
dirs = os.environ.get(var, "").split(os.pathsep)
# Append the sequence in libpath
log.info("%s += %r" % (var, libpath))
for dir in libpath:
# append system paths at the end
if dir in ('/lib', '/usr/lib'):
@ -105,16 +104,21 @@ def main(command, arguments=[], libpath=[], vars={}):
# Now rebuild the path string. This way we use a minimum of separators
# -- and we avoid adding a pointless separator when libpath is empty.
os.environ[var] = os.pathsep.join(clean_dirs)
log.info("%s = %r" % (var, os.environ[var]))
# This output format is intended to make it straightforward to copy
# the variable settings and the command itself from the build output
# and paste the whole thing at a command prompt to rerun it manually.
log.info("%s='%s' \\" % (var, os.environ[var]))
# Now handle arbitrary environment variables. The tricky part is ensuring
# that all the keys and values we try to pass are actually strings.
if vars:
log.info("Setting: %s" % ("\n".join(["%s=%s" % (key, value) for key, value in vars.iteritems()])))
for key, value in vars.items():
# As noted a few lines above, facilitate copy-paste rerunning.
log.info("%s='%s' \\" % (key, value))
os.environ.update(dict([(str(key), str(value)) for key, value in vars.iteritems()]))
# Run the child process.
command_list = [command]
command_list.extend(arguments)
log.info("Running: %s" % " ".join(command_list))
log.info(" ".join((("'%s'" % w) if ' ' in w else w) for w in command_list))
# Make sure we see all relevant output *before* child-process output.
sys.stdout.flush()
try:
@ -305,8 +309,11 @@ def get_windows_table():
return _windows_table
log=logging.getLogger(__name__)
logging.basicConfig()
# Use this instead of logging.basicConfig() because the latter prefixes
# every line of output with INFO:__main__:...
log=logging.getLogger()
log.setLevel(logging.INFO)
log.addHandler(logging.StreamHandler())
if __name__ == "__main__":
import argparse