diff --git a/AGENTS.md b/AGENTS.md index 6d651de7..07614c0c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -82,8 +82,9 @@ Important CMake options: The headers of the embedded assets are generated, and checked by CTest, in pure CMake (`js/core/EmbedAsset.cmake`; the `webfront-embedded-assets` target regenerates them). Normal C++ builds consume the versioned headers. Configuring with `WEBFRONT_ENABLE_TESTING=ON` downloads the pinned bootstrap environment and the packages of the test registry, each verified -against its SHA-512; `-DWEBFRONT_BOOTSTRAP_DIR` and `-DWEBFRONT_REGISTRY_DIR` replace those downloads on a machine -without network access. +against its SHA-512, tried three times and kept once per machine (`WEBFRONT_DOWNLOAD_CACHE`, by default in CPM's cache or +the user's cache directory), so a new build tree links them instead of downloading them again; `-DWEBFRONT_BOOTSTRAP_DIR` +and `-DWEBFRONT_REGISTRY_DIR` replace those downloads on a machine without network access. - `WEBFRONT_EMBED_CEF=OFF` (default): CEF is unavailable; this is the normal unit-test build. `ON` downloads/links CEF and enables the automated browser test; it makes `CEFFrontend` available but does not select it: `webfront::WebFront` always uses the system browser. - `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases. diff --git a/cmake/WebFrontBootstrap.cmake b/cmake/WebFrontBootstrap.cmake index dba1b6fb..152b1bd0 100644 --- a/cmake/WebFrontBootstrap.cmake +++ b/cmake/WebFrontBootstrap.cmake @@ -15,6 +15,124 @@ set(WEBFRONT_BOOTSTRAP_INTEGRITY "sha512-qaSYOJvxcXtKIbrjfjZFFvfoQrda5NfBq24ttQ7 # A directory holding environment.tgz (the pinned archive) replaces the download on a machine without network access. set(WEBFRONT_BOOTSTRAP_DIR "" CACHE PATH "Directory with the pinned bootstrap environment.tgz, instead of downloading it") +# The verified downloads of the configure, kept once per machine: a new build tree links them instead of downloading them +# again. WEBFRONT_DOWNLOAD_CACHE or CPM's cache chooses the place; WebFront's own build otherwise uses the user's cache +# directory, and a project that consumes WebFront keeps each download in its build tree unless it asks. An environment +# variable set to nothing counts as unset, so that it never makes a path at the root; -DWEBFRONT_DOWNLOAD_CACHE= disables +# the cache. +get_filename_component(_webfront_source "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +set(_webfront_download_cache "") +if(NOT "$ENV{WEBFRONT_DOWNLOAD_CACHE}" STREQUAL "") + set(_webfront_download_cache "$ENV{WEBFRONT_DOWNLOAD_CACHE}") +elseif(NOT "$ENV{CPM_SOURCE_CACHE}" STREQUAL "") + set(_webfront_download_cache "$ENV{CPM_SOURCE_CACHE}/webfront-downloads") +elseif(NOT CMAKE_SOURCE_DIR STREQUAL _webfront_source) + # A consuming project: each download stays in its build tree. +elseif(CMAKE_HOST_WIN32 AND NOT "$ENV{LOCALAPPDATA}" STREQUAL "") + set(_webfront_download_cache "$ENV{LOCALAPPDATA}/WebFront/downloads") +elseif(CMAKE_HOST_APPLE AND NOT "$ENV{HOME}" STREQUAL "") + set(_webfront_download_cache "$ENV{HOME}/Library/Caches/WebFront/downloads") +elseif(NOT "$ENV{XDG_CACHE_HOME}" STREQUAL "") + set(_webfront_download_cache "$ENV{XDG_CACHE_HOME}/webfront/downloads") +elseif(NOT "$ENV{HOME}" STREQUAL "") + set(_webfront_download_cache "$ENV{HOME}/.cache/webfront/downloads") +endif() +set(WEBFRONT_DOWNLOAD_CACHE "${_webfront_download_cache}" CACHE PATH "Directory keeping the verified configure downloads for every build tree (empty: none)") +# A download that fails is tried again, WEBFRONT_DOWNLOAD_ATTEMPTS times in all, WEBFRONT_DOWNLOAD_RETRY_DELAY seconds apart. +if(NOT DEFINED WEBFRONT_DOWNLOAD_ATTEMPTS) + set(WEBFRONT_DOWNLOAD_ATTEMPTS 3) +endif() +if(NOT DEFINED WEBFRONT_DOWNLOAD_RETRY_DELAY) + set(WEBFRONT_DOWNLOAD_RETRY_DELAY 5) +endif() + +# Sets to TRUE when a file can be created in , which is created when missing. An existing directory +# may still refuse files (a read-only cache, a mount of another user's): a probe file tells. +function(_webfront_writable_directory directory output) + set(${output} FALSE PARENT_SCOPE) + file(MAKE_DIRECTORY "${directory}" RESULT made) + if(NOT made EQUAL 0) + return() + endif() + string(RANDOM LENGTH 12 suffix) + set(probe "${directory}/.webfront-probe-${suffix}") + execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${probe}" RESULT_VARIABLE touched OUTPUT_QUIET ERROR_QUIET) + if(touched EQUAL 0 AND EXISTS "${probe}") + file(REMOVE "${probe}") + set(${output} TRUE PARENT_SCOPE) + endif() +endfunction() + +# webfront_download_verified( URL SHA512 FAILURE MISMATCH ): makes a file whose SHA-512 +# is . A file already there with that digest is kept. Otherwise the machine's download cache provides it, a download +# filling the cache first; is then a link to the cached file, or a copy where a link cannot be made. A download that +# fails is tried again; when it still fails, the configure stops with FAILURE and the reason, and with MISMATCH when the +# data it brought has another digest. No file without the expected digest is ever left at or in the cache. +function(webfront_download_verified path) + cmake_parse_arguments(ARG "" "URL;SHA512;FAILURE;MISMATCH" "" ${ARGN}) + if(EXISTS "${path}") + file(SHA512 "${path}" actual) + if(actual STREQUAL ARG_SHA512) + return() + endif() + file(REMOVE "${path}") + endif() + get_filename_component(name "${path}" NAME) + get_filename_component(destination "${path}" DIRECTORY) + file(MAKE_DIRECTORY "${destination}") + set(target "${path}") + if(WEBFRONT_DOWNLOAD_CACHE) + # The first half of the digest names the entry: two files of the same name and version never meet. + string(SUBSTRING "${ARG_SHA512}" 0 32 key) + set(entry "${WEBFRONT_DOWNLOAD_CACHE}/${key}/${name}") + # A verified entry serves even a cache that cannot be written, such as a shared read-only one. + if(EXISTS "${entry}") + file(SHA512 "${entry}" actual) + if(actual STREQUAL ARG_SHA512) + file(CREATE_LINK "${entry}" "${path}" COPY_ON_ERROR) + return() + endif() + endif() + # A download fills the cache only where a file can be created; a damaged entry is replaced once verified. + _webfront_writable_directory("${WEBFRONT_DOWNLOAD_CACHE}/${key}" writable) + if(writable) + set(target "${entry}") + else() + message(WARNING "The download cache ${WEBFRONT_DOWNLOAD_CACHE} cannot be written: ${name} is kept in the build tree only") + endif() + endif() + set(present FALSE) + foreach(attempt RANGE 1 ${WEBFRONT_DOWNLOAD_ATTEMPTS}) + # Written aside, then renamed once verified: a concurrent configure never reads a partial file. + string(RANDOM LENGTH 12 suffix) + set(partial "${target}.${suffix}.partial") + file(DOWNLOAD "${ARG_URL}" "${partial}" STATUS result TLS_VERIFY ON INACTIVITY_TIMEOUT 60 TIMEOUT 600) + list(GET result 0 code) + if(code EQUAL 0) + file(SHA512 "${partial}" actual) + if(NOT actual STREQUAL ARG_SHA512) + file(REMOVE "${partial}") + message(FATAL_ERROR "${ARG_MISMATCH}") + endif() + file(RENAME "${partial}" "${target}") + set(present TRUE) + break() + endif() + file(REMOVE "${partial}") + list(GET result 1 reason) + if(attempt LESS WEBFRONT_DOWNLOAD_ATTEMPTS) + message(STATUS "Download of ${ARG_URL} failed (${reason}); trying again in ${WEBFRONT_DOWNLOAD_RETRY_DELAY} s") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep ${WEBFRONT_DOWNLOAD_RETRY_DELAY}) + endif() + endforeach() + if(NOT present) + message(FATAL_ERROR "${ARG_FAILURE}: ${reason} (${WEBFRONT_DOWNLOAD_ATTEMPTS} attempts)") + endif() + if(NOT target STREQUAL path) + file(CREATE_LINK "${target}" "${path}" COPY_ON_ERROR) + endif() +endfunction() + # Converts a base64 value to lowercase hexadecimal bytes. function(webfront_base64_to_hex value output) set(alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") @@ -86,24 +204,9 @@ function(webfront_provision_bootstrap archive) endif() else() set(path "${ARG_DESTINATION}/${name}") - set(present FALSE) - if(EXISTS "${path}") - file(SHA512 "${path}" actual) - if(actual STREQUAL expected) - set(present TRUE) - endif() - endif() - if(NOT present) - file(MAKE_DIRECTORY "${ARG_DESTINATION}") - file(DOWNLOAD "${ARG_URL}" "${path}" STATUS result TLS_VERIFY ON INACTIVITY_TIMEOUT 60 TIMEOUT 600) - list(GET result 0 code) - if(NOT code EQUAL 0) - file(REMOVE "${path}") - list(GET result 1 reason) - message(FATAL_ERROR "Cannot download the bootstrap environment ${ARG_URL}: ${reason}. " - "Provision it with -DWEBFRONT_BOOTSTRAP_DIR=.") - endif() - endif() + webfront_download_verified("${path}" URL "${ARG_URL}" SHA512 "${expected}" + FAILURE "Cannot download the bootstrap environment ${ARG_URL}. Provision it with -DWEBFRONT_BOOTSTRAP_DIR=" + MISMATCH "Bootstrap environment integrity check failed for ${ARG_URL}: expected ${ARG_INTEGRITY}") endif() file(SHA512 "${path}" actual) if(NOT actual STREQUAL expected) diff --git a/cmake/WebFrontRegistry.cmake b/cmake/WebFrontRegistry.cmake index be76d82c..3b670b89 100644 --- a/cmake/WebFrontRegistry.cmake +++ b/cmake/WebFrontRegistry.cmake @@ -25,6 +25,7 @@ function(webfront_provision_registry output list directory) set(name "${CMAKE_MATCH_1}-${name}") endif() set(path "${directory}/${name}") + # A verified archive already in the build tree is kept: the offline directory need not stay mounted. set(present FALSE) if(EXISTS "${path}") file(SHA512 "${path}" actual) @@ -32,21 +33,17 @@ function(webfront_provision_registry output list directory) set(present TRUE) endif() endif() - if(NOT present) - if(WEBFRONT_REGISTRY_DIR) - if(NOT EXISTS "${WEBFRONT_REGISTRY_DIR}/${name}") - message(FATAL_ERROR "Test registry archive ${WEBFRONT_REGISTRY_DIR}/${name} is missing: WEBFRONT_REGISTRY_DIR must hold it") - endif() - file(COPY_FILE "${WEBFRONT_REGISTRY_DIR}/${name}" "${path}" ONLY_IF_DIFFERENT) - else() - file(DOWNLOAD "${url}" "${path}" STATUS result TLS_VERIFY ON INACTIVITY_TIMEOUT 60 TIMEOUT 600) - list(GET result 0 code) - if(NOT code EQUAL 0) - file(REMOVE "${path}") - list(GET result 1 reason) - message(FATAL_ERROR "Cannot download ${url}: ${reason}. Provision the archives with -DWEBFRONT_REGISTRY_DIR=.") - endif() + if(present) + continue() + elseif(WEBFRONT_REGISTRY_DIR) + if(NOT EXISTS "${WEBFRONT_REGISTRY_DIR}/${name}") + message(FATAL_ERROR "Test registry archive ${WEBFRONT_REGISTRY_DIR}/${name} is missing: WEBFRONT_REGISTRY_DIR must hold it") endif() + file(COPY_FILE "${WEBFRONT_REGISTRY_DIR}/${name}" "${path}" ONLY_IF_DIFFERENT) + else() + webfront_download_verified("${path}" URL "${url}" SHA512 "${expected}" + FAILURE "Cannot download ${url}. Provision the archives with -DWEBFRONT_REGISTRY_DIR=" + MISMATCH "Integrity check failed for ${name}: expected ${integrity}") endif() file(SHA512 "${path}" actual) if(NOT actual STREQUAL expected) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 631e9ec7..61ae6fa6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -30,6 +30,7 @@ these entries stays in the GitHub releases and the Git history. - Run each developer integration part and each wf command of the tests in a process of its own again: the shared windows of #544 and #556 made the driver cases about a third slower on Windows and failed more often. Remove the timing analysis tools and their CI steps, and repeat the desktop suite through one path, with `desktop_passes` on a manual dispatch (#570, `docs/TEST_PERFORMANCE.md`). - Close the test driver's window with `requestClose()` instead of asking the page: a spec that blocks the page now ends with the driver's timeout report instead of a forced exit (#570). - Retire browser tests that repeated others: `LifeEmbeddedBuild` and `LifeEmbeddedIntegration` (the journey compiles and runs the same application from its own generated header), `WfDriverCreateStarter` and `WfDriverTestPasses` (`JourneyCreate` and `JourneyTest`), and `AutomationCliWatchdog`, whose endpoint reuse and Unicode failure checks now follow `AutomationMcpWatchdog` (#570). +- Keep the configure downloads of the tests (bootstrap environment, test registry, jasmine-core) once per machine, in `WEBFRONT_DOWNLOAD_CACHE`, and try a failed download three times: a new build tree links the verified archives instead of downloading them again (#570, `docs/DEVELOPER_ENVIRONMENT.md`). - Declare GCC 13 as the best-effort S2 minimum for the library and examples, document the GCC 14 exit clause and qualified Clang scope, and add GCC 13 ASan/UBSan fast tests (#525, ADR-022). - Skip the cases that configure a CMake project (label `configuration`, about 75 s of worker time) and the coverage capture on a pull request that does not change the build system, and drop the compiler-cache probe step; a push to `develop` and the full tier still run them (#545). diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index b92c558e..66134e5c 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -673,8 +673,12 @@ webfront-wf --project [--environment --integrity /bootstrap/` and verifies the - digest; a wrong digest or an unreachable URL stops the configure. On a machine without network access, pass - `-DWEBFRONT_BOOTSTRAP_DIR=`: the archive is verified the same way. + digest; a wrong digest, or a URL still unreachable after three attempts, stops the configure. The verified downloads are + kept once per machine in `WEBFRONT_DOWNLOAD_CACHE` (the `WEBFRONT_DOWNLOAD_CACHE` environment variable, else + `$CPM_SOURCE_CACHE/webfront-downloads`, else the user's cache directory for WebFront's own build; a consuming project keeps + them in its build tree unless it sets one): a new build tree links them instead of downloading them again. On a machine + without network access, pass `-DWEBFRONT_BOOTSTRAP_DIR=`: the archive is verified the + same way. - `--environment` and `--integrity` run an archive built elsewhere, such as the one built from the current sources (the environment under test of #315). `--registry-dir` serves a local npm registry from the driver's origin and imposes it. `--manifest-dir` keeps the manifest and the lock in that directory of the project (usage error 64 when it is absolute, has an empty or dot component or leaves the project). diff --git a/test/cmake/CheckBootstrapProvisioning.cmake b/test/cmake/CheckBootstrapProvisioning.cmake index 7b107b08..4a639e4f 100644 --- a/test/cmake/CheckBootstrapProvisioning.cmake +++ b/test/cmake/CheckBootstrapProvisioning.cmake @@ -1,4 +1,5 @@ -# Bootstrap provisioning at configure time: SRI conversion, verified download, local directory, integrity failures. +# Bootstrap provisioning at configure time: SRI conversion, verified download, machine download cache, retries, local +# directory, integrity failures. # Usage: cmake -DROOT= -DWORK= -P CheckBootstrapProvisioning.cmake include("${ROOT}/cmake/WebFrontBootstrap.cmake") @@ -35,21 +36,28 @@ file(WRITE "${WORK}/local/environment.tgz" "${content}") file(WRITE "${WORK}/tampered.tgz" "tampered\n") file(WRITE "${WORK}/run.cmake" [[ include("${ROOT}/cmake/WebFrontBootstrap.cmake") +if(NOT DESTINATION) + set(DESTINATION "${WORK}/cache") +endif() if(LOCAL) - webfront_provision_bootstrap(archive URL "${URL}" INTEGRITY "${INTEGRITY}" DESTINATION "${WORK}/cache" LOCAL_DIR "${LOCAL}") + webfront_provision_bootstrap(archive URL "${URL}" INTEGRITY "${INTEGRITY}" DESTINATION "${DESTINATION}" LOCAL_DIR "${LOCAL}") else() - webfront_provision_bootstrap(archive URL "${URL}" INTEGRITY "${INTEGRITY}" DESTINATION "${WORK}/cache") + webfront_provision_bootstrap(archive URL "${URL}" INTEGRITY "${INTEGRITY}" DESTINATION "${DESTINATION}") endif() message(STATUS "provisioned ${archive}") ]]) function(provision name result_var output_var) - cmake_parse_arguments(ARG "" "URL;INTEGRITY;LOCAL" "" ${ARGN}) + cmake_parse_arguments(ARG "" "URL;INTEGRITY;LOCAL;DESTINATION;CACHE" "" ${ARGN}) + # No retry delay, and the machine cache only where a case names one. execute_process(COMMAND "${CMAKE_COMMAND}" -DROOT=${ROOT} -DWORK=${WORK} -DURL=${ARG_URL} -DINTEGRITY=${ARG_INTEGRITY} - -DLOCAL=${ARG_LOCAL} -P "${WORK}/run.cmake" + -DLOCAL=${ARG_LOCAL} -DDESTINATION=${ARG_DESTINATION} -DWEBFRONT_DOWNLOAD_CACHE=${ARG_CACHE} + -DWEBFRONT_DOWNLOAD_RETRY_DELAY=0 -P "${WORK}/run.cmake" RESULT_VARIABLE result OUTPUT_VARIABLE out ERROR_VARIABLE err) set(${result_var} "${result}" PARENT_SCOPE) - set(${output_var} "${out}${err}" PARENT_SCOPE) + # CMake wraps a long message wherever its paths make it long: the checks read it on one line. + string(REGEX REPLACE "[ \t\r\n]+" " " text "${out}${err}") + set(${output_var} "${text}" PARENT_SCOPE) endfunction() # A file URL: a Windows drive letter needs a third slash. @@ -83,12 +91,26 @@ if(EXISTS "${WORK}/cache/environment.tgz") message(FATAL_ERROR "A downloaded archive that fails its integrity check must be removed") endif() -# A download failure names the offline alternative. +# A download failure is tried again, then names the offline alternative. provision(missing result text URL "${scheme}${WORK}/absent/environment.tgz" INTEGRITY "${sri}") -if(result EQUAL 0 OR NOT text MATCHES "WEBFRONT_BOOTSTRAP_DIR") - message(FATAL_ERROR "A failed download must point to WEBFRONT_BOOTSTRAP_DIR: ${result} ${text}") +if(result EQUAL 0 OR NOT text MATCHES "WEBFRONT_BOOTSTRAP_DIR" OR NOT text MATCHES "3 attempts" OR NOT text MATCHES "trying again") + message(FATAL_ERROR "A failed download must be tried again, then point to WEBFRONT_BOOTSTRAP_DIR: ${result} ${text}") endif() +# The machine download cache: a download fills it, and another build tree then gets the archive from it alone. +file(WRITE "${WORK}/source/environment.tgz" "${content}") +set(machine "${WORK}/machine") +string(SUBSTRING "${hex}" 0 32 key) +provision(cacheFill result text URL "${url}" INTEGRITY "${sri}" DESTINATION "${WORK}/tree-a" CACHE "${machine}") +expect_equal("${result}" 0 "A download must fill the machine cache: ${text}") +file(REMOVE "${WORK}/source/environment.tgz") +provision(cacheHit result text URL "${url}" INTEGRITY "${sri}" DESTINATION "${WORK}/tree-b" CACHE "${machine}") +expect_equal("${result}" 0 "A new build tree must be provisioned from the machine cache without the source: ${text}") +foreach(file "${machine}/${key}/environment.tgz" "${WORK}/tree-a/environment.tgz" "${WORK}/tree-b/environment.tgz") + file(SHA512 "${file}" digest) + expect_equal("${digest}" "${hex}" "The cached and provisioned archives must be the verified one (${file})") +endforeach() + # A local provisioning directory replaces the download and is verified too. provision(local result text URL "https://offline.invalid/environment.tgz" INTEGRITY "${sri}" LOCAL "${WORK}/local") expect_equal("${result}" 0 "A local directory must replace the download: ${text}") @@ -103,6 +125,60 @@ if(result EQUAL 0 OR NOT text MATCHES "is missing") message(FATAL_ERROR "An absent local archive must fail the configure: ${result} ${text}") endif() +# A cache that exists but refuses files (a shared, read-only one): a download falls back to the build tree with a warning +# instead of stopping the configure. Only POSIX permissions can make it so, and a process +# that writes through them (root) cannot test it. +if(NOT CMAKE_HOST_WIN32) + file(WRITE "${WORK}/source/environment.tgz" "${content}") + set(readonly "${WORK}/readonly") + file(REMOVE_RECURSE "${readonly}") + file(MAKE_DIRECTORY "${readonly}/${key}") + file(CHMOD "${readonly}" "${readonly}/${key}" DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${readonly}/${key}/probe" RESULT_VARIABLE writable OUTPUT_QUIET ERROR_QUIET) + if(writable EQUAL 0) + file(REMOVE "${readonly}/${key}/probe") + message(STATUS "This process writes into read-only directories: the read-only cache cases are skipped") + else() + provision(readonlyEmpty result text URL "${url}" INTEGRITY "${sri}" DESTINATION "${WORK}/tree-e" CACHE "${readonly}") + expect_equal("${result}" 0 "A read-only cache must not stop the configure: ${text}") + if(NOT text MATCHES "cannot be written") + message(FATAL_ERROR "A read-only cache must be reported: ${text}") + endif() + endif() + file(CHMOD "${readonly}" "${readonly}/${key}" DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) +endif() + +# The test registry keeps the verified archives already in the build tree: its offline directory need not stay mounted. +file(MAKE_DIRECTORY "${WORK}/offline") +file(WRITE "${WORK}/offline/environment.tgz" "${content}") +file(WRITE "${WORK}/packages.json" "{\"packages\": [{\"name\": \"environment\", \"url\": \"https://offline.invalid/environment.tgz\", \"integrity\": \"${sri}\"}]}") +file(WRITE "${WORK}/registry.cmake" [[ +list(APPEND CMAKE_MODULE_PATH "${ROOT}/cmake") +include("${ROOT}/cmake/WebFrontRegistry.cmake") +webfront_provision_registry(directory "${WORK}/packages.json" "${WORK}/registry-tree") +message(STATUS "provisioned ${directory}") +]]) +foreach(round mounted unmounted) + execute_process(COMMAND "${CMAKE_COMMAND}" -DROOT=${ROOT} -DWORK=${WORK} -DWEBFRONT_REGISTRY_DIR=${WORK}/offline + -DWEBFRONT_DOWNLOAD_CACHE= -P "${WORK}/registry.cmake" + RESULT_VARIABLE result OUTPUT_VARIABLE out ERROR_VARIABLE err) + expect_equal("${result}" 0 "The ${round} offline registry directory must provision the build tree: ${out}${err}") + file(REMOVE_RECURSE "${WORK}/offline") +endforeach() + +# An environment variable set to nothing counts as unset: an empty CPM_SOURCE_CACHE gives a consuming project no cache, +# not one at the root. +file(WRITE "${WORK}/default-cache.cmake" [[ +include("${ROOT}/cmake/WebFrontBootstrap.cmake") +message(STATUS "cache=[${WEBFRONT_DOWNLOAD_CACHE}]") +]]) +execute_process(COMMAND "${CMAKE_COMMAND}" -E env --unset=WEBFRONT_DOWNLOAD_CACHE CPM_SOURCE_CACHE= "${CMAKE_COMMAND}" -DROOT=${ROOT} + -P "${WORK}/default-cache.cmake" WORKING_DIRECTORY "${WORK}" OUTPUT_VARIABLE out ERROR_VARIABLE out) +if(NOT out MATCHES "cache=\\[\\]") + message(FATAL_ERROR "An empty CPM_SOURCE_CACHE must not choose a cache: ${out}") +endif() + # A malformed integrity is refused before anything is downloaded. provision(malformed result text URL "${url}" INTEGRITY "sha256-abc") if(result EQUAL 0 OR NOT text MATCHES "sha512- SRI")