diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-08-28 20:54:17 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-08-28 20:54:17 +0000 |
commit | 3331fd822894b319fb8ac1ee28566df522a0ad35 (patch) | |
tree | a492a72b0f6d4024e4118cc28d505816f441098b /lldb/packages/Python/lldbsuite/test | |
parent | 3ae9b9d5e40d1d9bdea1fd8e6fca322df920754a (diff) | |
download | bcm5719-llvm-3331fd822894b319fb8ac1ee28566df522a0ad35.tar.gz bcm5719-llvm-3331fd822894b319fb8ac1ee28566df522a0ad35.zip |
[dotest] Centralize and simplify session dir logic (NFC)
I was looking at the session directory logic for unrelated reasons and
noticed that the logic spread out across dotest. This simplifies things
a bit by moving the logic together.
llvm-svn: 370259
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/dotest.py | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index d57d3be2840..40c9bfbd95d 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -23,9 +23,10 @@ from __future__ import print_function # System modules import atexit -import os +import datetime import errno import logging +import os import platform import re import signal @@ -387,9 +388,11 @@ def parseOptionsAndInitTestdirs(): configuration.regexp = args.p if args.s: - if args.s.startswith('-'): - usage(parser) configuration.sdir_name = args.s + else: + timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S") + configuration.sdir_name = os.path.join(os.getcwd(), timestamp_started) + configuration.session_file_format = args.session_file_format if args.t: @@ -1019,6 +1022,9 @@ def run_suite(): # lldb.SBDebugger.Initialize()/Terminate() pair. import lldb + # Now we can also import lldbutil + from lldbsuite.test import lldbutil + # Create a singleton SBDebugger in the lldb namespace. lldb.DBG = lldb.SBDebugger.Create() @@ -1078,7 +1084,6 @@ def run_suite(): # Set up the working directory. # Note that it's not dotest's job to clean this directory. - import lldbsuite.test.lldbutil as lldbutil build_dir = configuration.test_build_dir lldbutil.mkdir_p(build_dir) @@ -1120,19 +1125,8 @@ def run_suite(): # Install the control-c handler. unittest2.signals.installHandler() - # If sdir_name is not specified through the '-s sdir_name' option, get a - # timestamp string and export it as LLDB_SESSION_DIR environment var. This will - # be used when/if we want to dump the session info of individual test cases - # later on. - # - # See also TestBase.dumpSessionInfo() in lldbtest.py. - import datetime - # The windows platforms don't like ':' in the pathname. - timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S") - if not configuration.sdir_name: - configuration.sdir_name = timestamp_started - os.environ["LLDB_SESSION_DIRNAME"] = os.path.join( - os.getcwd(), configuration.sdir_name) + lldbutil.mkdir_p(configuration.sdir_name) + os.environ["LLDB_SESSION_DIRNAME"] = configuration.sdir_name sys.stderr.write( "\nSession logs for test failures/errors/unexpected successes" @@ -1140,13 +1134,6 @@ def run_suite(): configuration.sdir_name) sys.stderr.write("Command invoked: %s\n" % getMyCommandLine()) - if not os.path.isdir(configuration.sdir_name): - try: - os.mkdir(configuration.sdir_name) - except OSError as exception: - if exception.errno != errno.EEXIST: - raise - # # Invoke the default TextTestRunner to run the test suite # |