1 2import unittest2 3import os 4import shutil 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class TestClangModuleAppUpdate(TestBase): 13 mydir = TestBase.compute_mydir(__file__) 14 15 @skipIf(debug_info=no_match(["gmodules"])) 16 def test_rebuild_app_modules_untouched(self): 17 with open(self.getBuildArtifact("module.modulemap"), "w") as f: 18 f.write(""" 19 module Foo { header "f.h" } 20 """) 21 with open(self.getBuildArtifact("f.h"), "w") as f: 22 f.write(""" 23 @import Foundation; 24 @interface Foo : NSObject { 25 int i; 26 } 27 +(instancetype)init; 28 @end 29 """) 30 31 mod_cache = self.getBuildArtifact("private-module-cache") 32 import os 33 if os.path.isdir(mod_cache): 34 shutil.rmtree(mod_cache) 35 self.build() 36 self.assertTrue(os.path.isdir(mod_cache), "module cache exists") 37 38 target, process, _, bkpt = lldbutil.run_to_source_breakpoint( 39 self, "break here", lldb.SBFileSpec("main.m")) 40 bar = target.FindTypes('Bar').GetTypeAtIndex(0) 41 foo = bar.GetDirectBaseClassAtIndex(0).GetType() 42 self.assertEqual(foo.GetNumberOfFields(), 1) 43 self.assertEqual(foo.GetFieldAtIndex(0).GetName(), "i") 44 45 # Rebuild. 46 process.Kill() 47 os.remove(self.getBuildArtifact('main.o')) 48 os.remove(self.getBuildArtifact('a.out')) 49 self.build() 50 51 # Reattach. 52 target, process, _, _ = lldbutil.run_to_breakpoint_do_run(self, target, bkpt) 53 bar = target.FindTypes('Bar').GetTypeAtIndex(0) 54 foo = bar.GetDirectBaseClassAtIndex(0).GetType() 55 self.assertEqual(foo.GetNumberOfFields(), 1) 56 self.assertEqual(foo.GetFieldAtIndex(0).GetName(), "i") 57