def get_deploy_release(self) -> DeployRelease: set_home_directory() old_version = Version(0, 0, 1) new_version = Version(0, 1, 0) deploy = False release_details = ReleaseDetails(old_version, new_version, deploy, ProjectDetails()) return DeployRelease(release_details)
def get_prepare_release(self) -> CppGeneration: set_home_directory() old_version = Version(8, 4, 0) new_version = Version(8, 5, 0) deploy = False release_details = ReleaseDetails(old_version, new_version, deploy) return CppGeneration(release_details)
def get_prepare_release(self) -> CppGeneration: set_home_directory() old_version = Version(0, 0, 1) new_version = Version(0, 1, 0) deploy = False release_details = ReleaseDetails(old_version, new_version, deploy, qt_project_details()) return CppGeneration(release_details)
def test_conandata_yml(self) -> None: text = '' for i in range(3): text += PrepareConanRelease.create_conandata_yml_text( ProjectDetails(), Version(1, 1, i), "single_header_sha", "licence_sha") verify(text)
def get_version_number_hpp_text(version_object: Version) -> str: version_string = version_object.get_version_text_without_v() text = remove_indentation << f''' #pragma once #include "ApprovalTests/ApprovalsMacroDefaults.h" #define APPROVAL_TESTS_VERSION_MAJOR {version_object.major} #define APPROVAL_TESTS_VERSION_MINOR {version_object.minor} #define APPROVAL_TESTS_VERSION_PATCH {version_object.patch} #define APPROVAL_TESTS_VERSION_STR "{version_string}" #define APPROVAL_TESTS_VERSION \\ (APPROVAL_TESTS_VERSION_MAJOR * 10000 + APPROVAL_TESTS_VERSION_MINOR * 100 + \\ APPROVAL_TESTS_VERSION_PATCH) #if !APPROVAL_TESTS_HIDE_DEPRECATED_CODE // clang-format off // Deprecated, for regression only: #define APPROVALTESTS_VERSION APPROVAL_TESTS_VERSION #define APPROVALTESTS_VERSION_MAJOR APPROVAL_TESTS_VERSION_MAJOR #define APPROVALTESTS_VERSION_MINOR APPROVAL_TESTS_VERSION_MINOR #define APPROVALTESTS_VERSION_PATCH APPROVAL_TESTS_VERSION_PATCH #define APPROVALTESTS_VERSION_STR APPROVAL_TESTS_VERSION_STR // clang-format on #endif ''' return text
def confirm_previous_release_still_works(details: ReleaseDetails) -> None: last_approved = max(PrepareConanRelease.get_accepted_approval_releases( details.project_details), key=lambda x: Version.from_string_without_v(x)) DeployConanRelease.test_conan_build_passes(details.conan_details, last_approved)
def set_working_directory_and_load_current_version( library_folder_name: str) -> Version: """ :param library_folder_name: the sub-folder where headers are, e.g. "ApprovalTests" """ os.chdir(os.path.join("..", library_folder_name)) return Version.read(release_constants.build_dir)
def create_conandata_yml_text(new_version: Version, single_header_sha: str, licence_file_sha: str) -> str: new_version_with_v = new_version.get_version_text() conan_data = \ F''' {new_version.get_version_text_without_v()}: - url: https://github.com/approvals/ApprovalTests.cpp/releases/download/{new_version_with_v}/ApprovalTests.{new_version_with_v}.hpp sha256: {single_header_sha} - url: "https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/{new_version_with_v}/LICENSE" sha256: {licence_file_sha} ''' return conan_data
def create_conandata_yml_text(project_details: ProjectDetails, new_version: Version, single_header_sha: str, licence_file_sha: str) -> str: new_version_with_v = new_version.get_version_text() conan_data = \ F''' {new_version.get_version_text_without_v()}: - url: {project_details.github_project_url}/releases/download/{new_version_with_v}/{project_details.library_folder_name}.{new_version_with_v}.hpp sha256: {single_header_sha} - url: "https://raw.githubusercontent.com/approvals/{project_details.github_project_name}/{new_version_with_v}/LICENSE" sha256: {licence_file_sha} ''' return conan_data
def get_version_number_hpp_text(version_object: Version) -> str: version_string = version_object.get_version_text_without_v() text = remove_indentation << f''' #pragma once #define APPROVALTESTS_VERSION_MAJOR {version_object.major} #define APPROVALTESTS_VERSION_MINOR {version_object.minor} #define APPROVALTESTS_VERSION_PATCH {version_object.patch} #define APPROVALTESTS_VERSION_STR "{version_string}" #define APPROVALTESTS_VERSION \\ (APPROVALTESTS_VERSION_MAJOR * 10000 + APPROVALTESTS_VERSION_MINOR * 100 + \\ APPROVALTESTS_VERSION_PATCH) ''' return text
def create_portfile_cmake_text(new_version: Version, single_header_sha: str, licence_file_sha: str) -> str: new_version_with_v = new_version.get_version_text() vcpkg_data = remove_indentation_from(F''' vcpkg_download_distfile(single_header URLS https://github.com/approvals/ApprovalTests.cpp/releases/download/{new_version_with_v}/ApprovalTests.{new_version_with_v}.hpp FILENAME ApprovalTests.{new_version_with_v}.hpp SHA512 {single_header_sha} ) vcpkg_download_distfile(license_file URLS https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/{new_version_with_v}/LICENSE FILENAME ApprovalTestsLicense.{new_version_with_v} SHA512 {licence_file_sha} ) file(INSTALL "${{single_header}}" DESTINATION "${{CURRENT_PACKAGES_DIR}}/include" RENAME ApprovalTests.hpp) file(INSTALL "${{license_file}}" DESTINATION "${{CURRENT_PACKAGES_DIR}}/share/${{PORT}}" RENAME copyright) ''') return vcpkg_data
def get_version_number_hpp_text(version_object: Version, project_details: ProjectDetails) -> str: version_string = version_object.get_version_text_without_v() macro_prefix = project_details.macro_prefix # TODO Need to adjust amount of whitespace before trailing '`', depending on length of macro_prefix text = remove_indentation << f''' #pragma once #define {macro_prefix}_VERSION_MAJOR {version_object.major} #define {macro_prefix}_VERSION_MINOR {version_object.minor} #define {macro_prefix}_VERSION_PATCH {version_object.patch} #define {macro_prefix}_VERSION_STR "{version_string}" ''' line1 = f'#define {macro_prefix}_VERSION' line2 = f' ({macro_prefix}_VERSION_MAJOR * 10000 + {macro_prefix}_VERSION_MINOR * 100 +' second_part = remove_indentation << f''' {CppGeneration.append_continuation_character(line1)} {CppGeneration.append_continuation_character(line2)} {macro_prefix}_VERSION_PATCH) ''' return text + second_part
def test_update_version_number_header(self) -> None: new_version = Version(8, 5, 0) output = CppGeneration.get_version_number_hpp_text(new_version) verify(output)
def test(self) -> None: details = ReleaseDetails(Version(1, 2, 3), Version(1, 2, 4), True, ProjectDetails()) scrubber = Options().with_scrubber( lambda t: t.replace('"../../conan-', '"../../../conan/conan-')) verify_as_json(details, options=scrubber)
def load_current_version() -> Version: os.chdir("../ApprovalTests") return Version.read(release_constants.build_dir)
def test_get_new_branch_name(self) -> None: self.assertEqual( 'approval-tests-cpp.1.2.3', PrepareVcpkgRelease.get_new_branch_name(ProjectDetails(), Version(1, 2, 3)))
def test_portfile_cmake(self) -> None: text = PrepareVcpkgRelease.create_portfile_cmake_text( Version(1, 2, 3), "single_header_sha", "licence_sha") verify(text)
def test_create_version(self) -> None: version = Version(2, 3, 4) self.assertEqual('v.2.3.4', version.get_version_text())
def test_get_new_branch_name(self) -> None: self.assertEqual('approvaltests.cpp.qt.1.2.3', PrepareConanRelease.get_new_branch_name(qt_project_details(), Version(1, 2, 3)))
def test_config_yml(self) -> None: text = '' for i in range(3): text += PrepareConanRelease.create_conan_config_yml_text( Version(1, 1, i)) verify(text)
def load_test_version_ini() -> Version: source_dir = os.path.split(__file__)[0] version = Version.read(source_dir) return version
def test_sorting(self) -> None: versions = ['10.2.3', '10.10.4', '9.1.1', '10.2.4'] m = max(versions, key=lambda x: Version.from_string_without_v(x)) self.assertEqual(m, '10.10.4')
def test_vcpkg_json(self) -> None: text = PrepareVcpkgRelease.create_vcpkg_vcpkg_json_text( Version(1, 2, 3)) verify(text)
def test(self) -> None: details = ReleaseDetails(Version(1, 2, 3), Version(1, 2, 4), True, ProjectDetails()) verify_as_json(details)