diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:01:22 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:01:22 +0000 |
commit | 71d5a2540a98c81f5bcaeb48805e0e2881f530ef (patch) | |
tree | 5343938942df402b49ec7300a1c25a2d4ccd5821 /utils/lit/tests/Inputs/test-data | |
parent | 31bbf64f3a4974a2d6c8b3b27ad2f519caf74057 (diff) |
Diffstat (limited to 'utils/lit/tests/Inputs/test-data')
-rw-r--r-- | utils/lit/tests/Inputs/test-data/dummy_format.py | 38 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/test-data/lit.cfg | 42 |
2 files changed, 42 insertions, 38 deletions
diff --git a/utils/lit/tests/Inputs/test-data/dummy_format.py b/utils/lit/tests/Inputs/test-data/dummy_format.py new file mode 100644 index 000000000000..93e48eeb8396 --- /dev/null +++ b/utils/lit/tests/Inputs/test-data/dummy_format.py @@ -0,0 +1,38 @@ +import os +try: + import ConfigParser +except ImportError: + import configparser as ConfigParser + +import lit.formats +import lit.Test + +class DummyFormat(lit.formats.FileBasedTest): + def execute(self, test, lit_config): + # In this dummy format, expect that each test file is actually just a + # .ini format dump of the results to report. + + source_path = test.getSourcePath() + + cfg = ConfigParser.ConfigParser() + cfg.read(source_path) + + # Create the basic test result. + result_code = cfg.get('global', 'result_code') + result_output = cfg.get('global', 'result_output') + result = lit.Test.Result(getattr(lit.Test, result_code), + result_output) + + # Load additional metrics. + for key,value_str in cfg.items('results'): + value = eval(value_str) + if isinstance(value, int): + metric = lit.Test.IntMetricValue(value) + elif isinstance(value, float): + metric = lit.Test.RealMetricValue(value) + else: + raise RuntimeError("unsupported result type") + result.addMetric(key, metric) + + return result + diff --git a/utils/lit/tests/Inputs/test-data/lit.cfg b/utils/lit/tests/Inputs/test-data/lit.cfg index f5aba7b21774..0191cc218884 100644 --- a/utils/lit/tests/Inputs/test-data/lit.cfg +++ b/utils/lit/tests/Inputs/test-data/lit.cfg @@ -1,44 +1,10 @@ -import os -try: - import ConfigParser -except ImportError: - import configparser as ConfigParser - -import lit.formats -import lit.Test - -class DummyFormat(lit.formats.FileBasedTest): - def execute(self, test, lit_config): - # In this dummy format, expect that each test file is actually just a - # .ini format dump of the results to report. - - source_path = test.getSourcePath() - - cfg = ConfigParser.ConfigParser() - cfg.read(source_path) - - # Create the basic test result. - result_code = cfg.get('global', 'result_code') - result_output = cfg.get('global', 'result_output') - result = lit.Test.Result(getattr(lit.Test, result_code), - result_output) - - # Load additional metrics. - for key,value_str in cfg.items('results'): - value = eval(value_str) - if isinstance(value, int): - metric = lit.Test.IntMetricValue(value) - elif isinstance(value, float): - metric = lit.Test.RealMetricValue(value) - else: - raise RuntimeError("unsupported result type") - result.addMetric(key, metric) - - return result +import site +site.addsitedir(os.path.dirname(__file__)) +import dummy_format config.name = 'test-data' config.suffixes = ['.ini'] -config.test_format = DummyFormat() +config.test_format = dummy_format.DummyFormat() config.test_source_root = None config.test_exec_root = None config.target_triple = None |