def test_FilterOutIncludedFilesAsValuesSimple(self): db = inclusions_database.GenerateInclusionsDatabase( test_utils.BASIC_TEST_CONFIG) output = inclusions_database.FilterOutIncludedFilesAsValues(db) expected_output = {"foo/foo.h": ["bar/bar.h", "bar/core.h"]} self.assertEqual(expected_output, output)
def test_FilterOutIncludedFilesAsKeysComplex(self): db = inclusions_database.GenerateInclusionsDatabase( test_utils.COMPLEX_TEST_CONFIG) output = inclusions_database.FilterOutIncludedFilesAsKeys(db) expected_output = { "bar/baz/bar_core_factory.h": ["bar/core.h"], "foo/foo.h": ["bar/bar.h", "bar/core.h"] } self.assertEqual(expected_output, output)
def test_IncludedFilesRegexes(self): test_db = inclusions_database.GenerateInclusionsDatabase( test_utils.COMPLEX_TEST_CONFIG) expected_included_files_regexes = [ r"bar/bar\..*", r"bar/core\..*", r"bar/bar_unittest\..*", r"bar/core_unittest\..*", ] included_files_regexes = inclusions_database.IncludedFilesRegexes( test_db) self.assertEqual(expected_included_files_regexes, included_files_regexes)
def test_GenerateInclusionsDatabaseComplex(self): output_db = inclusions_database.GenerateInclusionsDatabase( test_utils.COMPLEX_TEST_CONFIG) self.assertIn("timestamp (UTC)", output_db) self.assertIn("repo_rev", output_db) self.assertEqual(output_db["repo_rev"], git_utils.GetUsageAnalyzerRepoRevision()) self.assertIn("usage_analyzer_rev", output_db) self.assertEqual(output_db["usage_analyzer_rev"], git_utils.GetUsageAnalyzerRepoRevision()) self.assertIn("config", output_db) self.assertEqual(output_db["config"], test_utils.COMPLEX_TEST_CONFIG) test_utils.VerifyComplexIncludedToIncluding( self, output_db["included_to_including"]) test_utils.VerifyComplexIncludingToIncluded( self, output_db["including_to_included"])
def test_LimitToSpecifiedIncludedFilesComplex(self): output_db = inclusions_database.GenerateInclusionsDatabase( test_utils.COMPLEX_TEST_CONFIG) inclusions_database.LimitToSpecifiedIncludedFiles( output_db, test_utils.COMPLEX_TEST_INCLUDED_FILES_TO_LIMIT_TO) self.assertIn("timestamp (UTC)", output_db) self.assertIn("repo_rev", output_db) self.assertEqual(output_db["repo_rev"], git_utils.GetUsageAnalyzerRepoRevision()) self.assertIn("usage_analyzer_rev", output_db) self.assertEqual(output_db["usage_analyzer_rev"], git_utils.GetUsageAnalyzerRepoRevision()) self.assertIn("config", output_db) self.assertEqual(output_db["config"], test_utils.COMPLEX_TEST_CONFIG) test_utils.VerifyComplexIncludedToIncludingWithLimitedIncludes( self, output_db["included_to_including"]) test_utils.VerifyComplexIncludingToIncludedWithLimitedIncludes( self, output_db["including_to_included"])
def generate_inclusions(chromium_root, config_filename, output_dir): config = inclusions_config.ReadConfigFromFile(config_filename, chromium_root) inclusions_db = inclusions_database.GenerateInclusionsDatabase(config) inclusions_database.WriteInclusionsDbToDisk(inclusions_db, output_dir)