def setUp(self): basics.opt_debug_pattern = 1 self.tmp = tempfile.mkdtemp() caches = cache_basics.SetUpCaches(self.tmp) self.includepath_map = caches.includepath_map self.canonical_path = caches.canonical_path self.directory_map = caches.directory_map self.realpath_map = caches.realpath_map self.systemdir_prefix_cache = caches.systemdir_prefix_cache mock_compiler = '/usr/crosstool/v8/gcc-4.1.0-glibc-2.2.2/blah/gcc' self.mock_compiler = mock_compiler def Mock_SetSystemDirsDefaults(compiler, language, sysroot_info, timer=None): if compiler != mock_compiler: raise Exception, "compiler: %s, mock_compiler: %s" % ( compiler, mock_compiler) self.compiler_defaults = lambda x: x self.compiler_defaults.SetSystemDirsDefaults = Mock_SetSystemDirsDefaults self.compiler_defaults.system_dirs_default_all = [] self.compiler_defaults.system_dirs_default = {} self.compiler_defaults.system_dirs_default[mock_compiler] = {} self.compiler_defaults.system_dirs_default[mock_compiler]['c'] = { '': [] } self.compiler_defaults.system_dirs_default[mock_compiler]['c++'] = { '': [] }
def setUp(self): basics.opt_debug_pattern = 1 self.tmp = tempfile.mkdtemp() caches = cache_basics.SetUpCaches(self.tmp) self.includepath_map = caches.includepath_map self.canonical_path = caches.canonical_path self.directory_map = caches.directory_map self.realpath_map = caches.realpath_map
def _InitializeAllCaches(self): # Make cache for parsed files. self.file_cache = {} # Make table for symbols in #define's. self.symbol_table = {} # Erect the edifice of caches. caches = self.caches = ( cache_basics.SetUpCaches(self.client_root_keeper.client_root)) # Migrate the cache stuff to self namespace. self.includepath_map = caches.includepath_map self.directory_map = caches.directory_map self.realpath_map = caches.realpath_map self.canonical_path = caches.canonical_path self.dirname_cache = caches.dirname_cache self.compiler_defaults = caches.compiler_defaults self.systemdir_prefix_cache = caches.systemdir_prefix_cache self.simple_build_stat = caches.simple_build_stat self.build_stat_cache = caches.build_stat_cache self.IsIncludepathIndex = caches.IsIncludepathIndex self.IsSearchdirIndex = caches.IsSearchdirIndex self.IsCurrdirIndex = caches.IsCurrdirIndex self.IsRealpathIndex = caches.IsRealpathIndex self.IsFilepathPair = caches.IsFilepathPair # Make a cache for the symbolic links encountered; also for their # replication into root directory. self.mirror_path = mirror_path.MirrorPath(self.simple_build_stat, self.canonical_path, self.realpath_map, self.systemdir_prefix_cache) # Make a parser for C/C++. self.parse_file = parse_file.ParseFile(self.includepath_map) # Make a compressor for source files. self.compress_files = compress_files.CompressFiles(self.includepath_map, self.directory_map, self.realpath_map, self.mirror_path) # A fast cache for avoiding calls into the mirror_path object. self.mirrored = set([]) # For statistics only. We measure the different search lists # (search paths) by accumulating them all in sets. self.quote_dirs_set = set([]) # quote search lists self.angle_dirs_set = set([]) # angle searchlists self.include_dir_pairs = set([]) # the pairs (quote search list,
def test_ResolveExpr(self): # Erect the edifice of caches. caches = cache_basics.SetUpCaches(self.tmp) parse_file_obj = parse_file.ParseFile(caches.includepath_map) symbol_table = {} # Set up symbol_table by parsing test_data/more_macros.c. self.assertEqual( parse_file_obj.Parse("test_data/more_macros.c", symbol_table), ([], [], ['TEMPLATE_VARNAME(foo)'], [])) # Check what we got in symbol_table. self.assertEqual( macro_eval.EvalExpression("TEMPLATE_VARNAME(foo)", symbol_table), set([ 'TEMPLATE_VARNAME(foo)', '"maps/foo.tpl.varnames.h"', 'AS_STRING(maps/foo.tpl.varnames.h)', 'AS_STRING_INTERNAL(maps/foo.tpl.varnames.h)' ])) # Verify that resolving this expression yields one actual file (which we # have placed in test_data/map). [((d, ip), rp)], symbols = macro_eval.ResolveExpr( caches.includepath_map.Index, caches.build_stat_cache.Resolve, 'TEMPLATE_VARNAME(foo)', caches.directory_map.Index(os.getcwd()), # current dir caches.directory_map.Index(""), # file directory [caches.directory_map.Index("test_data")], # search directory [], symbol_table) self.assertEqual(caches.directory_map.string[d], "test_data/") self.assertEqual(caches.includepath_map.string[ip], "maps/foo.tpl.varnames.h") self.assertEqual( symbols, set([ 'TEMPLATE_VARNAME', 'maps', 'AS_STRING', 'AS_STRING_INTERNAL', 'tpl', 'varnames', 'h', 'foo' ]))
def setUp(self): basics.debug_pattern = 3 self.tmp = tempfile.mkdtemp() caches = cache_basics.SetUpCaches(self.tmp) self.canonical_path = caches.canonical_path self.simple_build_stat = caches.simple_build_stat self.mirror_path = mirror_path.MirrorPath(self.simple_build_stat, self.canonical_path, caches.realpath_map, caches.systemdir_prefix_cache) self.directories = ['/', '/a', '/link', '/a/link', '/a/b', '/link/link', '/root'] self.links = ['/a/link', '/link', '/link/link'] self.exists = self.directories + self.links self.realpaths = {'/' :'/', '/a' :'/a', '/a/link' :'/a/b', '/link' :'/a', '/link/link':'/a/b'}