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