brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 43da097 Raw
40 lines · python
1import os2import configparser3 4import lit.formats5import lit.Test6 7 8class DummyFormat(lit.formats.FileBasedTest):9    def execute(self, test, lit_config):10        # In this dummy format, expect that each test file is actually just a11        # .ini format dump of the results to report.12 13        source_path = test.getSourcePath()14 15        cfg = configparser.ConfigParser()16        cfg.read(source_path)17 18        # Create the basic test result.19        result_code = cfg.get("global", "result_code")20        result_output = cfg.get("global", "result_output")21        result = lit.Test.Result(getattr(lit.Test, result_code), result_output)22 23        if cfg.has_option("global", "required_feature"):24            required_feature = cfg.get("global", "required_feature")25            if required_feature:26                test.requires.append(required_feature)27 28        # Load additional metrics.29        for key, value_str in cfg.items("results"):30            value = eval(value_str)31            if isinstance(value, int):32                metric = lit.Test.IntMetricValue(value)33            elif isinstance(value, float):34                metric = lit.Test.RealMetricValue(value)35            else:36                raise RuntimeError("unsupported result type")37            result.addMetric(key, metric)38 39        return result40