diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 | 
| commit | f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch) | |
| tree | 48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /packages/Python/lldbsuite/test/test_runner | |
| parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/test_runner')
| -rw-r--r-- | packages/Python/lldbsuite/test/test_runner/__init__.py | 0 | ||||
| -rw-r--r-- | packages/Python/lldbsuite/test/test_runner/lib/lldb_utils.py | 66 | ||||
| -rw-r--r-- | packages/Python/lldbsuite/test/test_runner/process_control.py (renamed from packages/Python/lldbsuite/test/test_runner/lib/process_control.py) | 0 | ||||
| -rw-r--r-- | packages/Python/lldbsuite/test/test_runner/test/__init__.py | 0 | ||||
| -rwxr-xr-x | packages/Python/lldbsuite/test/test_runner/test/test_process_control.py (renamed from packages/Python/lldbsuite/test/test_runner/test/process_control_tests.py) | 13 | 
5 files changed, 8 insertions, 71 deletions
| diff --git a/packages/Python/lldbsuite/test/test_runner/__init__.py b/packages/Python/lldbsuite/test/test_runner/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/packages/Python/lldbsuite/test/test_runner/__init__.py diff --git a/packages/Python/lldbsuite/test/test_runner/lib/lldb_utils.py b/packages/Python/lldbsuite/test/test_runner/lib/lldb_utils.py deleted file mode 100644 index e469bbf12207..000000000000 --- a/packages/Python/lldbsuite/test/test_runner/lib/lldb_utils.py +++ /dev/null @@ -1,66 +0,0 @@ -""" -The LLVM Compiler Infrastructure - -This file is distributed under the University of Illinois Open Source -License. See LICENSE.TXT for details. - -Provides classes used by the test results reporting infrastructure -within the LLDB test suite. - - -This module contains utilities used by the lldb test framwork. -""" - - -class OptionalWith(object): -    # pylint: disable=too-few-public-methods -    # This is a wrapper - it is not meant to provide any extra methods. -    """Provides a wrapper for objects supporting "with", allowing None. - -    This lets a user use the "with object" syntax for resource usage -    (e.g. locks) even when the wrapped with object is None. - -    e.g. - -    wrapped_lock = OptionalWith(thread.Lock()) -    with wrapped_lock: -        # Do something while the lock is obtained. -        pass - -    might_be_none = None -    wrapped_none = OptionalWith(might_be_none) -    with wrapped_none: -        # This code here still works. -        pass - -    This prevents having to write code like this when -    a lock is optional: - -    if lock: -        lock.acquire() - -    try: -        code_fragament_always_run() -    finally: -        if lock: -            lock.release() - -    And I'd posit it is safer, as it becomes impossible to -    forget the try/finally using OptionalWith(), since -    the with syntax can be used. -    """ -    def __init__(self, wrapped_object): -        self.wrapped_object = wrapped_object - -    def __enter__(self): -        if self.wrapped_object is not None: -            return self.wrapped_object.__enter__() -        else: -            return self - -    def __exit__(self, the_type, value, traceback): -        if self.wrapped_object is not None: -            return self.wrapped_object.__exit__(the_type, value, traceback) -        else: -            # Don't suppress any exceptions -            return False diff --git a/packages/Python/lldbsuite/test/test_runner/lib/process_control.py b/packages/Python/lldbsuite/test/test_runner/process_control.py index a7e639e4b8b6..a7e639e4b8b6 100644 --- a/packages/Python/lldbsuite/test/test_runner/lib/process_control.py +++ b/packages/Python/lldbsuite/test/test_runner/process_control.py diff --git a/packages/Python/lldbsuite/test/test_runner/test/__init__.py b/packages/Python/lldbsuite/test/test_runner/test/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/packages/Python/lldbsuite/test/test_runner/test/__init__.py diff --git a/packages/Python/lldbsuite/test/test_runner/test/process_control_tests.py b/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py index 354506d65812..817c83c4fb55 100755 --- a/packages/Python/lldbsuite/test/test_runner/test/process_control_tests.py +++ b/packages/Python/lldbsuite/test/test_runner/test/test_process_control.py @@ -12,18 +12,18 @@ within the LLDB test suite.  Tests the process_control module.  """ +from __future__ import print_function +  # System imports.  import os +import os.path  import platform  import unittest  import sys  import threading -# Add lib dir to pythonpath -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'lib')) -  # Our imports. -import process_control +from test_runner import process_control  class TestInferiorDriver(process_control.ProcessDriver): @@ -77,7 +77,10 @@ class ProcessControlTests(unittest.TestCase):              options=None):          # Base command. -        command = ([sys.executable, "inferior.py"]) +        script_name = "{}/inferior.py".format(os.path.dirname(__file__)) +        if not os.path.exists(script_name): +            raise Exception("test inferior python script not found: {}".format(script_name)) +        command = ([sys.executable, script_name])          if ignore_soft_terminate:              cls._suppress_soft_terminate(command) | 
