ensure lldbinline remembers .py extension
This ensure lldbinline.test_file paths are tracked as .py files rather than .pyc files. Also, this change adds an assert to the test infrastructure if a filename that is not ending in .py is attempted to be added to the test events infrastructure where we track test results. See: http://reviews.llvm.org/D19215 Earlier revision reviewed by: Pavel Labath llvm-svn: 266664
This commit is contained in:
parent
3fde652e18
commit
dad52cee4b
|
@ -189,6 +189,12 @@ def ApplyDecoratorsToFunction(func, decorators):
|
||||||
|
|
||||||
|
|
||||||
def MakeInlineTest(__file, __globals, decorators=None):
|
def MakeInlineTest(__file, __globals, decorators=None):
|
||||||
|
# Adjust the filename if it ends in .pyc. We want filenames to
|
||||||
|
# reflect the source python file, not the compiled variant.
|
||||||
|
if __file is not None and __file.endswith(".pyc"):
|
||||||
|
# Strip the trailing "c"
|
||||||
|
__file = __file[0:-1]
|
||||||
|
|
||||||
# Derive the test name from the current file name
|
# Derive the test name from the current file name
|
||||||
file_basename = os.path.basename(__file)
|
file_basename = os.path.basename(__file)
|
||||||
InlineTest.mydir = TestBase.compute_mydir(__file)
|
InlineTest.mydir = TestBase.compute_mydir(__file)
|
||||||
|
@ -205,7 +211,8 @@ def MakeInlineTest(__file, __globals, decorators=None):
|
||||||
# Add the test case to the globals, and hide InlineTest
|
# Add the test case to the globals, and hide InlineTest
|
||||||
__globals.update({test_name : test})
|
__globals.update({test_name : test})
|
||||||
|
|
||||||
# Store the name of the originating file.o
|
# Keep track of the original test filename so we report it
|
||||||
|
# correctly in test results.
|
||||||
test.test_filename = __file
|
test.test_filename = __file
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ def create_results_formatter(config):
|
||||||
def create_socket(port):
|
def create_socket(port):
|
||||||
"""Creates a socket to the localhost on the given port.
|
"""Creates a socket to the localhost on the given port.
|
||||||
|
|
||||||
@param port the port number of the listenering port on
|
@param port the port number of the listening port on
|
||||||
the localhost.
|
the localhost.
|
||||||
|
|
||||||
@return (socket object, socket closing function)
|
@return (socket object, socket closing function)
|
||||||
|
@ -242,6 +242,13 @@ class EventBuilder(object):
|
||||||
})
|
})
|
||||||
return event
|
return event
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _assert_is_python_sourcefile(test_filename):
|
||||||
|
if test_filename is not None:
|
||||||
|
if not test_filename.endswith(".py"):
|
||||||
|
raise Exception("source python filename has unexpected extension: {}".format(test_filename))
|
||||||
|
return test_filename
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _event_dictionary_common(test, event_type):
|
def _event_dictionary_common(test, event_type):
|
||||||
"""Returns an event dictionary setup with values for the given event type.
|
"""Returns an event dictionary setup with values for the given event type.
|
||||||
|
@ -257,9 +264,9 @@ class EventBuilder(object):
|
||||||
# Determine the filename for the test case. If there is an attribute
|
# Determine the filename for the test case. If there is an attribute
|
||||||
# for it, use it. Otherwise, determine from the TestCase class path.
|
# for it, use it. Otherwise, determine from the TestCase class path.
|
||||||
if hasattr(test, "test_filename"):
|
if hasattr(test, "test_filename"):
|
||||||
test_filename = test.test_filename
|
test_filename = EventBuilder._assert_is_python_sourcefile(test.test_filename)
|
||||||
else:
|
else:
|
||||||
test_filename = inspect.getsourcefile(test.__class__)
|
test_filename = EventBuilder._assert_is_python_sourcefile(inspect.getsourcefile(test.__class__))
|
||||||
|
|
||||||
event = EventBuilder.bare_event(event_type)
|
event = EventBuilder.bare_event(event_type)
|
||||||
event.update({
|
event.update({
|
||||||
|
@ -498,7 +505,7 @@ class EventBuilder(object):
|
||||||
if exception_description is not None:
|
if exception_description is not None:
|
||||||
event["exception_description"] = exception_description
|
event["exception_description"] = exception_description
|
||||||
if test_filename is not None:
|
if test_filename is not None:
|
||||||
event["test_filename"] = test_filename
|
event["test_filename"] = EventBuilder._assert_is_python_sourcefile(test_filename)
|
||||||
if command_line is not None:
|
if command_line is not None:
|
||||||
event["command_line"] = command_line
|
event["command_line"] = command_line
|
||||||
return event
|
return event
|
||||||
|
@ -522,7 +529,7 @@ class EventBuilder(object):
|
||||||
if worker_index is not None:
|
if worker_index is not None:
|
||||||
event["worker_index"] = int(worker_index)
|
event["worker_index"] = int(worker_index)
|
||||||
if test_filename is not None:
|
if test_filename is not None:
|
||||||
event["test_filename"] = test_filename
|
event["test_filename"] = EventBuilder._assert_is_python_sourcefile(test_filename)
|
||||||
if command_line is not None:
|
if command_line is not None:
|
||||||
event["command_line"] = command_line
|
event["command_line"] = command_line
|
||||||
return event
|
return event
|
||||||
|
|
Loading…
Reference in New Issue