xref: /llvm-project/lldb/test/API/test_utils/base/TestBaseTest.py (revision 4cc8f2a017c76af25234afc7c380550e9c93135c)
1"""
2Test TestBase test functions.
3"""
4
5from lldbsuite.test.lldbtest import *
6from lldbsuite.test_event import build_exception
7import six
8
9class TestBuildMethod(Base):
10
11    def setUp(self):
12        super().setUp()
13        self._traces = []
14        self.traceAlways = True
15
16    # override the parent trace method
17    def trace(self, *args, **kwargs):
18        io = six.StringIO()
19        print(*args, file=io, **kwargs)
20        self._traces.append(io.getvalue())
21
22    def test_build_fails_helpfully(self):
23        try:
24            self.build(dictionary={"CXX_SOURCES": "nonexisting-file.cpp"})
25        except build_exception.BuildError as e:
26            self.assertIn("nonexisting-file.cpp", str(e))
27        else:
28            self.fail("BuildError not raised!")
29
30    def test_build_logs_traces(self):
31        self.build(dictionary={"CXX_SOURCES": "return0.cpp"})
32        self.assertIn("CXX_SOURCES", self._traces[0])
33        self.assertIn("return0.o", self._traces[1])
34