llvm.org GIT mirror llvm / fd0a9c3
[LIT] Move xunit tests tests into their own location, and and add failures Failures will increase coverage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332056 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Matthews 1 year, 5 months ago
6 changed file(s) with 65 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
+0
-7
utils/lit/tests/Inputs/test-data/bad&name.ini less more
None [global]
1 result_code = PASS
2 result_output = & < > "
3
4 [results]
5 value0 = 1
6 value1 = 2.3456
0 [global]
1 result_code = FAIL
2 result_output = & < > "
3
4 [results]
5 value0 = 1
6 value1 = 2.3456
0 import os
1 try:
2 import ConfigParser
3 except ImportError:
4 import configparser as ConfigParser
5
6 import lit.formats
7 import lit.Test
8
9 class DummyFormat(lit.formats.FileBasedTest):
10 def execute(self, test, lit_config):
11 # In this dummy format, expect that each test file is actually just a
12 # .ini format dump of the results to report.
13
14 source_path = test.getSourcePath()
15
16 cfg = ConfigParser.ConfigParser()
17 cfg.read(source_path)
18
19 # Create the basic test result.
20 result_code = cfg.get('global', 'result_code')
21 result_output = cfg.get('global', 'result_output')
22 result = lit.Test.Result(getattr(lit.Test, result_code),
23 result_output)
24
25 # Load additional metrics.
26 for key,value_str in cfg.items('results'):
27 value = eval(value_str)
28 if isinstance(value, int):
29 metric = lit.Test.IntMetricValue(value)
30 elif isinstance(value, float):
31 metric = lit.Test.RealMetricValue(value)
32 else:
33 raise RuntimeError("unsupported result type")
34 result.addMetric(key, metric)
35
36 return result
37
0 import site
1 site.addsitedir(os.path.dirname(__file__))
2 import dummy_format
3
4 config.name = 'test-data'
5 config.suffixes = ['.ini']
6 config.test_format = dummy_format.DummyFormat()
7 config.test_source_root = None
8 config.test_exec_root = None
9 config.target_triple = None
1111 # CHECK-NEXT: "value0": 1,
1212 # CHECK-NEXT: "value1": 2.3456
1313 # CHECK-NEXT: }
14 # CHECK: "name": "test-data :: bad&name.ini",
15 # CHECK: "output": "& < > \""
16
17 # CHECK: ]
14 # CHECK-NEXT: "name": "test-data :: metrics.ini",
15 # CHECK-NEXT: "output": "Test passed."
16 # CHECK-NEXT: }
17 # CHECK-NEXT: ]
1818 # CHECK-NEXT: }
0 # Check xunit output
1 # RUN: %{lit} --xunit-xml-output %t.xunit.xml %{inputs}/test-data
1 # RUN: %{lit} --xunit-xml-output %t.xunit.xml %{inputs}/xunit-output || true
22 # RUN: FileCheck < %t.xunit.xml %s
33
44 # CHECK:
55 # CHECK:
6 # CHECK:
7 # CHECK:
8 # CHECK: case classname='test-data.test-data' name='metrics.ini' time='{{[0-1]}}.{{[0-9]+}}'/>
6 # CHECK: suite name='test-data' tests='1' failures='1'>
7 # CHECK:
8 # CHECK-NEXT:
9 # CHECK-NEXT:& < > "
10 # CHECK-NEXT:
911 # CHECK:
1012 # CHECK: