Replace the unit test of BranchProbability::normalizeEdgeWeights() with BranchProbabi...
[oota-llvm.git] / utils / lit / lit / LitTestCase.py
1 from __future__ import absolute_import
2 import unittest
3
4 import lit.Test
5
6 """
7 TestCase adaptor for providing a 'unittest' compatible interface to 'lit' tests.
8 """
9
10 class UnresolvedError(RuntimeError):
11     pass
12         
13 class LitTestCase(unittest.TestCase):
14     def __init__(self, test, run):
15         unittest.TestCase.__init__(self)
16         self._test = test
17         self._run = run
18
19     def id(self):
20         return self._test.getFullName()
21
22     def shortDescription(self):
23         return self._test.getFullName()
24
25     def runTest(self):
26         # Run the test.
27         self._run.execute_test(self._test)
28
29         # Adapt the result to unittest.
30         result = self._test.result
31         if result.code is lit.Test.UNRESOLVED:
32             raise UnresolvedError(result.output)
33         elif result.code.isFailure:
34             self.fail(result.output)