Ejemplo n.º 1
0
    def test_load_pralinefile_stage_with_pralinefile(self):
        file_system = FileSystemMock({working_directory}, pralinefile, working_directory=working_directory, on_which=gcc_which)

        resources = {}

        load_pralinefile(file_system, resources, None, program_arguments, None, None)

        self.assertEqual(resources['project_directory'], file_system.get_working_directory())

        self.assertIn('pralinefile', resources)

        self.assertIn('compiler', resources)
Ejemplo n.º 2
0
    def test_get_package_dependencies_from_archive(self):
        archive = pickle.dumps({
            'Pralinefile':
            b"""\
            organization: my_org
            artifact: my_art
            version: 1.0.0
            dependencies:
            - organization: some_org
              artifact: some_art
              version: 7.0.1
            - organization: test_org
              artifact: test_art
              version: 2.2.2
              scope: test
            - organization: another_org
              artifact: another_art
              version: 1.2.3
            """
        })
        directory = 'packages'
        package_path = f'{directory}/my_org-my_art-x32-windows-msvc-debug-1.0.0.tar.gz'
        file_system = FileSystemMock({directory}, {package_path: archive})
        scope = 'main'

        dependencies = get_package_dependencies_from_archive(
            file_system, package_path, scope)

        expected_dependencies = [
            'some_org-some_art-x32-windows-msvc-debug-7.0.1.tar.gz',
            'another_org-another_art-x32-windows-msvc-debug-1.2.3.tar.gz'
        ]

        self.assertEqual(dependencies, expected_dependencies)
Ejemplo n.º 3
0
    def test_create_pipeline(self):
        #
        #       [F]
        #        |
        #      [E D]
        #      /  | \
        #    [C] [A][B C]
        #
        do_nothing = lambda f, r, c, a, cfg, rp: None
        can_run = lambda _, __, ___: True
        cant_run = lambda _, __, ___: False
        stages = {
            'A':
            Stage('A', [], ['a'], cant_run, [], False, False, do_nothing),
            'B':
            Stage('B', [], ['b'], can_run, [], False, False, do_nothing),
            'C':
            Stage('C', [], ['c'], can_run, [], False, False, do_nothing),
            'D':
            Stage('D', [['a'], ['b', 'c']], ['d'], can_run, [], False, False,
                  do_nothing),
            'E':
            Stage('E', [['c']], ['e'], can_run, [], False, False, do_nothing),
            'F':
            Stage('F', [['e', 'd']], [], can_run, [], False, False, do_nothing)
        }
        file_system = FileSystemMock()
        program_arguments = {'global': {}, 'byStage': {}}
        configuration = {}
        pipeline = create_pipeline('F', stages, file_system, program_arguments,
                                   configuration)

        self.assertEqual(pipeline, [(0, 'C'), (0, 'E'), (0, 'B'), (1, 'D'),
                                    (0, 'F')])
Ejemplo n.º 4
0
    def test_clean_stage_with_target_folder(self):
        file_system = FileSystemMock({'my/project/target'})
        resources   = {'project_directory': 'my/project'}

        clean(file_system, resources, None, None, None, None)

        self.assertEqual(file_system.directories, {normpath('my/project')})
Ejemplo n.º 5
0
    def test_load_test_sources(self):
        file_system = FileSystemMock({'project/sources/org/art'}, {
            'project/sources/org/art/math.hpp': b'',
            'project/sources/org/art/math.cpp': b'',
            'project/sources/org/art/math.test.cpp': b''
        })

        resources = {
            'test_sources_root': 'project/sources',
            'pralinefile': {
                'organization': 'org',
                'artifact': 'art'
            }
        }

        load_test_sources(file_system, resources, None, None, None, None)

        expected_test_sources = {
            'project/sources/org/art/math.test.cpp',
            'project/sources/org/art/executable.test.cpp'
        }

        self.assertEqual({normpath(p) for p in resources['test_sources']}, {normpath(p) for p in expected_test_sources})

        expected_files = {
            'project/sources/org/art/math.hpp': b'',
            'project/sources/org/art/math.cpp': b'',
            'project/sources/org/art/math.test.cpp': b'',
            'project/sources/org/art/executable.test.cpp': test_executable_contents.encode('utf-8')
        }

        self.assertEqual(file_system.files, {normpath(p): d for p, d in expected_files.items()})
