From 750c2b67e36c3593c590887a63382bef91cb2260 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sun, 16 Mar 2025 09:43:12 +0100 Subject: [PATCH 1/4] [unit-test-cmake] Install macros only for host triplet --- scripts/test_ports/unit-test-cmake/portfile.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/test_ports/unit-test-cmake/portfile.cmake b/scripts/test_ports/unit-test-cmake/portfile.cmake index 36a1db33abadd8..3e5785465a5c4f 100644 --- a/scripts/test_ports/unit-test-cmake/portfile.cmake +++ b/scripts/test_ports/unit-test-cmake/portfile.cmake @@ -1,5 +1,8 @@ set(VCPKG_POLICY_EMPTY_PACKAGE enabled) -file(INSTALL "${CURRENT_PORT_DIR}/test-macros.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +if(NOT VCPKG_CROSSCOMPILING) + file(INSTALL "${CURRENT_PORT_DIR}/test-macros.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +endif() include("${CURRENT_PORT_DIR}/test-macros.cmake") From 876ac31cdfac4bbd4717db9eb38ab3d595771607 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sun, 16 Mar 2025 09:47:29 +0100 Subject: [PATCH 2/4] [vcpkg-ci-vcpkg-make] Renamed from vcpkg-make-tests Use the common prefix with regard to port-under-test. --- .../portfile.cmake | 0 .../test-z_adapt_lib_link_names.cmake | 0 .../test-z_vcpkg_make_determine_arch.cmake | 0 ...est-z_vcpkg_make_determine_host_arch.cmake | 0 ...t-z_vcpkg_make_determine_target_arch.cmake | 0 ...t-z_vcpkg_make_prepare_compile_flags.cmake | 0 .../test_ports/vcpkg-ci-vcpkg-make/vcpkg.json | 40 ++++++++++++++++++ .../test_ports/vcpkg-make-tests/vcpkg.json | 41 ------------------- 8 files changed, 40 insertions(+), 41 deletions(-) rename scripts/test_ports/{vcpkg-make-tests => vcpkg-ci-vcpkg-make}/portfile.cmake (100%) rename scripts/test_ports/{vcpkg-make-tests => vcpkg-ci-vcpkg-make}/test-z_adapt_lib_link_names.cmake (100%) rename scripts/test_ports/{vcpkg-make-tests => vcpkg-ci-vcpkg-make}/test-z_vcpkg_make_determine_arch.cmake (100%) rename scripts/test_ports/{vcpkg-make-tests => vcpkg-ci-vcpkg-make}/test-z_vcpkg_make_determine_host_arch.cmake (100%) rename scripts/test_ports/{vcpkg-make-tests => vcpkg-ci-vcpkg-make}/test-z_vcpkg_make_determine_target_arch.cmake (100%) rename scripts/test_ports/{vcpkg-make-tests => vcpkg-ci-vcpkg-make}/test-z_vcpkg_make_prepare_compile_flags.cmake (100%) create mode 100644 scripts/test_ports/vcpkg-ci-vcpkg-make/vcpkg.json delete mode 100644 scripts/test_ports/vcpkg-make-tests/vcpkg.json diff --git a/scripts/test_ports/vcpkg-make-tests/portfile.cmake b/scripts/test_ports/vcpkg-ci-vcpkg-make/portfile.cmake similarity index 100% rename from scripts/test_ports/vcpkg-make-tests/portfile.cmake rename to scripts/test_ports/vcpkg-ci-vcpkg-make/portfile.cmake diff --git a/scripts/test_ports/vcpkg-make-tests/test-z_adapt_lib_link_names.cmake b/scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_adapt_lib_link_names.cmake similarity index 100% rename from scripts/test_ports/vcpkg-make-tests/test-z_adapt_lib_link_names.cmake rename to scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_adapt_lib_link_names.cmake diff --git a/scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_determine_arch.cmake b/scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_determine_arch.cmake similarity index 100% rename from scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_determine_arch.cmake rename to scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_determine_arch.cmake diff --git a/scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_determine_host_arch.cmake b/scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_determine_host_arch.cmake similarity index 100% rename from scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_determine_host_arch.cmake rename to scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_determine_host_arch.cmake diff --git a/scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_determine_target_arch.cmake b/scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_determine_target_arch.cmake similarity index 100% rename from scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_determine_target_arch.cmake rename to scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_determine_target_arch.cmake diff --git a/scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_prepare_compile_flags.cmake b/scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_prepare_compile_flags.cmake similarity index 100% rename from scripts/test_ports/vcpkg-make-tests/test-z_vcpkg_make_prepare_compile_flags.cmake rename to scripts/test_ports/vcpkg-ci-vcpkg-make/test-z_vcpkg_make_prepare_compile_flags.cmake diff --git a/scripts/test_ports/vcpkg-ci-vcpkg-make/vcpkg.json b/scripts/test_ports/vcpkg-ci-vcpkg-make/vcpkg.json new file mode 100644 index 00000000000000..abf9e82d4d1a56 --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-vcpkg-make/vcpkg.json @@ -0,0 +1,40 @@ +{ + "name": "vcpkg-ci-vcpkg-make", + "version-string": "ci", + "description": "Ensures that the vcpkg-make port functions are unit tested.", + "license": "MIT", + "dependencies": [ + { + "name": "unit-test-cmake", + "host": true + }, + { + "name": "vcpkg-make", + "host": true + } + ], + "default-features": [ + "z-vcpkg-make-determine-arch", + "z-vcpkg-make-determine-host-arch", + "z-vcpkg-make-determine-target-arch", + "z-vcpkg-make-prepare-compile-flags", + "z-vcpkg-make-z-adapt-lib-link-names" + ], + "features": { + "z-vcpkg-make-determine-arch": { + "description": "Test the z_vcpkg_make_determine_arch function" + }, + "z-vcpkg-make-determine-host-arch": { + "description": "Test the z_vcpkg_make_determine_host_arch function" + }, + "z-vcpkg-make-determine-target-arch": { + "description": "Test the z_vcpkg_make_determine_target_arch function" + }, + "z-vcpkg-make-prepare-compile-flags": { + "description": "Test the z_vcpkg_make_prepare_compile_flags function" + }, + "z-vcpkg-make-z-adapt-lib-link-names": { + "description": "Test the z_vcpkg_make_z_adapt_lib_link_names function" + } + } +} diff --git a/scripts/test_ports/vcpkg-make-tests/vcpkg.json b/scripts/test_ports/vcpkg-make-tests/vcpkg.json deleted file mode 100644 index 8e02bdfc7a8224..00000000000000 --- a/scripts/test_ports/vcpkg-make-tests/vcpkg.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "vcpkg-make-tests", - "version-string": "0", - "description": "Ensures that the vcpkg-make port functions are unit tested.", - "license": "MIT", - "dependencies": [ - { - "name": "unit-test-cmake", - "host": true - }, - { - "name": "vcpkg-make", - "host": true - } - ], - "default-features": [ - "z-vcpkg-make-prepare-compile-flags", - "z-vcpkg-make-determine-arch", - "z-vcpkg-make-determine-host-arch", - "z-vcpkg-make-determine-target-arch", - "z-vcpkg-make-z-adapt-lib-link-names" - ], - "features": { - "z-vcpkg-make-prepare-compile-flags": { - "description": "Test the z_vcpkg_make_prepare_compile_flags function" - }, - "z-vcpkg-make-determine-arch":{ - "description": "Test the z_vcpkg_make_determine_arch function" - }, - "z-vcpkg-make-determine-host-arch":{ - "description": "Test the z_vcpkg_make_determine_host_arch function" - }, - "z-vcpkg-make-determine-target-arch":{ - "description": "Test the z_vcpkg_make_determine_target_arch function" - }, - "z-vcpkg-make-z-adapt-lib-link-names":{ - "description": "Test the z_vcpkg_make_z_adapt_lib_link_names function" - } - } - } - \ No newline at end of file From 6089ad18cfd51bba7486c5d5e6f24bf9232562f5 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sun, 16 Mar 2025 10:22:45 +0100 Subject: [PATCH 3/4] [unit-test-cmake] Cleanup test pc files --- .../test_ports/unit-test-cmake/test-vcpkg_fixup_pkgconfig.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/test_ports/unit-test-cmake/test-vcpkg_fixup_pkgconfig.cmake b/scripts/test_ports/unit-test-cmake/test-vcpkg_fixup_pkgconfig.cmake index 625cb3ce2d4669..758594bfd7cec7 100644 --- a/scripts/test_ports/unit-test-cmake/test-vcpkg_fixup_pkgconfig.cmake +++ b/scripts/test_ports/unit-test-cmake/test-vcpkg_fixup_pkgconfig.cmake @@ -198,3 +198,5 @@ Libs: -L${prefix}/lib -lgeneralinfod ]]) unit_test_ensure_success([[ vcpkg_fixup_pkgconfig(SKIP_CHECK) ]]) unit_test_pkgconfig_check_key("debug;release" "Libs:" [[ "-L${prefix}/lib" -lgeneralinfod]]) + +file(REMOVE_RECURSE "${pc_file_release}" "${pc_file_debug}") From bf8cb80a5e24557324bb180a9a080dd8bbaca99e Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sun, 16 Mar 2025 10:29:31 +0100 Subject: [PATCH 4/4] [unit-test-cmake] Add unit_test_report_result() --- scripts/test_ports/unit-test-cmake/portfile.cmake | 4 +--- scripts/test_ports/unit-test-cmake/test-macros.cmake | 7 +++++++ .../vcpkg-ci-cmake-toolchain-file/portfile.cmake | 2 ++ scripts/test_ports/vcpkg-ci-vcpkg-make/portfile.cmake | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/test_ports/unit-test-cmake/portfile.cmake b/scripts/test_ports/unit-test-cmake/portfile.cmake index 3e5785465a5c4f..0dc09c52f30f2a 100644 --- a/scripts/test_ports/unit-test-cmake/portfile.cmake +++ b/scripts/test_ports/unit-test-cmake/portfile.cmake @@ -38,6 +38,4 @@ if("execute-required-process" IN_LIST FEATURES) include("${CMAKE_CURRENT_LIST_DIR}/test-vcpkg_execute_required_process.cmake") endif() -if(Z_VCPKG_UNIT_TEST_HAS_ERROR) - _message(FATAL_ERROR "At least one test failed") -endif() +unit_test_report_result() diff --git a/scripts/test_ports/unit-test-cmake/test-macros.cmake b/scripts/test_ports/unit-test-cmake/test-macros.cmake index bf1c3c9233568e..031ec7ef792c48 100644 --- a/scripts/test_ports/unit-test-cmake/test-macros.cmake +++ b/scripts/test_ports/unit-test-cmake/test-macros.cmake @@ -22,6 +22,13 @@ macro(message level msg) endif() endmacro() +# Call this at the end of testing. +macro(unit_test_report_result) + if(Z_VCPKG_UNIT_TEST_HAS_ERROR) + _message(FATAL_ERROR "At least one test failed") + endif() +endmacro() + set(Z_VCPKG_UNIT_TEST_HAS_ERROR OFF CACHE BOOL "" FORCE) unset_fatal_error() diff --git a/scripts/test_ports/vcpkg-ci-cmake-toolchain-file/portfile.cmake b/scripts/test_ports/vcpkg-ci-cmake-toolchain-file/portfile.cmake index 06e58b130bc319..7f70d162ef3563 100644 --- a/scripts/test_ports/vcpkg-ci-cmake-toolchain-file/portfile.cmake +++ b/scripts/test_ports/vcpkg-ci-cmake-toolchain-file/portfile.cmake @@ -160,3 +160,5 @@ unit_test_ensure_cmake_error([[ set(CMAKE_REQUIRE_FIND_PACKAGE_absentPackageX 1) find_package(transitiveOptionalAbsentPackageX REQUIRED) ]]) + +unit_test_report_result() diff --git a/scripts/test_ports/vcpkg-ci-vcpkg-make/portfile.cmake b/scripts/test_ports/vcpkg-ci-vcpkg-make/portfile.cmake index 245ab0e55b74ed..f097c8c23df8e1 100644 --- a/scripts/test_ports/vcpkg-ci-vcpkg-make/portfile.cmake +++ b/scripts/test_ports/vcpkg-ci-vcpkg-make/portfile.cmake @@ -20,3 +20,5 @@ endif() if("z-vcpkg-make-z-adapt-lib-link-names" IN_LIST FEATURES) include("${CMAKE_CURRENT_LIST_DIR}/test-z_adapt_lib_link_names.cmake") endif() + +unit_test_report_result()