Skip to content

Commit

Permalink
[dotest] Centralize and simplify session dir logic (NFC)
Browse files Browse the repository at this point in the history
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
JDevlieghere committed Aug 28, 2019
1 parent 3ae9b9d commit 3331fd8
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
@@ -23,9 +23,10 @@

# 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,33 +1125,15 @@ 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"
" will go into directory '%s'\n" %
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
#

0 comments on commit 3331fd8

Please sign in to comment.