Ejemplo n.º 6
0
    def test_invoke_stage_with_cycles(self):
        #
        #         A
        #         |
        #    B -> C
        #     ^   |
        #      \_ |
        #         D
        #
        do_nothing = lambda f, r, c, a, cfg, rp: None
        can_run = lambda _, __, ___: True
        stages = {
            'A': Stage('A', [['c']], ['a'], can_run, [], False, False,
                       do_nothing),
            'B': Stage('B', [['c']], ['b'], can_run, [], False, False,
                       do_nothing),
            'C': Stage('C', [['d']], ['c'], can_run, [], True, False,
                       do_nothing),
            'D': Stage('D', [['b']], ['d'], can_run, [], True, False,
                       do_nothing)
        }
        file_system = FileSystemMock()
        program_arguments = {'global': {}, 'byStage': {}}

        self.assertRaises(CyclicStagesError, invoke_stage, 'A', stages,
                          file_system, program_arguments, None, None)
Ejemplo n.º 7
0
    def test_load_clang_format_stage_with_user_supplied_style_file(self):
        normalized_executable_path = normpath(
            'path/to/clang_format_executable')
        normalized_style_file_path = normpath('my/project/.clang-format')

        file_system = FileSystemMock(
            {'path/to', 'my/project'}, {
                normalized_executable_path: b'',
                normalized_style_file_path: b'IndentWidth: 8'
            })

        resources = {'project_directory': 'my/project'}
        configuration = {
            'clang-format-executable-path': normalized_executable_path
        }

        load_clang_format(file_system, resources, None, None, configuration,
                          None)

        self.assertEqual(normpath(resources['clang_format_executable']),
                         normalized_executable_path)

        self.assertEqual(normpath(resources['clang_format_style_file']),
                         normalized_style_file_path)

        self.assertEqual(file_system.files[normalized_style_file_path],
                         b'IndentWidth: 8')
Ejemplo n.º 8
0
    def test_format_headers(self):
        def on_execute(command, add_to_library_path):
            return (normpath('project/sources/org/art/math.hpp') in command
                    and normpath('project/sources/org/art/vector.hpp')
                    not in command
                    and normpath('project/sources/org/art/map.hpp') in command
                    and normpath('project/sources/org/art/request.hpp')
                    not in command)

        file_system = FileSystemMock(
            {'project/sources/org/art'}, {
                'project/sources/org/art/math.hpp': b'math-contents',
                'project/sources/org/art/vector.hpp': b'vector-contents',
                'project/sources/org/art/map.hpp': b'map-contents'
            },
            on_execute=on_execute)

        clang_format_executable = 'path/to/clang-format'

        resources = {
            'clang_format_executable': clang_format_executable,
            'headers': file_system.files.keys()
        }

        cache = {
            normpath(p): d
            for p, d in {
                'project/sources/org/art/vector.hpp':
                '2d5b04a0069bfadaadbce424db26c7a66c13afa3c621326ab0f1303c6a20ad82',
                'project/sources/org/art/map.hpp': 'stale',
                'project/sources/org/art/request.hpp': 'stale'
            }.items()
        }

        format_headers(file_system, resources, cache, None, None, None)

        expected_formatted_headers = {
            'project/sources/org/art/math.hpp',
            'project/sources/org/art/vector.hpp',
            'project/sources/org/art/map.hpp'
        }

        self.assertEqual({normpath(p)
                          for p in resources['formatted_headers']},
                         {normpath(p)
                          for p in expected_formatted_headers})

        expected_cache = {
            'project/sources/org/art/math.hpp':
            '38527a9ac8d06095ec3a63b5409cdf92888fd8ee721a38628b7c83765f52e182',
            'project/sources/org/art/vector.hpp':
            '2d5b04a0069bfadaadbce424db26c7a66c13afa3c621326ab0f1303c6a20ad82',
            'project/sources/org/art/map.hpp':
            'e886d8d60c513bebdc21c4fe27f14797be5a41471d25af89c087f8db7f98e3ec'
        }

        self.assertEqual(cache,
                         {normpath(p): d
                          for p, d in expected_cache.items()})
