]> git.proxmox.com Git - rustc.git/blame - src/llvm/utils/lit/lit/LitTestCase.py
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / utils / lit / lit / LitTestCase.py
CommitLineData
1a4d82fc 1from __future__ import absolute_import
223e47cc 2import unittest
1a4d82fc
JJ
3
4import lit.Test
223e47cc
LB
5
6"""
7TestCase adaptor for providing a 'unittest' compatible interface to 'lit' tests.
8"""
9
10class UnresolvedError(RuntimeError):
11 pass
12
13class LitTestCase(unittest.TestCase):
1a4d82fc 14 def __init__(self, test, run):
223e47cc
LB
15 unittest.TestCase.__init__(self)
16 self._test = test
1a4d82fc 17 self._run = run
223e47cc
LB
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):
1a4d82fc
JJ
26 # Run the test.
27 self._run.execute_test(self._test)
223e47cc 28
1a4d82fc
JJ
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)