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 mydir = TestBase.compute_mydir(__file__) 12 13 def setUp(self): 14 super().setUp() 15 self._traces = [] 16 self.traceAlways = True 17 18 # override the parent trace method 19 def trace(self, *args, **kwargs): 20 io = six.StringIO() 21 print(*args, file=io, **kwargs) 22 self._traces.append(io.getvalue()) 23 24 def test_build_fails_helpfully(self): 25 try: 26 self.build(dictionary={"CXX_SOURCES": "nonexisting-file.cpp"}) 27 except build_exception.BuildError as e: 28 self.assertIn("nonexisting-file.cpp", str(e)) 29 else: 30 self.fail("BuildError not raised!") 31 32 def test_build_logs_traces(self): 33 self.build(dictionary={"CXX_SOURCES": "return0.cpp"}) 34 self.assertIn("CXX_SOURCES", self._traces[0]) 35 self.assertIn("return0.o", self._traces[1]) 36