Ejemplo n.º 9
0
    def test_load_clang_format_stage_with_no_configuration(self):
        file_system = FileSystemMock({'my/project'})
        resources = {'project_directory': 'my/project'}
        configuration = {}

        self.assertRaises(ClangFormatConfigurationError, load_clang_format,
                          file_system, resources, None, None, configuration,
                          None)
Ejemplo n.º 10
0
    def test_hash_file(self):
        directory   = 'my'
        file_name   = 'my/file'
        binary      = b'secretvalue'
        file_system = FileSystemMock({directory}, {file_name: binary})
        hash_value  = hash_file(file_system, file_name)

        self.assertEqual(hash_value, '3734c3023573321d4f7912cfeda42eb8fa74d1c3fb2f8f08147ac66ee14a5bba')
Ejemplo n.º 11
0
    def test_hash_archive(self):
        file_system = FileSystemMock(files={
            'archive.tar.gz': pickle.dumps({
                'path/to/file.txt': b'file-contents',
                'another_path/to/another_file.txt': b'another-file-contents'
            })
        })

        hash_code = hash_archive(file_system, 'archive.tar.gz')

        self.assertEqual(hash_code, 'de53e4f349df70285ef8acc48135f45d842be16094fbcd09bcea189b2adfb2c8')
Ejemplo n.º 12
0
    def test_key_retrieval_with_default(self):
        directory = 'my'
        file_name = 'my/vault'
        data = pickle.dumps({'bike': 'green'},
                            protocol=pickle.HIGHEST_PROTOCOL)
        file_system = FileSystemMock({directory}, {file_name: data})

        with Cache(file_system, file_name) as cache:
            self.assertEqual(cache.get('bike'), 'green')
            self.assertEqual(cache.get('bicycle'), None)
            self.assertEqual(cache.get('scooter', 'white'), 'white')
Ejemplo n.º 13
0
    def test_key_retrieval_with_existing_cache(self):
        directory = 'my'
        file_name = 'my/cache'
        data = pickle.dumps({'myKey': 38}, protocol=pickle.HIGHEST_PROTOCOL)
        file_system = FileSystemMock({directory}, {file_name: data})

        with Cache(file_system, file_name) as cache:
            self.assertEqual(cache['myKey'], 38)

        with Cache(file_system, file_name) as cache:
            self.assertEqual(cache['myKey'], 38)
Ejemplo n.º 14
0
    def test_key_update_with_existing_cache(self):
        directory = 'my'
        file_name = 'my/safe'
        data = pickle.dumps({'car': 'red'}, protocol=pickle.HIGHEST_PROTOCOL)
        file_system = FileSystemMock({directory}, {file_name: data})

        with Cache(file_system, file_name) as cache:
            cache['car'] = 'yellow'
            self.assertEqual(cache['car'], 'yellow')

        with Cache(file_system, file_name) as cache:
            self.assertEqual(cache['car'], 'yellow')
Ejemplo n.º 15
0
    def test_key_adding_with_fresh_cache(self):
        file_name = 'my/pickle'
        file_system = FileSystemMock()

        with Cache(file_system, file_name) as cache:
            cache['dragon'] = 'blue'
            self.assertEqual(cache['dragon'], 'blue')

        with Cache(file_system, file_name) as cache:
            cache['cat'] = 'black'
            self.assertEqual(cache['cat'], 'black')
            self.assertEqual(cache['dragon'], 'blue')
