def test_headers_which_are_out_of_date_at_the_target_are_shifted(self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/Plugins', 4)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = []
        services.files_lists['Source/Module1/Plugins'] = [
            'File1.cpp', 'File1.h', 'File2.h'
        ]
        services.files_lists['build/include/T4'] = ['File1.h', 'File2.h']
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/Plugins']
        services.folders_lists['Source/Module1/Plugins'] = []
        services.file_dates['Source/Module1/Plugins/File1.h'] = 'uptodate'
        services.file_dates['Source/Module1/Plugins/File2.h'] = 'uptodate'
        services.file_dates['build/include/T4/File1.h'] = 'notuptodate'
        services.file_dates['build/include/T4/File2.h'] = 'notuptodate'
        reorganizer = HeaderReorganization(layout, services)

        reorganizer.reorganizeHeaders()
        self.assertEquals(2, len(services.linked_files))
        self.assertEquals(
            'build/include/T4',
            services.linked_files['Source/Module1/Plugins/File1.h'])
        self.assertEquals(
            'build/include/T4',
            services.linked_files['Source/Module1/Plugins/File2.h'])
        self.assertEquals(2, len(services.removed_files))
        self.assertTrue('build/include/T4/File1.h' in services.removed_files)
        self.assertTrue('build/include/T4/File2.h' in services.removed_files)
示例#2
0
 def test_a_file_pattern_can_be_mapped_to_its_own_tier(self):
     project = ProjectLayout()
     project.addTierForModulesLike('**/repository/I[A-Z]*.h', 7)
     self.assertEqual(
         7,
         project.tierForModule(
             'Source/Module1/repository/ISomeInterface.h'))
    def test_reorganize_headers_for_a_different_tier_module(self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/Plugins', 4)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = []
        services.files_lists['Source/Module1/Plugins'] = [
            'File1.cpp', 'File1.h', 'File2.h'
        ]
        services.files_lists['build/include/T4'] = []
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/Plugins']
        services.folders_lists['Source/Module1/Plugins'] = []

        reorganizer = HeaderReorganization(layout, services)

        reorganizer.reorganizeHeaders()
        self.assertEquals(2, len(services.linked_files))
        self.assertEquals(
            'build/include/T4',
            services.linked_files['Source/Module1/Plugins/File1.h'])
        self.assertEquals(
            'build/include/T4',
            services.linked_files['Source/Module1/Plugins/File2.h'])
    def test_headers_which_are_no_longer_in_the_sources_are_removed_from_the_destinations(
            self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/Plugins', 4)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = []
        services.files_lists['Source/Module1/Plugins'] = [
            'File1.cpp', 'File1.h'
        ]
        services.files_lists['build/include/T4'] = ['File2.h']
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/Plugins']
        services.folders_lists['Source/Module1/Plugins'] = []
        services.folders_lists['build/include/T4'] = []

        reorganizer = HeaderReorganization(layout, services)

        reorganizer.reorganizeHeaders()
        self.assertEquals(1, len(services.linked_files))
        self.assertEquals(
            'build/include/T4',
            services.linked_files['Source/Module1/Plugins/File1.h'])
        self.assertEquals(1, len(services.removed_files))
        self.assertTrue('build/include/T4/File2.h' in services.removed_files)
    def test_private_headers_are_reorganized_if_a_module_is_prescient(self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/private', -1)
        layout.addTierForModulesLike('**/TestCases', 5, None, True)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = []
        services.files_lists['Source/Module1/private'] = [
            'File1.cpp', 'File1.h', 'File2.h'
        ]
        services.files_lists['build/include/T0'] = []
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/private']
        services.folders_lists['Source/Module1/private'] = []

        reorganizer = HeaderReorganization(layout, services)

        reorganizer.reorganizeHeaders()
        self.assertEquals(2, len(services.linked_files))
        self.assertEquals(
            'build/include/T0',
            services.linked_files['Source/Module1/private/File1.h'])
        self.assertEquals(
            'build/include/T0',
            services.linked_files['Source/Module1/private/File2.h'])
示例#6
0
    def test_resolve_include_path_for_module_with_third_party_headers(self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/Module1', 3)
        layout.addTierForModulesLike('CoreLib', 3, 'CoreLib')

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = [
            'Source/Module1/File1.cpp', 'Source/Module1/File1.h',
            'Source/Module1/File2.h'
        ]
        services.files_lists['Source/Module1/private'] = [
            'Source/Module1/private/File1.cpp',
            'Source/Module1/private/File1.h', 'Source/Module1/private/File2.h'
        ]
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/private']
        services.folders_lists['Source/Module1/private'] = []

        path_resolver = IncludePath(layout, services)
        self.assertEqual([
            'CoreLib', 'build/include/T1', 'build/include/T2',
            'build/include/T3'
        ], path_resolver.resolveIncludePaths('Source/Module1'))
    def test_headers_which_are_no_longer_in_the_sources_are_removed_from_the_destinations_even_if_their_tier_folder_is_unused(
            self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/Plugins', 4)
        layout.addTierForModulesLike('**/Plugins/File9.h', 8)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = []
        services.files_lists['Source/Module1/Plugins'] = [
            'File1.cpp', 'File1.h', 'File9.h'
        ]
        services.files_lists['build/include/T8'] = ['File2.h', 'File9.h']
        services.files_lists['build/include/T7'] = ['File2.h', 'File9.h']
        services.files_lists['build/include/T6'] = ['File2.h', 'File9.h']
        services.files_lists['build/include/T5'] = ['File2.h', 'File9.h']
        services.files_lists['build/include/T4'] = ['File2.h', 'File9.h']
        services.files_lists['build/include/T3'] = ['File2.h']
        services.files_lists['build/include/T2'] = ['File2.h']
        services.files_lists['build/include/T1'] = ['File2.h']
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/Plugins']
        services.folders_lists['Source/Module1/Plugins'] = []
        services.folders_lists['build/include/T8'] = []
        services.folders_lists['build/include/T7'] = []
        services.folders_lists['build/include/T6'] = []
        services.folders_lists['build/include/T5'] = []
        services.folders_lists['build/include/T4'] = []
        services.folders_lists['build/include/T3'] = []
        services.folders_lists['build/include/T2'] = []
        services.folders_lists['build/include/T1'] = []

        reorganizer = HeaderReorganization(layout, services)

        reorganizer.reorganizeHeaders()
        self.assertEquals(2, len(services.linked_files))
        self.assertEquals(
            'build/include/T4',
            services.linked_files['Source/Module1/Plugins/File1.h'])
        self.assertEquals(
            'build/include/T8',
            services.linked_files['Source/Module1/Plugins/File9.h'])
        self.assertEquals(12, len(services.removed_files))
        self.assertTrue('build/include/T8/File2.h' in services.removed_files)
        self.assertTrue('build/include/T7/File2.h' in services.removed_files)
        self.assertTrue('build/include/T6/File2.h' in services.removed_files)
        self.assertTrue('build/include/T5/File2.h' in services.removed_files)
        self.assertTrue('build/include/T4/File2.h' in services.removed_files)
        self.assertTrue('build/include/T1/File2.h' in services.removed_files)
        self.assertTrue('build/include/T2/File2.h' in services.removed_files)
        self.assertTrue('build/include/T3/File2.h' in services.removed_files)
        self.assertTrue('build/include/T7/File9.h' in services.removed_files)
        self.assertTrue('build/include/T6/File9.h' in services.removed_files)
        self.assertTrue('build/include/T5/File9.h' in services.removed_files)
        self.assertTrue('build/include/T4/File9.h' in services.removed_files)
示例#8
0
 def test_a_double_star_in_the_middle_can_match_no_folder_but_a_separator(
         self):
     project = ProjectLayout()
     project.addTierForModulesLike('afolder/**/someotherfolder', 6)
     self.assertEqual(6, project.tierForModule('afolder/someotherfolder'))
     self.assertEqual(
         6, project.tierForModule('afolder/anextrafolder/someotherfolder'))
     self.assertEqual(
         1, project.tierForModule('thewrongfolder/someotherfolder'))
     self.assertEqual(1,
                      project.tierForModule('afolder/alsothewrongfolder'))
示例#9
0
 def test_an_underscore_in_the_pattern_matches_an_underscore(self):
     project = ProjectLayout()
     project.addTierForModulesLike('**/repository/I[A-Z]*_h', 6)
     self.assertEqual(
         6,
         project.tierForModule(
             'Source/Module1/repository/ISomeInterface_h'))
     self.assertEqual(
         1,
         project.tierForModule(
             'Source/Module1/repository/ISomeInterfacedoth'))
示例#10
0
 def test_a_star_in_the_pattern_matches_a_dash(self):
     project = ProjectLayout()
     project.addTierForModulesLike('**/repository/*.h', 6)
     self.assertEqual(
         6,
         project.tierForModule(
             'Source/Module1/repository/I-SomeInterface.h'))
     self.assertEqual(
         1,
         project.tierForModule(
             'Source/Module1/repository/I-SomeInterfacedoth'))
示例#11
0
    def test_reorganize_headers_for_a_higher_tier_module(self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/Module2', 3)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module2'] = [
            'Source/Module2/File1.cpp', 'Source/Module2/File1.h',
            'Source/Module2/File2.h'
        ]
        services.folders_lists['Source'] = ['Source/Module2']
        services.folders_lists['Source/Module2'] = []

        path_resolver = IncludePath(layout, services)
        self.assertEqual(
            ['build/include/T1', 'build/include/T2', 'build/include/T3'],
            path_resolver.resolveIncludePaths('Source/Module2'))
    def test_private_headers_are_not_reorganized(self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/private', -1)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = []
        services.files_lists['Source/Module1/private'] = [
            'File1.cpp', 'File1.h', 'File2.h'
        ]
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/private']
        services.folders_lists['Source/Module1/private'] = []

        reorganizer = HeaderReorganization(layout, services)

        reorganizer.reorganizeHeaders()
        self.assertEquals(0, len(services.linked_files))
示例#13
0
 def test_a_series_of_matching_tier_rules_are_applied_in_order(self):
     project = ProjectLayout()
     project.addTierForModulesLike('**/Module1/**', 4)
     project.addTierForModulesLike('**/BusinessLogic/**', 2)
     project.addTierForModulesLike('**/Source/**', 1)
     self.assertEqual(4,
                      project.tierForModule('Source/Module1/BusinessLogic'))
    def test_public_headers_in_a_private_module_are_reorganized(self):
        layout = ProjectLayout()
        layout.addSourceFolder('Source')
        layout.addTierForModulesLike('**/private', 0)
        layout.addTierForModulesLike('**/private/Public*.h', 4)

        services = StubProjectServices()
        services.files_lists['Source'] = []
        services.files_lists['Source/Module1'] = []
        services.files_lists['Source/Module1/private'] = [
            'PublicFile1.cpp', 'PublicFile1.h', 'PublicFile2.h'
        ]
        services.folders_lists['Source'] = ['Source/Module1']
        services.folders_lists['Source/Module1'] = ['Source/Module1/private']
        services.folders_lists['Source/Module1/private'] = []

        reorganizer = HeaderReorganization(layout, services)

        reorganizer.reorganizeHeaders()
        self.assertEquals(2, len(services.linked_files))
        self.assertTrue(
            'Source/Module1/private/PublicFile1.h' in services.linked_files)
        self.assertTrue(
            'Source/Module1/private/PublicFile2.h' in services.linked_files)
示例#15
0
 def test_a_module_suffix_can_be_matched_with_double_star_wildcards(self):
     project = ProjectLayout()
     project.addTierForModulesLike('**/BusinessLogic', 2)
     self.assertEqual(2,
                      project.tierForModule('Source/Module1/BusinessLogic'))
示例#16
0
 def test_a_negative_value_can_be_used_for_a_private_tier(self):
     project = ProjectLayout()
     project.addTierForModulesLike('**/private', -1)
     self.assertEqual(0, project.tierForModule('Source/Module1/private'))
示例#17
0
 def test_a_non_default_tier_can_be_configured_and_returned_for_a_module(
         self):
     project = ProjectLayout()
     project.addTierForModulesLike('**/BusinessLogic', 2)
     self.assertEqual(2,
                      project.tierForModule('Source/Module1/BusinessLogic'))
示例#18
0
 def test_get_third_party_include_folder_returns_an_empty_list_for_higher_tiers_than_configured(
         self):
     project = ProjectLayout()
     project.addTierForModulesLike('*/CodeLib', 1, 'code/CodeLib')
     self.assertEqual([], project.getThirdPartyIncludeFolders(5))
示例#19
0
 def test_get_third_party_include_folder_returns_third_party_folders_in_that_tier(
         self):
     project = ProjectLayout()
     project.addTierForModulesLike('*/CodeLib', 1, 'code/CodeLib')
     self.assertEqual(['code/CodeLib'],
                      project.getThirdPartyIncludeFolders(1))
示例#20
0
 def test_get_third_party_include_folder_returns_an_empty_list_for_no_folders(
         self):
     project = ProjectLayout()
     project.addTierForModulesLike('*/CodeLib', 4, 'code/CodeLib')
     self.assertEqual([], project.getThirdPartyIncludeFolders(1))
示例#21
0
 def test_a_module_is_by_default_not_third_party(self):
     project = ProjectLayout()
     project.addTierForModulesLike('Source/*/BusinessLogic', 2)
     self.assertFalse(project.isThirdPartyModule('Source/Module1/Entities'))
示例#22
0
 def test_a_module_is_able_to_be_configured_not_prescient(self):
     project = ProjectLayout()
     project.addTierForModulesLike('Source/*/Entities', 2, None, False)
     self.assertFalse(project.isPrescientModule('Source/Module1/Entities'))
示例#23
0
 def test_a_module_is_by_default_not_prescient(self):
     project = ProjectLayout()
     project.addTierForModulesLike('Source/*/BusinessLogic', 2)
     self.assertFalse(project.isPrescientModule('Source/Module1/Entities'))
示例#24
0
 def test_a_module_is_able_to_be_configured_with_a_third_party_path(self):
     project = ProjectLayout()
     project.addTierForModulesLike('*/CodeLib', 2, 'code/CodeLib')
     self.assertEqual('code/CodeLib',
                      project.thirdPartyIncludePath('code/CodeLib'))
示例#25
0
 def test_a_module_is_able_to_be_configured_with_no_third_party_path(self):
     project = ProjectLayout()
     project.addTierForModulesLike('Source/*/Entities', 2, None)
     self.assertTrue(
         project.thirdPartyIncludePath('Source/Module1/Entities') == None)
示例#26
0
 def test_a_module_by_default_has_no_third_party_path(self):
     project = ProjectLayout()
     project.addTierForModulesLike('Source/*/BusinessLogic', 2)
     self.assertTrue(
         project.thirdPartyIncludePath('Source/Module1/Entities') == None)
示例#27
0
 def test_a_module_is_able_to_be_configured_not_third_party(self):
     project = ProjectLayout()
     project.addTierForModulesLike('Source/*/Entities', 2, None)
     self.assertFalse(project.isThirdPartyModule('Source/Module1/Entities'))
示例#28
0
 def test_a_module_is_able_to_be_configured_prescient(self):
     project = ProjectLayout()
     project.addTierForModulesLike('*/CodeLib', 2, None, True)
     self.assertTrue(project.isPrescientModule('code/CodeLib'))
示例#29
0
 def test_a_module_is_able_to_be_configured_third_party(self):
     project = ProjectLayout()
     project.addTierForModulesLike('*/CodeLib', 2, 'code/CodeLib')
     self.assertTrue(project.isThirdPartyModule('code/CodeLib'))
示例#30
0
 def test_a_module_suffix_can_be_unmatched_by_intermediates_matched_with_single_star_wildcards(
         self):
     project = ProjectLayout()
     project.addTierForModulesLike('Source/*/BusinessLogic', 2)
     self.assertEqual(1, project.tierForModule('Source/Module1/Entities'))