[lit] Remove --repeat option, which wasn't that useful.
[oota-llvm.git] / utils / lit / lit / Test.py
1 import os
2
3 # Test results.
4
5 class TestResult:
6     def __init__(self, name, isFailure):
7         self.name = name
8         self.isFailure = isFailure
9
10     def __repr__(self):
11         return '%s%r' % (self.__class__.__name__,
12                          (self.name, self.isFailure))
13
14 PASS        = TestResult('PASS', False)
15 XFAIL       = TestResult('XFAIL', False)
16 FAIL        = TestResult('FAIL', True)
17 XPASS       = TestResult('XPASS', True)
18 UNRESOLVED  = TestResult('UNRESOLVED', True)
19 UNSUPPORTED = TestResult('UNSUPPORTED', False)
20
21 # Test classes.
22
23 class TestFormat:
24     """TestFormat - Test information provider."""
25
26     def __init__(self, name):
27         self.name = name
28
29 class TestSuite:
30     """TestSuite - Information on a group of tests.
31
32     A test suite groups together a set of logically related tests.
33     """
34
35     def __init__(self, name, source_root, exec_root, config):
36         self.name = name
37         self.source_root = source_root
38         self.exec_root = exec_root
39         # The test suite configuration.
40         self.config = config
41
42     def getSourcePath(self, components):
43         return os.path.join(self.source_root, *components)
44
45     def getExecPath(self, components):
46         return os.path.join(self.exec_root, *components)
47
48 class Test:
49     """Test - Information on a single test instance."""
50
51     def __init__(self, suite, path_in_suite, config):
52         self.suite = suite
53         self.path_in_suite = path_in_suite
54         self.config = config
55         # The test result code, once complete.
56         self.result = None
57         # Any additional output from the test, once complete.
58         self.output = None
59         # The wall time to execute this test, if timing and once complete.
60         self.elapsed = None
61
62     def setResult(self, result, output, elapsed):
63         assert self.result is None, "Test result already set!"
64         self.result = result
65         self.output = output
66         self.elapsed = elapsed
67
68     def getFullName(self):
69         return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
70
71     def getSourcePath(self):
72         return self.suite.getSourcePath(self.path_in_suite)
73
74     def getExecPath(self):
75         return self.suite.getExecPath(self.path_in_suite)