Ejemplo n.º 16
0
    def test_get_package_extracted_contents(self):
        package_path = 'workspace/juice/target/external/packages/org-art-x32-windows-msvc-debug-1.0.0.tar.gz'
        extraction_path = 'workspace/juice/target/external'
        archive = pickle.dumps({
            'resources/org/art/app.config':
            b'app-config',
            'headers/org/art/inc.hpp':
            b'inc-hpp',
            'libraries/org-art-x32-windows-msvc-debug-1.0.0.dll':
            b'library-dll',
            'libraries_interfaces/org-art-x32-windows-msvc-debug-1.0.0.lib':
            b'library-interface-lib',
            'symbols_tables/org-art-x32-windows-msvc-debug-1.0.0.pdb':
            b'symbols-tables-pdb',
            'executables/org-art-x32-windows-msvc-debug-1.0.0.exe':
            b'executable-exe'
        })
        file_system = FileSystemMock({dirname(package_path)},
                                     {package_path: archive})

        contents = get_package_extracted_contents(file_system, package_path,
                                                  extraction_path)

        expected_contents = {
            'resources':
            ['workspace/juice/target/external/resources/org/art/app.config'],
            'headers':
            ['workspace/juice/target/external/headers/org/art/inc.hpp'],
            'libraries': [
                'workspace/juice/target/external/libraries/org-art-x32-windows-msvc-debug-1.0.0.dll'
            ],
            'libraries_interfaces': [
                'workspace/juice/target/external/libraries_interfaces/org-art-x32-windows-msvc-debug-1.0.0.lib'
            ],
            'symbols_tables': [
                'workspace/juice/target/external/symbols_tables/org-art-x32-windows-msvc-debug-1.0.0.pdb'
            ],
            'executables': [
                'workspace/juice/target/external/executables/org-art-x32-windows-msvc-debug-1.0.0.exe'
            ]
        }

        self.assertEqual(
            {
                root: [normpath(p) for p in files]
                for root, files in contents.items()
            }, {
                root: [normpath(p) for p in files]
                for root, files in expected_contents.items()
            })
Ejemplo n.º 17
0
    def test_key_adding_with_existing_cache(self):
        directory = 'my'
        file_name = 'my/storage'
        data = pickle.dumps({'someKey': 'someValue'},
                            protocol=pickle.HIGHEST_PROTOCOL)
        file_system = FileSystemMock({directory}, {file_name: data})

        with Cache(file_system, file_name) as cache:
            cache['otherKey'] = 'otherValue'
            self.assertEqual(cache['someKey'], 'someValue')
            self.assertEqual(cache['otherKey'], 'otherValue')

        with Cache(file_system, file_name) as cache:
            self.assertEqual(cache['someKey'], 'someValue')
            self.assertEqual(cache['otherKey'], 'otherValue')
Ejemplo n.º 18
0
    def test_create_pipeline_with_multiple_suppliers(self):
        do_nothing = lambda f, r, c, a, cfg, rp: None
        can_run = lambda _, __, ___: True
        stages = {
            'A': Stage('A', [], ['x'], can_run, [], False, False, do_nothing),
            'B': Stage('B', [], ['x'], can_run, [], False, False, do_nothing),
            'C': Stage('C', ['x'], ['c'], can_run, [], False, False,
                       do_nothing)
        }
        file_system = FileSystemMock()
        program_arguments = {'global': {}, 'byStage': {}}
        configuration = {}

        self.assertRaises(MultipleSuppliersError, create_pipeline, 'C', stages,
                          file_system, program_arguments, configuration)
Ejemplo n.º 19
0
    def test_invoke_stage_with_unsatisfiable_nonexistent_stage(self):
        do_nothing = lambda f, r, c, a, cfg, rp: None
        can_run = lambda _, __, ___: True
        stages = {
            'A':
            Stage('A', [['b', 'c']], ['a'], can_run, [], False, False,
                  do_nothing),
            'B':
            Stage('B', [['d']], ['b'], can_run, [], False, False, do_nothing),
            'C':
            Stage('C', [['d']], ['c'], can_run, [], True, False, do_nothing),
            'D':
            Stage('D', [[]], [], can_run, [], True, False, do_nothing)
        }
        file_system = FileSystemMock()
        program_arguments = {'global': {}, 'byStage': {}}

        self.assertRaises(UnsatisfiableStageError, invoke_stage, 'A', stages,
                          file_system, program_arguments, None, None)
