summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-03-18 18:04:25 (GMT)
committerBrad King <brad.king@kitware.com>2024-03-18 19:11:49 (GMT)
commit9c472b9482545230ac36205110df7090db7ea451 (patch)
treece754a96c3b6be6ef389ed5e2bab402ad1883b7c /Tests
parent0b3756a7e3c4676c7f8a08c1047b6cdc7da147e2 (diff)
downloadCMake-9c472b9482545230ac36205110df7090db7ea451.zip
CMake-9c472b9482545230ac36205110df7090db7ea451.tar.gz
CMake-9c472b9482545230ac36205110df7090db7ea451.tar.bz2
Tests: Convert CPackWiXGenerator to RunCMake.CPack_WIX
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt22
-rw-r--r--Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake78
-rw-r--r--Tests/RunCMake/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-check.cmake1
-rw-r--r--Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-stdout.txt11
-rw-r--r--Tests/RunCMake/CPack_WIX/AppWiX-verify-stdout.txt33
-rw-r--r--Tests/RunCMake/CPack_WIX/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/CPack_WIX/cpack-check-common.cmake6
-rwxr-xr-xTests/RunCMake/CPack_WIX/print-msi.ps129
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/CMakeLists.txt (renamed from Tests/CPackWiXGenerator/CMakeLists.txt)0
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/file with spaces.h (renamed from Tests/CPackWiXGenerator/file with spaces.h)0
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/license.txt (renamed from Tests/CPackWiXGenerator/license.txt)0
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/mylib.cpp (renamed from Tests/CPackWiXGenerator/mylib.cpp)0
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/mylib.h (renamed from Tests/CPackWiXGenerator/mylib.h)0
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/mylibapp.cpp (renamed from Tests/CPackWiXGenerator/mylibapp.cpp)0
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/myotherapp.cpp (renamed from Tests/CPackWiXGenerator/myotherapp.cpp)0
-rw-r--r--Tests/RunCMake/RunCPack/AppWiX/patch.xml (renamed from Tests/CPackWiXGenerator/patch.xml)0
17 files changed, 90 insertions, 100 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 52aba53..828191b 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -978,28 +978,6 @@ if(BUILD_TESTING)
endif()
endif()
- if(WIN32)
- if(CMake_TEST_CPACK_WIX)
- add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND}
- -C \${CTEST_CONFIGURATION_TYPE}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator"
- "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
- ${build_generator_args}
- --build-project CPackWiXGenerator
- --build-options
- --test-command ${CMAKE_CMAKE_COMMAND}
- "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
- "-Dno_verify:BOOL=${CMake_TEST_WIX_NO_VERIFY}"
- "-Dconfig=\${CTEST_CONFIGURATION_TYPE}"
- -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake")
-
- set_property(TEST CPackWiXGenerator PROPERTY
- ATTACHED_FILES_ON_FAIL
- "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator/_CPack_Packages/win32/WIX/wix.log")
- endif()
- endif()
-
# On Windows run the CPackInnoSetupGenerator test
if(WIN32 AND CMake_TEST_CPACK_INNOSETUP)
add_test(CPackInnoSetupGenerator ${CMAKE_CTEST_COMMAND}
diff --git a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
deleted file mode 100644
index 28665ee..0000000
--- a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
+++ /dev/null
@@ -1,78 +0,0 @@
-message(STATUS "=============================================================")
-message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
-message(STATUS "")
-
-if(NOT CPackWiXGenerator_BINARY_DIR)
- message(FATAL_ERROR "CPackWiXGenerator_BINARY_DIR not set")
-endif()
-
-message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}")
-message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}")
-message(STATUS "CPackWiXGenerator_BINARY_DIR: ${CPackWiXGenerator_BINARY_DIR}")
-
-if(config)
- set(_C_config -C ${config})
-endif()
-
-execute_process(COMMAND "${CMAKE_CPACK_COMMAND}"
- ${_C_config}
- RESULT_VARIABLE CPack_result
- OUTPUT_VARIABLE CPack_output
- ERROR_VARIABLE CPack_error
- WORKING_DIRECTORY "${CPackWiXGenerator_BINARY_DIR}")
-
-if(CPack_result)
- message(FATAL_ERROR "CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
-else ()
- message(STATUS "CPack_output=${CPack_output}")
-endif()
-
-set(expected_file_mask "*.msi")
-file(GLOB installer_file "${expected_file_mask}")
-
-message(STATUS "installer_file='${installer_file}'")
-message(STATUS "expected_file_mask='${expected_file_mask}'")
-
-if(NOT installer_file)
- message(FATAL_ERROR "installer_file does not exist.")
-endif()
-
-function(run_wix_command command)
- file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT)
- find_program(WIX_PROGRAM NAMES ${command} NO_CACHE PATHS "${WIX_ROOT}" PATH_SUFFIXES "bin")
- if(NOT WIX_PROGRAM)
- message(FATAL_ERROR "Failed to find WiX Tool: ${WIX_PROGRAM}")
- endif()
-
- message(STATUS "Running WiX Tool: ${command} ${ARGN}")
-
- execute_process(COMMAND "${WIX_PROGRAM}" ${ARGN}
- RESULT_VARIABLE WIX_result
- OUTPUT_VARIABLE WIX_output
- ERROR_VARIABLE WIX_output
- WORKING_DIRECTORY "${CPackWiXGenerator_BINARY_DIR}")
-
- message(STATUS "${command} Output: \n${WIX_output}")
-
- if(WIX_result)
- message(FATAL_ERROR "WiX ${command} failed: ${WIX_result}")
- endif()
-endfunction()
-
-file(GLOB WXS_SOURCE_FILES
- "${CPackWiXGenerator_BINARY_DIR}/_CPack_Packages/*/WIX/*.wxs")
-
-if(NOT WXS_SOURCE_FILES)
- message(FATAL_ERROR "Failed finding WiX source files to validate.")
-endif()
-
-foreach(WXS_SOURCE_FILE IN LISTS WXS_SOURCE_FILES)
- run_wix_command(wixcop "${WXS_SOURCE_FILE}")
-endforeach()
-
-# error SMOK1076 : ICE61: This product should remove only older
-# versions of itself. The Maximum version is not less
-# than the current product. (1.0.0 1.0.0)
-if (NOT no_verify)
- run_wix_command(smoke -nologo -wx -sw1076 "${installer_file}")
-endif ()
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index d4bb490..a541e8d 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -1096,6 +1096,11 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k" AND NOT DEFINED CMake_TEST_E2K_BROKEN_L
endif()
add_RunCMake_test_group(CPack "${cpack_tests}")
+
+if(CMake_TEST_CPACK_WIX)
+ add_RunCMake_test(CPack_WIX)
+endif()
+
# add a test to make sure symbols are exported from a shared library
# for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used
add_RunCMake_test(AutoExportDll
diff --git a/Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-check.cmake b/Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-check.cmake
new file mode 100644
index 0000000..a7a28ae
--- /dev/null
+++ b/Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-check.cmake
@@ -0,0 +1 @@
+include(${RunCMake_SOURCE_DIR}/cpack-check-common.cmake)
diff --git a/Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-stdout.txt b/Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-stdout.txt
new file mode 100644
index 0000000..585166d
--- /dev/null
+++ b/Tests/RunCMake/CPack_WIX/AppWiX-cpack-WIX-stdout.txt
@@ -0,0 +1,11 @@
+CPack: Create package using WIX
+CPack: Install projects
+CPack: - Install project: CPackWiXGenerator \[Release\]
+CPack: - Install component: applications
+CPack: - Install component: applications2
+CPack: - Install component: extras
+CPack: - Install component: headers
+CPack: - Install component: libraries
+CPack: Create package
+CPack: - package: [^
+]*/Tests/RunCMake/CPack_WIX/AppWiX-build/MyLib-1\.0\.0-win64\.msi generated\.
diff --git a/Tests/RunCMake/CPack_WIX/AppWiX-verify-stdout.txt b/Tests/RunCMake/CPack_WIX/AppWiX-verify-stdout.txt
new file mode 100644
index 0000000..68f58ac
--- /dev/null
+++ b/Tests/RunCMake/CPack_WIX/AppWiX-verify-stdout.txt
@@ -0,0 +1,33 @@
+-- MyLib-1\.0\.0-win64\.msi
+Component: 'CM_CP_applications.bin.my_libapp.exe' 'CM_DP_applications.bin'
+Component: 'CM_SHORTCUT_applications' 'PROGRAM_MENU_FOLDER'
+Component: 'CM_SHORTCUT_DESKTOP_applications' 'DesktopFolder'
+Component: 'CM_CP_applications2.bin.my_other_app.exe' 'CM_DP_applications2.bin'
+Component: 'CM_SHORTCUT_applications2' 'PROGRAM_MENU_FOLDER'
+Component: 'CM_SHORTCUT_DESKTOP_applications2' 'DesktopFolder'
+Component: 'CM_C_EMPTY_CM_DP_extras.extras.empty' 'CM_DP_extras.extras.empty'
+Component: 'CM_CP_headers.include.file_with_spaces.h' 'CM_DP_headers.include'
+Component: 'CM_CP_headers.include.mylib.h' 'CM_DP_headers.include'
+Component: 'CM_CP_libraries.lib.mylib.lib' 'CM_DP_libraries.lib'
+Directory: 'INSTALL_ROOT' 'ProgramFiles64Folder' '[^']*\|CPack Component Example'
+Directory: 'CM_DP_applications.bin' 'INSTALL_ROOT' 'bin'
+Directory: 'PROGRAM_MENU_FOLDER' 'ProgramMenuFolder' 'MyLib'
+Directory: 'DesktopFolder' 'TARGETDIR' 'Desktop'
+Directory: 'CM_DP_applications2.bin' 'INSTALL_ROOT' 'bin'
+Directory: 'CM_DP_extras.extras.empty' 'CM_DP_extras.extras' 'empty'
+Directory: 'CM_DP_headers.include' 'INSTALL_ROOT' 'include'
+Directory: 'CM_DP_libraries.lib' 'INSTALL_ROOT' 'lib'
+Directory: 'CM_DP_extras.extras' 'INSTALL_ROOT' 'extras'
+Directory: 'ProgramFiles64Folder' 'TARGETDIR' '.'
+Directory: 'TARGETDIR' '' 'SourceDir'
+Directory: 'ProgramMenuFolder' 'TARGETDIR' '.'
+File: 'CM_FP_applications.bin.my_libapp.exe' 'CM_CP_applications.bin.my_libapp.exe' '[^']*\|my-libapp.exe'
+File: 'CM_FP_applications2.bin.my_other_app.exe' 'CM_CP_applications2.bin.my_other_app.exe' '[^']*\|my-other-app.exe'
+File: 'CM_FP_headers.include.file_with_spaces.h' 'CM_CP_headers.include.file_with_spaces.h' '[^']*\|file with spaces.h'
+File: 'CM_FP_headers.include.mylib.h' 'CM_CP_headers.include.mylib.h' 'mylib.h'
+File: 'CM_FP_libraries.lib.mylib.lib' 'CM_CP_libraries.lib.mylib.lib' 'mylib.lib'
+Shortcut: 'CM_SP_applications.bin.my_libapp.exe' 'PROGRAM_MENU_FOLDER' '[^']*\|CPack WiX Test' 'CM_SHORTCUT_applications'
+Shortcut: 'CM_DSP_applications.bin.my_libapp.exe' 'DesktopFolder' '[^']*\|CPack WiX Test' 'CM_SHORTCUT_DESKTOP_applications'
+Shortcut: 'CM_SP_applications2.bin.my_other_app.exe' 'PROGRAM_MENU_FOLDER' '[^']*\|Second CPack WiX Test' 'CM_SHORTCUT_applications2'
+Shortcut: 'CM_DSP_applications2.bin.my_other_app.exe' 'DesktopFolder' '[^']*\|Second CPack WiX Test' 'CM_SHORTCUT_DESKTOP_applications2'
+--
diff --git a/Tests/RunCMake/CPack_WIX/RunCMakeTest.cmake b/Tests/RunCMake/CPack_WIX/RunCMakeTest.cmake
new file mode 100644
index 0000000..1e81497
--- /dev/null
+++ b/Tests/RunCMake/CPack_WIX/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCPack)
+
+set(RunCPack_GENERATORS WIX)
+
+run_cpack(AppWiX BUILD GLOB *.msi VERIFY powershell -ExecutionPolicy Bypass -File ${CMAKE_CURRENT_LIST_DIR}/print-msi.ps1)
diff --git a/Tests/RunCMake/CPack_WIX/cpack-check-common.cmake b/Tests/RunCMake/CPack_WIX/cpack-check-common.cmake
new file mode 100644
index 0000000..2f16d71
--- /dev/null
+++ b/Tests/RunCMake/CPack_WIX/cpack-check-common.cmake
@@ -0,0 +1,6 @@
+file(GLOB wix_log_file RELATIVE "${RunCMake_TEST_BINARY_DIR}" "${RunCMake_TEST_BINARY_DIR}/_CPack_Packages/*/WIX/wix.log")
+if(wix_log_file)
+ file(READ "${RunCMake_TEST_BINARY_DIR}/${wix_log_file}" wix_log)
+ string(REPLACE "\n" "\n wix-log> " wix_log " wix-log> ${wix_log}")
+ set(RunCMake_TEST_FAILURE_MESSAGE "${wix_log_file}:\n${wix_log}")
+endif()
diff --git a/Tests/RunCMake/CPack_WIX/print-msi.ps1 b/Tests/RunCMake/CPack_WIX/print-msi.ps1
new file mode 100755
index 0000000..01fdbc8
--- /dev/null
+++ b/Tests/RunCMake/CPack_WIX/print-msi.ps1
@@ -0,0 +1,29 @@
+# https://learn.microsoft.com/en-us/windows/win32/msi/database-tables
+
+param (
+ $file
+ )
+
+function printTable {
+ param (
+ $msi,
+ [string]$name,
+ [int[]]$columns = (1)
+ )
+
+ try {
+ $view = $msi.OpenView("select * from " + $name)
+ $view.Execute()
+ while ($record = $view.Fetch()) {
+ Write-Host ($name + ": " + ($columns | ForEach-Object {"'" + $record.StringData($_) + "'"}))
+ }
+ } catch {}
+}
+
+$installer = New-Object -ComObject WindowsInstaller.Installer
+$msi = $installer.OpenDatabase($file, 0)
+
+printTable -msi $msi -name "Component" -columns 1,3
+printTable -msi $msi -name "Directory" -columns 1,2,3
+printTable -msi $msi -name "File" -columns 1,2,3
+printTable -msi $msi -name "Shortcut" -columns 1,2,3,4
diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/RunCMake/RunCPack/AppWiX/CMakeLists.txt
index 33fdc5e..33fdc5e 100644
--- a/Tests/CPackWiXGenerator/CMakeLists.txt
+++ b/Tests/RunCMake/RunCPack/AppWiX/CMakeLists.txt
diff --git a/Tests/CPackWiXGenerator/file with spaces.h b/Tests/RunCMake/RunCPack/AppWiX/file with spaces.h
index e69de29..e69de29 100644
--- a/Tests/CPackWiXGenerator/file with spaces.h
+++ b/Tests/RunCMake/RunCPack/AppWiX/file with spaces.h
diff --git a/Tests/CPackWiXGenerator/license.txt b/Tests/RunCMake/RunCPack/AppWiX/license.txt
index 7942783..7942783 100644
--- a/Tests/CPackWiXGenerator/license.txt
+++ b/Tests/RunCMake/RunCPack/AppWiX/license.txt
diff --git a/Tests/CPackWiXGenerator/mylib.cpp b/Tests/RunCMake/RunCPack/AppWiX/mylib.cpp
index 8d63071..8d63071 100644
--- a/Tests/CPackWiXGenerator/mylib.cpp
+++ b/Tests/RunCMake/RunCPack/AppWiX/mylib.cpp
diff --git a/Tests/CPackWiXGenerator/mylib.h b/Tests/RunCMake/RunCPack/AppWiX/mylib.h
index 5d0a822..5d0a822 100644
--- a/Tests/CPackWiXGenerator/mylib.h
+++ b/Tests/RunCMake/RunCPack/AppWiX/mylib.h
diff --git a/Tests/CPackWiXGenerator/mylibapp.cpp b/Tests/RunCMake/RunCPack/AppWiX/mylibapp.cpp
index a438ac7..a438ac7 100644
--- a/Tests/CPackWiXGenerator/mylibapp.cpp
+++ b/Tests/RunCMake/RunCPack/AppWiX/mylibapp.cpp
diff --git a/Tests/CPackWiXGenerator/myotherapp.cpp b/Tests/RunCMake/RunCPack/AppWiX/myotherapp.cpp
index 5047a34..5047a34 100644
--- a/Tests/CPackWiXGenerator/myotherapp.cpp
+++ b/Tests/RunCMake/RunCPack/AppWiX/myotherapp.cpp
diff --git a/Tests/CPackWiXGenerator/patch.xml b/Tests/RunCMake/RunCPack/AppWiX/patch.xml
index 13c392d..13c392d 100644
--- a/Tests/CPackWiXGenerator/patch.xml
+++ b/Tests/RunCMake/RunCPack/AppWiX/patch.xml