def test_sort_parts_by_dependencies(self) -> None:
        parts = [Parts('higher.h', ['lower.h']), Parts('lower.h', [])]
        self.assertTrue(SingleHeaderFile.depends_on(parts[0], parts[1]))
        self.assertFalse(SingleHeaderFile.depends_on(parts[1], parts[0]))

        parts = SingleHeaderFile.sort_parts_by_dependencies(parts)
        verify_all('sorted', parts)
Example #2
0
    def create_single_header_file(self) -> str:
        self.create_simulated_single_header_file(include_cpps=True)

        simulated_single_header = os.path.abspath(
            self.details.locations.simulated_single_header_file_path)
        with use_directory("../build"):
            print(os.getcwd())
            self.run_for_approval_tests(simulated_single_header,
                                        self.details.release_new_single_header)
            text = read_file(self.details.release_new_single_header)

            year = datetime.now().year
            text = (
                f'// {self.details.project_details.github_project_name} version {self.details.new_version_as_text()}\n'
                f'// More information at: {self.details.project_details.github_project_url}\n'
                f'//\n'
                f'// Copyright (c) {year} Llewellyn Falco and Clare Macrae. All rights reserved.\n'
                f'//\n'
                f'// Distributed under the Apache 2.0 License\n'
                f'// See https://opensource.org/licenses/Apache-2.0\n'
                f'\n'
                '//----------------------------------------------------------------------\n'
                '// Welcome to Approval Tests.\n'
                '//\n'
                '// If you experience linker errors about missing symbols, it means\n'
                '// you have forgotten to configure your test framework for Approval Tests.\n'
                '//\n'
                '// For help with this, please see:\n'
                '//     https://github.com/approvals/ApprovalTests.cpp/blob/master/doc/TroubleshootingMisconfiguredMain.md\n'
                '//----------------------------------------------------------------------\n'
                f'{text}')
            write_file(self.details.release_new_single_header, text)

        # HACK! A side-effect of this method is that it overwrites
        # the version-controlled simulated single-header, including .cpp
        # files.
        # Revert that change:
        self.create_simulated_single_header_file(include_cpps=False)

        # Check for broken headers in the generated text
        # (but only after we have reverted any modified source code)
        header_files_h = SingleHeaderFile.get_all_files('.', '.h')
        header_files_hpp = SingleHeaderFile.get_all_files('.', '.hpp')
        errors = CppGeneration.validate_single_header_file_content(
            header_files_h, header_files_hpp, text)
        if errors != "":
            raise RuntimeError(errors)

        return os.path.abspath(self.details.release_new_single_header)
 def disabled_test_create_simulated_single_header_file(self) -> None:
     # The output of this depends on the current C++ code, so changes
     # over time. It is here to help when refactoring the release process.
     prepare_release = self.get_prepare_release()
     verify(
         SingleHeaderFile.create_content(
             '.',
             prepare_release.details.project_details,
             include_cpps=False))
 def create_simulated_single_header_file(self) -> str:
     return SingleHeaderFile.create('.')
#! /usr/bin/env python3
import os

from scripts.project_details import ProjectDetails
from scripts.single_header_file import SingleHeaderFile

if __name__ == '__main__':
    os.chdir("../ApprovalTests")
    SingleHeaderFile.create('.', ProjectDetails(), include_cpps=False)
Example #6
0
 def create_simulated_single_header_file(self, include_cpps: bool) -> str:
     return SingleHeaderFile.create('.',
                                    self.details.project_details,
                                    include_cpps=include_cpps)
 def test_depends_on_uses_whole_file_name(self) -> None:
     file1 = Parts('file1.h', [])
     file2 = Parts('file2.h', ['prefixed_file1.h'])
     self.assertFalse(SingleHeaderFile.depends_on(file2, file1))
#! /usr/bin/env python3
import os

from scripts.single_header_file import SingleHeaderFile

if __name__ == '__main__':
    os.chdir("../ApprovalTests")
    SingleHeaderFile.create('.')