Ejemplo n.º 20
0
    def test_pralinefile_from_path(self):
        file_system = FileSystemMock(
            files={
                'Pralinefile':
                b"""\
            organization: another_organization
            artifact: another_artifact
            compilers: [gcc]
            modes: [release]
            version: 7.7.7
            dependencies:
            - organization: org
              artifact: art
              scope: test
              version: 3.+5.+5
            """
            })

        expected_pralinefile = {
            'organization':
            'another_organization',
            'artifact':
            'another_artifact',
            'platforms':
            allowed_platforms,
            'architectures':
            allowed_architectures,
            'compilers': ['gcc'],
            'modes': ['release'],
            'version':
            '7.7.7',
            'dependencies': [{
                'organization': 'org',
                'artifact': 'art',
                'scope': 'test',
                'version': '3.+5.+5'
            }]
        }

        actual_pralinefile = pralinefile_from_path(file_system, 'Pralinefile')

        self.assertEqual(actual_pralinefile, expected_pralinefile)
Ejemplo n.º 21
0
    def test_load_resources_stage(self):
        file_system = FileSystemMock(
            {'project/resources/org/art', 'project/sources/org/art'}, {
                'project/resources/org/art/app.config': b'',
                'project/resources/org/art/locale.rsx': b'',
                'project/sources/org/art/main.cpp': b'',
            })

        resources = {'resources_root': 'project/resources'}

        load_resources(file_system, resources, None, None, None, None)

        expected_resources = {
            'project/resources/org/art/app.config',
            'project/resources/org/art/locale.rsx'
        }

        self.assertEqual({normpath(p)
                          for p in resources['resources']},
                         {normpath(p)
                          for p in expected_resources})
Ejemplo n.º 22
0
    def test_get_packages_from_directory(self):
        directory = 'packages'
        file_system = FileSystemMock({directory}, {
            f'{directory}/org-art-x32-windows-msvc-debug-1.0.0.tar.gz':
            b'',
            f'{directory}/other_org-other_art-x64-linux-gcc-release-5.2.2.tar.gz':
            b'',
            f'{directory}/some_other_file.txt':
            b'',
            'another_org-another_art-x32-darwin-clang-debug-2.1.0.tar.gz':
            b''
        })

        packages = get_packages_from_directory(file_system, directory)

        expected_packages = [
            'org-art-x32-windows-msvc-debug-1.0.0.tar.gz',
            'other_org-other_art-x64-linux-gcc-release-5.2.2.tar.gz'
        ]

        self.assertEqual(packages, expected_packages)
Ejemplo n.º 23
0
    def test_pack(self):
        file_system = FileSystemMock({'path/to'}, {
            'a.txt': b'a-contents',
            'b.txt': b'b-contents',
            'c.txt': b'c-contents'
        })
        package_path = 'path/to/package.tar.gz'
        package_files = [('a.txt', 'a.txt'), ('b.txt', 'other/b.txt')]
        cache = {}

        pack(file_system, package_path, package_files, cache)

        expected_files = {
            'a.txt':
            b'a-contents',
            'b.txt':
            b'b-contents',
            'c.txt':
            b'c-contents',
            'path/to/package.tar.gz':
            pickle.dumps({
                'a.txt': b'a-contents',
                'other/b.txt': b'b-contents'
            })
        }

        self.assertEqual(file_system.files,
                         {normpath(p): d
                          for p, d in expected_files.items()})

        self.assertEqual(file_system.directories, {normpath('path/to')})

        expected_cache = {
            'a.txt':
            'b3bc691c7cf43c01885b2e0ee2cf34b2dc7e482d9074de78bf4950344aade4be',
            'b.txt':
            'eb214d6536a9bbba4599c5bb566c609fc35e02a1d7c71cccfb5ebaa4575e2288'
        }

        self.assertEqual(cache, expected_cache)
Ejemplo n.º 24
0
    def test_load_headers_stage(self):
        file_system = FileSystemMock(
            {'project/resources/org/art/', 'project/sources/org/art'}, {
                'project/resources/org/art/precomp.hpp': b'',
                'project/sources/org/art/main.hpp': b'',
                'project/sources/org/art/inc.hpp': b'',
                'project/sources/org/art/main.cpp': b''
            })

        resources = {'headers_root': 'project/sources'}

        load_headers(file_system, resources, None, None, None, None)

        expected_headers = {
            'project/sources/org/art/main.hpp',
            'project/sources/org/art/inc.hpp'
        }

        self.assertEqual({normpath(p)
                          for p in resources['headers']},
                         {normpath(p)
                          for p in expected_headers})
