diff options
| author | Zachary Turner <zturner@google.com> | 2015-12-08 01:15:30 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2015-12-08 01:15:30 +0000 |
| commit | 606e3a5221ec611a2f5da6d9a4961e8e2199f9d2 (patch) | |
| tree | a71b819581216c1153340efce0baafd6a7da6941 /lldb/packages/Python/lldbsuite/test/result_formatter.py | |
| parent | da30cff9ef2e22cf9e8e307f132976a15feacdf8 (diff) | |
| download | bcm5719-llvm-606e3a5221ec611a2f5da6d9a4961e8e2199f9d2.tar.gz bcm5719-llvm-606e3a5221ec611a2f5da6d9a4961e8e2199f9d2.zip | |
Get rid of global variables in dotest.py
This moves all the global variables into a separate module called
`configuration`. This has a number of advantages:
1. Configuration data is centrally maintained so it's easy to get
a high level overview of what configuration data the test suite
makes use of.
2. The method of sharing configuration data among different parts
of the test suite becomes standardized. Previously we would
put some things into the `lldb` module, some things into the
`lldbtest_config` module, and some things would not get shared.
Now everything is shared through one module and is available to
the entire test suite.
3. It opens the door to moving some of the initialization code into
the `configuration` module, simplifying the implementation of
`dotest.py`.
There are a few stragglers that didn't get converted over to using
the `configuration` module in this patch, because it would have grown
the size of the patch unnecessarily. This includes everything
currently in the `lldbtest_config` module, as well as the
`lldb.remote_platform` variable. We can address these in the future.
llvm-svn: 254982
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/result_formatter.py')
| -rw-r--r-- | lldb/packages/Python/lldbsuite/test/result_formatter.py | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/result_formatter.py b/lldb/packages/Python/lldbsuite/test/result_formatter.py index 0af021c3dac..55ffb9e2493 100644 --- a/lldb/packages/Python/lldbsuite/test/result_formatter.py +++ b/lldb/packages/Python/lldbsuite/test/result_formatter.py @@ -30,15 +30,7 @@ import six from six.moves import cPickle # LLDB modules - - -class FormatterConfig(object): - def __init__(self): - self.filename = None - self.port = None - self.formatter_name = None - self.formatter_options = None - +from . import configuration class CreatedFormatter(object): def __init__(self, formatter, cleanup_func): @@ -46,7 +38,7 @@ class CreatedFormatter(object): self.cleanup_func = cleanup_func -def create_results_formatter(config): +def create_results_formatter(): """Sets up a test results formatter. @param config an instance of FormatterConfig @@ -75,28 +67,28 @@ def create_results_formatter(config): results_file_object = None cleanup_func = None - if config.filename: + if configuration.results_filename: # Open the results file for writing. - if config.filename == 'stdout': + if configuration.results_filename == 'stdout': results_file_object = sys.stdout cleanup_func = None - elif config.filename == 'stderr': + elif configuration.results_filename == 'stderr': results_file_object = sys.stderr cleanup_func = None else: - results_file_object = open(config.filename, "w") + results_file_object = open(configuration.results_filename, "w") cleanup_func = results_file_object.close default_formatter_name = ( "lldbsuite.test.result_formatter.XunitFormatter") - elif config.port: + elif configuration.results_port: # Connect to the specified localhost port. - results_file_object, cleanup_func = create_socket(config.port) + results_file_object, cleanup_func = create_socket(configuration.results_port) default_formatter_name = ( "lldbsuite.test.result_formatter.RawPickledFormatter") # If we have a results formatter name specified and we didn't specify # a results file, we should use stdout. - if config.formatter_name is not None and results_file_object is None: + if configuration.results_formatter_name is not None and results_file_object is None: # Use stdout. results_file_object = sys.stdout cleanup_func = None @@ -104,8 +96,8 @@ def create_results_formatter(config): if results_file_object: # We care about the formatter. Choose user-specified or, if # none specified, use the default for the output type. - if config.formatter_name: - formatter_name = config.formatter_name + if configuration.results_formatter_name: + formatter_name = configuration.results_formatter_name else: formatter_name = default_formatter_name @@ -119,8 +111,8 @@ def create_results_formatter(config): # Handle formatter options for the results formatter class. formatter_arg_parser = cls.arg_parser() - if config.formatter_options and len(config.formatter_options) > 0: - command_line_options = config.formatter_options + if configuration.results_formatter_options and len(configuration.results_formatter_options) > 0: + command_line_options = configuration.results_formatter_options else: command_line_options = [] |

