1eee887e0SPavel Labath""" 2eee887e0SPavel LabathTest TestBase test functions. 3eee887e0SPavel Labath""" 4eee887e0SPavel Labath 556f9cfe3SDave Leeimport io 656f9cfe3SDave Lee 7eee887e0SPavel Labathfrom lldbsuite.test.lldbtest import * 8eee887e0SPavel Labathfrom lldbsuite.test_event import build_exception 9eee887e0SPavel Labath 10eee887e0SPavel Labath 11*2238dcc3SJonas Devlieghereclass TestBuildMethod(Base): 12eee887e0SPavel Labath def setUp(self): 13eee887e0SPavel Labath super().setUp() 14eee887e0SPavel Labath self._traces = [] 15eee887e0SPavel Labath self.traceAlways = True 16eee887e0SPavel Labath 17eee887e0SPavel Labath # override the parent trace method 18eee887e0SPavel Labath def trace(self, *args, **kwargs): 1956f9cfe3SDave Lee buf = io.StringIO() 2056f9cfe3SDave Lee print(*args, file=buf, **kwargs) 2156f9cfe3SDave Lee self._traces.append(buf.getvalue()) 22eee887e0SPavel Labath 23eee887e0SPavel Labath def test_build_fails_helpfully(self): 24eee887e0SPavel Labath try: 25eee887e0SPavel Labath self.build(dictionary={"CXX_SOURCES": "nonexisting-file.cpp"}) 26eee887e0SPavel Labath except build_exception.BuildError as e: 27eee887e0SPavel Labath self.assertIn("nonexisting-file.cpp", str(e)) 28eee887e0SPavel Labath else: 29eee887e0SPavel Labath self.fail("BuildError not raised!") 30eee887e0SPavel Labath 31eee887e0SPavel Labath def test_build_logs_traces(self): 32eee887e0SPavel Labath self.build(dictionary={"CXX_SOURCES": "return0.cpp"}) 33eee887e0SPavel Labath self.assertIn("CXX_SOURCES", self._traces[0]) 34eee887e0SPavel Labath self.assertIn("return0.o", self._traces[1]) 35