Ejemplo n.º 25
0
    def test_create_pipeline_with_cycles(self):
        #
        #   ->[C]
        #   |  |
        #   | [B]
        #   |  |
        #   --[A]
        #
        do_nothing = lambda f, r, c, a, cfg, rp: None
        can_run = lambda _, __, ___: True
        stages = {
            'A': Stage('A', [['c']], ['a'], can_run, [], False, False,
                       do_nothing),
            'B': Stage('B', [['a']], ['b'], can_run, [], False, False,
                       do_nothing),
            'C': Stage('C', [['b']], ['c'], can_run, [], False, False,
                       do_nothing)
        }
        file_system = FileSystemMock()
        program_arguments = {'global': {}, 'byStage': {}}
        configuration = {}

        self.assertRaises(CyclicStagesError, create_pipeline, 'C', stages,
                          file_system, program_arguments, configuration)
Ejemplo n.º 26
0
    def test_load_clang_format_stage_with_client_configuration(self):
        normalized_executable_path = normpath(
            'path/to/clang_format_executable')
        normalized_style_file_path = normpath('my/project/.clang-format')

        file_system = FileSystemMock({'path/to', 'my/project'},
                                     {normalized_executable_path: b''})
        resources = {'project_directory': 'my/project'}
        configuration = {
            'clang-format-executable-path': normalized_executable_path
        }

        load_clang_format(file_system, resources, None, None, configuration,
                          None)

        self.assertEqual(resources['clang_format_executable'],
                         normalized_executable_path)

        self.assertEqual(normpath(resources['clang_format_style_file']),
                         normalized_style_file_path)

        self.assertEqual(
            file_system.files[normalized_style_file_path].decode('utf-8'),
            clang_format_style_file_contents)
Ejemplo n.º 27
0
    def test_link_library_using_cache_with_changed_library_interface(self):
        objects_root = 'objects/'
        libraries_root = 'libraries/'
        libraries_interfaces_root = 'libraries_interfaces/'
        symbols_tables_root = 'symbols_tables/'
        external_libraries_root = 'external/libraries'
        external_libraries_interfaces_root = 'external/libraries_interfaces'
        file_system = FileSystemMock(
            {
                objects_root, libraries_root, libraries_interfaces_root,
                symbols_tables_root, external_libraries_root,
                external_libraries_interfaces_root
            }, {
                'objects/a.obj':
                b'object-a.',
                'external/libraries/b.dll':
                b'external-library-b.',
                'external/libraries_interfaces/c.lib':
                b'updated-external-library-interface-c.'
            })
        compiler = CompilerMock(file_system)
        objects = ['objects/a.obj']
        external_libraries = ['external/libraries/b.dll']
        external_libraries_interfaces = ['external/libraries_interfaces/c.lib']
        cache = {
            'input': {
                'objects/a.obj':
                'a6cc476fe402432f09d3e66d73b6382421ee1a855ac6bde79357fc1483878463',
                'external/libraries/b.obj':
                '440602105d9abfce75656e19197e74539add8cb0dd002f4a550d46d7e8c1e837',
                'external/libraries_interfaces/c.lib':
                '8c777213d1130643127d77653c90f5d6784f6f95dac361afb454a3e6db084f4e'
            },
            'output':
            ('libraries/org-art-x32-windows-compmock-debug-1.0.0.dll',
             'libraries/interfaces/org-art-x32-windows-compmock-debug-1.0.0.lib',
             'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb')
        }
        library, library_interface, symbols_table = link_library_using_cache(
            file_system, compiler, libraries_root, libraries_interfaces_root,
            symbols_tables_root, external_libraries_root,
            external_libraries_interfaces_root, objects, external_libraries,
            external_libraries_interfaces, organization, artifact, version,
            cache)

        self.assertEqual(
            library, 'libraries/org-art-x32-windows-compmock-debug-1.0.0.dll')

        self.assertEqual(
            library_interface,
            'libraries_interfaces/org-art-x32-windows-compmock-debug-1.0.0.lib'
        )

        self.assertEqual(
            symbols_table,
            'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb')

        new_files = {
            'objects/a.obj':
            b'object-a.',
            'external/libraries/b.dll':
            b'external-library-b.',
            'external/libraries_interfaces/c.lib':
            b'updated-external-library-interface-c.',
            'libraries/org-art-x32-windows-compmock-debug-1.0.0.dll':
            b'object-a.external-library-b.updated-external-library-interface-c.dll',
            'libraries_interfaces/org-art-x32-windows-compmock-debug-1.0.0.lib':
            b'object-a.external-library-b.updated-external-library-interface-c.lib',
            'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb':
            b'object-a.external-library-b.updated-external-library-interface-c.pbd'
        }

        self.assertEqual(file_system.files,
                         {normpath(p): data
                          for p, data in new_files.items()})

        new_cache = {
            'input': {
                'objects/a.obj':
                'a6cc476fe402432f09d3e66d73b6382421ee1a855ac6bde79357fc1483878463',
                'external/libraries/b.dll':
                '440602105d9abfce75656e19197e74539add8cb0dd002f4a550d46d7e8c1e837',
                'external/libraries_interfaces/c.lib':
                '4655380785da55ddee626b49e92bf336911a4f8ea828b1693ecbf1d12714d8f8'
            },
            'output':
            ('libraries/org-art-x32-windows-compmock-debug-1.0.0.dll',
             'libraries_interfaces/org-art-x32-windows-compmock-debug-1.0.0.lib',
             'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb')
        }

        self.assertEqual(cache, new_cache)
Ejemplo n.º 28
0
    def test_link_executable_using_cache_with_changed_external_library(self):
        objects_root = 'objects/'
        executables_root = 'executables/'
        symbols_tables_root = 'symbols_tables/'
        external_libraries_root = 'external/libraries'
        external_libraries_interfaces_root = 'external/libraries_interfaces'
        file_system = FileSystemMock(
            {
                objects_root, executables_root, symbols_tables_root,
                external_libraries_root, external_libraries_interfaces_root
            }, {
                'objects/a.obj':
                b'object-a.',
                'external/libraries/b.dll':
                b'updated-external-library-b.',
                'external/libraries_interfaces/c.lib':
                b'external-library-interface-c.',
                'executables/my-executable.exe':
                b'object-a.external-library-b.external-library-interface-c.exe',
                'symbols_tables/my-executable.pdb':
                b'object-a.external-library-b.external-library-interface-c.pbd'
            })
        compiler = CompilerMock(file_system)
        objects = ['objects/a.obj']
        external_libraries = ['external/libraries/b.dll']
        external_libraries_interfaces = ['external/libraries_interfaces/c.lib']
        cache = {
            'input': {
                'objects/a.obj':
                'a6cc476fe402432f09d3e66d73b6382421ee1a855ac6bde79357fc1483878463',
                'external/libraries/b.dll':
                '440602105d9abfce75656e19197e74539add8cb0dd002f4a550d46d7e8c1e837',
                'external/libraries_interfaces/c.lib':
                '8c777213d1130643127d77653c90f5d6784f6f95dac361afb454a3e6db084f4e'
            },
            'output': ('executables/my-executable.exe',
                       'symbols_tables/my-executable.pdb')
        }

        executable, symbols_table = link_executable_using_cache(
            file_system, compiler, executables_root, symbols_tables_root,
            external_libraries_root, external_libraries_interfaces_root,
            objects, external_libraries, external_libraries_interfaces,
            organization, artifact, version, cache)

        self.assertEqual(
            executable,
            'executables/org-art-x32-windows-compmock-debug-1.0.0.exe')

        self.assertEqual(
            symbols_table,
            'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb')

        new_files = {
            'objects/a.obj':
            b'object-a.',
            'external/libraries/b.dll':
            b'updated-external-library-b.',
            'external/libraries_interfaces/c.lib':
            b'external-library-interface-c.',
            'executables/org-art-x32-windows-compmock-debug-1.0.0.exe':
            b'object-a.updated-external-library-b.external-library-interface-c.exe',
            'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb':
            b'object-a.updated-external-library-b.external-library-interface-c.pbd'
        }

        self.assertEqual(file_system.files,
                         {normpath(p): data
                          for p, data in new_files.items()})

        new_cache = {
            'input': {
                'objects/a.obj':
                'a6cc476fe402432f09d3e66d73b6382421ee1a855ac6bde79357fc1483878463',
                'external/libraries/b.dll':
                '09e93c7c7aae2efb94a0f6d12ee5b59c0b7a810989d84f866ef515e8dd0f6e41',
                'external/libraries_interfaces/c.lib':
                '8c777213d1130643127d77653c90f5d6784f6f95dac361afb454a3e6db084f4e'
            },
            'output':
            ('executables/org-art-x32-windows-compmock-debug-1.0.0.exe',
             'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb')
        }

        self.assertEqual(cache, new_cache)
Ejemplo n.º 29
0
    def test_compilation_using_cache(self):
        objects_root = 'objects/'
        sources_root = 'sources/'
        headers_root = 'sources/'
        external_headers_root = 'external/headers/'
        file_system = FileSystemMock(
            {objects_root, sources_root, headers_root, external_headers_root},
            {
                'sources/a.hpp': b'header-a.',
                'sources/a.cpp': b'source-a.',
                'sources/b.hpp': b'updated-header-b.',
                'sources/b.cpp': b'source-b.',
                'sources/d.hpp': b'header-d.',
                'sources/d.cpp': b'source-d.',
                'objects/a.obj': b'header-a.source-a.',
                'objects/b.obj': b'header-b.source-b.',
                'objects/c.obj': b'header-c.source-c.'
            })
        compiler = CompilerMock(file_system)
        headers = ['sources/a.hpp', 'sources/b.hpp', 'sources/d.hpp']
        sources = ['sources/a.cpp', 'sources/b.cpp', 'sources/d.cpp']
        cache = {
            'sources/a.cpp':
            '8ceb2730683fdf075d4ede855d5ed98f32be31b093f74b0bee13fd5dea9037dc',
            'sources/b.cpp':
            '5addc12d3b54fb9836277adccb06a03131ab92c10faf97613259bb77775db8d3',
            'sources/c.cpp':
            '853b9c27fdbe775b24a8fb14f7ef43aba1d6e698df4f2df6bc4e0f22c800f1d5'
        }
        objects = compile_using_cache(file_system, compiler, headers_root,
                                      external_headers_root, sources_root,
                                      objects_root, headers, sources, cache)

        self.assertEqual(objects,
                         ['objects/a.obj', 'objects/b.obj', 'objects/d.obj'])

        new_files = {
            'sources/a.hpp': b'header-a.',
            'sources/a.cpp': b'source-a.',
            'sources/b.hpp': b'updated-header-b.',
            'sources/b.cpp': b'source-b.',
            'sources/d.hpp': b'header-d.',
            'sources/d.cpp': b'source-d.',
            'objects/a.obj': b'header-a.source-a.',
            'objects/b.obj': b'updated-header-b.source-b.',
            'objects/d.obj': b'header-d.source-d.'
        }

        self.assertEqual(file_system.files,
                         {normpath(p): data
                          for p, data in new_files.items()})

        new_cache = {
            'sources/a.cpp':
            '8ceb2730683fdf075d4ede855d5ed98f32be31b093f74b0bee13fd5dea9037dc',
            'sources/b.cpp':
            'db4b8fea71a29aedd0eac30601ac3489bdc72a3261697215901cf04da2d6a931',
            'sources/d.cpp':
            'edf58f60231d34dfe3eb468e1b4cfeb35dd39cecd796183660cf13bf301f103b'
        }

        self.assertEqual(cache, new_cache)
Ejemplo n.º 30
0
    def test_key_retrieval_with_fresh_cache(self):
        file_name = 'my/file'
        file_system = FileSystemMock()

        with Cache(file_system, file_name) as cache:
            self.assertRaises(KeyError, cache.__getitem__, 'myKey')