test-build-modes.sh (23502B)
1 #!/bin/sh 2 set -eu 3 4 repository_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) 5 make_command=$(command -v make) 6 gradle_command=${GRADLE:-./gradlew} 7 fixture=$(mktemp -d "${TMPDIR:-/tmp}/harvestcircle-build-mode.XXXXXX") 8 cleanup() { 9 find "$fixture" -depth -delete 10 } 11 trap cleanup EXIT HUP INT TERM 12 13 printf '%s\n' '#!/bin/sh' 'if [ "${1:-}" = +1.99.0 ]; then shift; fi' 'if [ "${1:-}" = extbuild ]; then printf "%s\n" "cargo-extbuild unavailable" >&2; else printf "%s\n" "cargo must not be invoked in standalone dry-run" >&2; fi' 'exit 93' > "$fixture/cargo" 14 chmod +x "$fixture/cargo" 15 16 standalone_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE=standalone -C "$repository_root" check) 17 if printf '%s\n' "$standalone_output" | grep -q 'cargo extbuild'; then 18 printf '%s\n' 'standalone mode attempted to invoke extbuild' >&2 19 exit 1 20 fi 21 22 for lane in source-check integration-check development-check; do 23 for mode in standalone governed; do 24 lane_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE="$mode" -C "$repository_root" "$lane") 25 build_logic_count=$(printf '%s\n' "$lane_output" | grep -c -- '-p build-logic') 26 if [ "$build_logic_count" -ne 1 ]; then 27 printf '%s\n' "$lane in $mode mode must invoke build-logic verification exactly once" >&2 28 exit 1 29 fi 30 done 31 done 32 33 development_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE=standalone -C "$repository_root" development-check) 34 for forbidden in \ 35 'cargo audit' \ 36 'dependencyCheckAnalyze' \ 37 'verifyHostPackage' \ 38 'releaseReadiness' \ 39 'unsignedReleaseReadiness' \ 40 'signingReadiness' \ 41 'notarizationReadiness' \ 42 'packageDmg' \ 43 'packageDeb' 44 do 45 if printf '%s\n' "$development_output" | grep -q "$forbidden"; then 46 printf '%s\n' "development verification activated deferred integration: $forbidden" >&2 47 exit 1 48 fi 49 done 50 51 for mode in standalone governed; do 52 stability_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE="$mode" -C "$repository_root" build-logic-stability-check) 53 stability_count=$(printf '%s\n' "$stability_output" | grep -c 'test-build-logic-stability.sh') 54 if [ "$stability_count" -ne 1 ]; then 55 printf '%s\n' "build-logic stability in $mode mode must invoke its qualification tool exactly once" >&2 56 exit 1 57 fi 58 59 source_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE="$mode" -C "$repository_root" source-check) 60 if printf '%s\n' "$source_output" | grep -q 'test-build-logic-stability.sh'; then 61 printf '%s\n' "ordinary source-check in $mode mode invoked the nondefault stability lane" >&2 62 exit 1 63 fi 64 65 dev_check_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE="$mode" -C "$repository_root" dev-check) 66 dev_check_count=$(printf '%s\n' "$dev_check_output" | grep -c -- '--configuration-cache --configuration-cache-problems=fail :app:desktop:hotRunArgfile') 67 if [ "$dev_check_count" -ne 1 ]; then 68 printf '%s\n' "development readiness in $mode mode must verify the finite hot-reload argfile exactly once" >&2 69 exit 1 70 fi 71 72 source_dev_check_count=$(printf '%s\n' "$source_output" | grep -c -- '--configuration-cache --configuration-cache-problems=fail :app:desktop:hotRunArgfile') 73 if [ "$source_dev_check_count" -ne 1 ]; then 74 printf '%s\n' "ordinary source-check in $mode mode must include development readiness exactly once" >&2 75 exit 1 76 fi 77 done 78 79 dev_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE=standalone -C "$repository_root" dev) 80 if ! printf '%s\n' "$dev_output" | grep -q ':app:desktop:hotRun'; then 81 printf '%s\n' 'development command must invoke Compose hot reload' >&2 82 exit 1 83 fi 84 if printf '%s\n' "$dev_output" | grep -q -- '--no-configuration-cache'; then 85 printf '%s\n' 'development command disabled the qualified configuration cache' >&2 86 exit 1 87 fi 88 89 for mode in standalone governed; do 90 clean_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE="$mode" -C "$repository_root" clean) 91 build_runner_prefix= 92 if [ "$mode" = governed ]; then 93 build_runner_prefix='cargo extbuild run -- ' 94 fi 95 root_clean_count=$(printf '%s\n' "$clean_output" | grep -Fxc -- "${build_runner_prefix}${gradle_command} --no-daemon clean" || true) 96 included_clean_count=$(printf '%s\n' "$clean_output" | grep -Fxc -- "${build_runner_prefix}${gradle_command} --no-daemon -p build-logic clean" || true) 97 if [ "$root_clean_count" -ne 1 ] || [ "$included_clean_count" -ne 1 ]; then 98 printf '%s\n' "clean in $mode mode must clean the root and included builds exactly once" >&2 99 exit 1 100 fi 101 done 102 103 if "$make_command" --no-print-directory -C "$repository_root" BUILD_MODE=unsupported help > "$fixture/unknown.log" 2>&1; then 104 printf '%s\n' 'unknown build mode was accepted' >&2 105 exit 1 106 fi 107 grep -q "Unknown BUILD_MODE 'unsupported'" "$fixture/unknown.log" 108 109 if PATH="$fixture:$PATH" "$make_command" --no-print-directory -C "$repository_root" governed-doctor > "$fixture/governed.log" 2>&1; then 110 printf '%s\n' 'governed mode succeeded without extbuild' >&2 111 exit 1 112 fi 113 grep -q 'cargo-extbuild unavailable' "$fixture/governed.log" 114 115 if "$make_command" --no-print-directory -C "$repository_root" BUILD_MODE=standalone _release-check > "$fixture/release.log" 2>&1; then 116 printf '%s\n' 'release execution accepted standalone mode' >&2 117 exit 1 118 fi 119 grep -q 'release-check requires governed mode' "$fixture/release.log" 120 121 if "$make_command" --no-print-directory -C "$repository_root" BUILD_MODE=standalone _unsigned-release-check > "$fixture/unsigned-release.log" 2>&1; then 122 printf '%s\n' 'unsigned release execution accepted standalone mode' >&2 123 exit 1 124 fi 125 grep -q 'unsigned-release-check requires governed mode' "$fixture/unsigned-release.log" 126 127 unsigned_release_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE=governed -C "$repository_root" _unsigned-release-check) 128 if ! printf '%s\n' "$unsigned_release_output" | grep -q ':app:desktop:unsignedReleaseReadiness'; then 129 printf '%s\n' 'unsigned release command did not select the unsigned readiness gate' >&2 130 exit 1 131 fi 132 for forbidden in 'cargo audit' 'advisories' ':app:desktop:dependencyCheckAnalyze' ':app:desktop:releaseReadiness' ':app:desktop:signingReadiness' ':app:desktop:notarizationReadiness'; do 133 if printf '%s\n' "$unsigned_release_output" | grep -q "$forbidden"; then 134 printf '%s\n' "unsigned release command activated out-of-scope authority: $forbidden" >&2 135 exit 1 136 fi 137 done 138 139 standalone_package_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE=standalone -C "$repository_root" package-check) 140 standalone_unsigned_gate_count=$(printf '%s\n' "$standalone_package_output" | grep -Fxc -- "$gradle_command --no-daemon --no-parallel --no-configuration-cache :app:desktop:unsignedReleaseReadiness" || true) 141 if [ "$standalone_unsigned_gate_count" -ne 1 ] || printf '%s\n' "$standalone_package_output" | grep -q 'cargo extbuild'; then 142 printf '%s\n' 'standalone package-check must invoke the unsigned gate once without probing extbuild' >&2 143 exit 1 144 fi 145 146 governed_package_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE=standalone -C "$repository_root" governed-package-check) 147 governed_unsigned_gate_count=$(printf '%s\n' "$governed_package_output" | grep -Fxc -- "cargo extbuild run -- $gradle_command --no-daemon --no-parallel --no-configuration-cache :app:desktop:unsignedReleaseReadiness" || true) 148 if [ "$governed_unsigned_gate_count" -ne 1 ]; then 149 printf '%s\n' 'governed-package-check must invoke the extbuild-routed unsigned gate exactly once' >&2 150 exit 1 151 fi 152 153 # Run the real Make graph with only controlled native tools. The disposable 154 # dispatcher fixture deliberately has spaces, no ambient tool PATH, and finite 155 # stand-ins for hotRun, package checks, and the mode-check script itself. 156 dispatch_root="$(CDPATH= cd -- "$fixture" && pwd -P)/checkout with spaces" 157 dispatch_bin="$fixture/native tools" 158 mkdir -p "$dispatch_root/tools" "$dispatch_bin" 159 cp "$repository_root/Makefile" "$dispatch_root/Makefile" 160 cp "$repository_root/radroots.lib.source-lock.v1.toml" "$dispatch_root/" 161 ln -s "$(command -v sed)" "$dispatch_bin/sed" 162 cat > "$dispatch_bin/git" <<'EOF' 163 #!/bin/sh 164 case "$1" in 165 rev-parse) printf '%040d\n' 1 ;; 166 status) : ;; 167 show) printf '%s\n' 1 ;; 168 *) exit 92 ;; 169 esac 170 EOF 171 chmod +x "$dispatch_bin/git" 172 cat > "$fixture/dispatch-tool" <<'EOF' 173 #!/bin/sh 174 tool=${0##*/} 175 printf '%s\t%s\t%s\t%s\t%s\t%s\t%s' "$tool" "$PWD" "${HCR_TEST_ROUTED:-no}" "${HARVESTCIRCLE_BUILD_SOURCE_COMMIT:-}" "${HARVESTCIRCLE_BUILD_SOURCE_DIRTY:-}" "${HARVESTCIRCLE_BUILD_RADROOTS_REVISION:-}" "${SOURCE_DATE_EPOCH:-}" >> "$HCR_TEST_LOG" 176 printf '\t%s' "$@" >> "$HCR_TEST_LOG" 177 printf '\n' >> "$HCR_TEST_LOG" 178 if [ "$tool" = "${HCR_TEST_FAIL_TOOL:-}" ]; then 179 case " $* " in 180 *" ${HCR_TEST_FAIL_ARGUMENT:-} "*) exit 91 ;; 181 esac 182 fi 183 case "$tool" in 184 node|corepack) 185 [ "${HCR_TEST_RUNTIME:-native}" = web ] || exit 94 186 ;; 187 java|gradlew) 188 [ "${HCR_TEST_RUNTIME:-native}" = native ] || exit 94 189 ;; 190 npm|pnpm|npx) exit 94 ;; 191 cargo) 192 if [ "${1:-}" = +1.99.0 ]; then shift; fi 193 if [ "${1:-}" = extbuild ]; then 194 case "${2:-}" in 195 doctor) exit 0 ;; 196 run) 197 [ "${3:-}" = -- ] || exit 92 198 shift 3 199 export HCR_TEST_ROUTED=yes 200 exec "$@" 201 ;; 202 *) exit 92 ;; 203 esac 204 fi 205 [ "${HCR_TEST_RUNTIME:-native}" = native ] || exit 94 206 ;; 207 esac 208 # These are disposable build-output stand-ins, never primary build caches. 209 if [ "${HCR_TEST_CLEAN:-no}" = yes ]; then 210 [ "$PWD" = "$HCR_TEST_CHECKOUT" ] || exit 92 211 case "$tool:$*" in 212 'cargo:clean --manifest-path core/Cargo.toml') rm -rf core/target ;; 213 'cargo:clean --manifest-path tools/xtask/Cargo.toml') rm -rf tools/xtask/target ;; 214 'gradlew:--no-daemon clean') rm -rf build app/shared/build app/desktop/build ;; 215 'gradlew:--no-daemon -p build-logic clean') rm -rf build-logic/build ;; 216 esac 217 fi 218 EOF 219 for tool in cargo java node npm pnpm npx corepack; do 220 cp "$fixture/dispatch-tool" "$dispatch_bin/$tool" 221 chmod +x "$dispatch_bin/$tool" 222 done 223 cp "$fixture/dispatch-tool" "$dispatch_root/gradlew" 224 chmod +x "$dispatch_root/gradlew" 225 for tool in test-build-modes.sh verify-storage-api.sh; do 226 cp "$fixture/dispatch-tool" "$dispatch_root/tools/$tool" 227 chmod +x "$dispatch_root/tools/$tool" 228 done 229 230 run_dispatch() { 231 dispatch_mode=$1 232 dispatch_target=$2 233 dispatch_log=$3 234 : > "$dispatch_log" 235 # Start outside the checkout: Make must establish the recipe cwd with -C. 236 (cd "$fixture" && PATH="$dispatch_bin" MAKEFLAGS= MFLAGS= HCR_TEST_LOG="$dispatch_log" HCR_TEST_ROUTED=no \ 237 "$make_command" --no-print-directory -C "$dispatch_root" BUILD_MODE="$dispatch_mode" GRADLE=./gradlew "$dispatch_target") 238 } 239 240 for mode in standalone governed; do 241 default_output=$("$make_command" --no-print-directory -C "$dispatch_root" BUILD_MODE="$mode") 242 help_output=$("$make_command" --no-print-directory -C "$dispatch_root" BUILD_MODE="$mode" help) 243 if [ "$default_output" != "$help_output" ]; then 244 printf '%s\n' "default goal changed from help in $mode mode" >&2 245 exit 1 246 fi 247 for target in doctor dev check build package-check; do 248 alias="native-$target" 249 original_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE="$mode" -C "$repository_root" "$target") 250 alias_output=$(PATH="$fixture:$PATH" "$make_command" --no-print-directory -n BUILD_MODE="$mode" -C "$repository_root" "$alias") 251 if [ "$original_output" != "$alias_output" ]; then 252 printf '%s\n' "$alias changed or duplicated the $target command graph in $mode mode" >&2 253 exit 1 254 fi 255 run_dispatch "$mode" "$target" "$fixture/original-dispatch.log" > "$fixture/original-output.log" 2>&1 256 run_dispatch "$mode" "$alias" "$fixture/alias-dispatch.log" > "$fixture/alias-output.log" 2>&1 257 if ! cmp -s "$fixture/original-dispatch.log" "$fixture/alias-dispatch.log" || \ 258 ! cmp -s "$fixture/original-output.log" "$fixture/alias-output.log"; then 259 printf '%s\n' "$alias changed controlled execution of $target in $mode mode" >&2 260 exit 1 261 fi 262 if [ ! -s "$fixture/alias-dispatch.log" ] || \ 263 grep -Eq '^(node|npm|pnpm|npx|corepack)[[:space:]]' "$fixture/alias-dispatch.log"; then 264 printf '%s\n' "$alias did not execute native tools exclusively in $mode mode" >&2 265 exit 1 266 fi 267 if [ "$(grep -c '^java[[:space:]]' "$fixture/alias-dispatch.log")" -ne 1 ]; then 268 printf '%s\n' "$alias must execute its doctor once in $mode mode" >&2 269 exit 1 270 fi 271 while IFS="$(printf '\t')" read -r tool cwd details; do 272 if [ "$cwd" != "$dispatch_root" ]; then 273 printf '%s\n' "$alias invoked $tool outside the checkout in $mode mode" >&2 274 exit 1 275 fi 276 done < "$fixture/alias-dispatch.log" 277 for missing in java cargo gradlew; do 278 missing_path="$dispatch_bin/$missing" 279 if [ "$missing" = gradlew ]; then missing_path="$dispatch_root/gradlew"; fi 280 mv "$missing_path" "$fixture/missing-tool" 281 if run_dispatch "$mode" "$alias" "$fixture/missing-dispatch.log" > "$fixture/missing-output.log" 2>&1; then 282 printf '%s\n' "$alias succeeded without $missing in $mode mode" >&2 283 exit 1 284 fi 285 mv "$fixture/missing-tool" "$missing_path" 286 grep -Eq '(not found|No such file)' "$fixture/missing-output.log" 287 done 288 if [ "$mode" = governed ]; then 289 mv "$dispatch_bin/cargo" "$fixture/available-cargo" 290 cp "$fixture/cargo" "$dispatch_bin/cargo" 291 if run_dispatch "$mode" "$alias" "$fixture/missing-dispatch.log" > "$fixture/missing-output.log" 2>&1; then 292 printf '%s\n' "$alias succeeded without extbuild" >&2 293 exit 1 294 fi 295 grep -q 'cargo-extbuild unavailable' "$fixture/missing-output.log" 296 mv "$fixture/available-cargo" "$dispatch_bin/cargo" 297 fi 298 printf '%s\n' "harvestcircle.native-alias.$mode.$alias=dry-run,execution,cwd,no-node,missing-tools:pass" 299 done 300 done 301 302 # Execute browser recipes with only their own tools available. The governed 303 # variant also needs the explicit extbuild router; it must not invoke native 304 # Cargo, Java or Gradle. These stand-ins qualify command boundaries only. 305 web_bin="$fixture/web tools" 306 mkdir -p "$web_bin" "$dispatch_root/web" 307 for tool in node corepack; do 308 cp "$fixture/dispatch-tool" "$web_bin/$tool" 309 chmod +x "$web_bin/$tool" 310 done 311 run_web_dispatch() { 312 if [ "$mode" = standalone ]; then 313 rm -f "$web_bin/cargo" 314 else 315 cp "$dispatch_bin/cargo" "$web_bin/cargo" 316 fi 317 : > "$fixture/web-dispatch.log" 318 (cd "$fixture" && PATH="$web_bin" MAKEFLAGS= MFLAGS= \ 319 HCR_TEST_LOG="$fixture/web-dispatch.log" HCR_TEST_ROUTED=no HCR_TEST_RUNTIME=web \ 320 HARVESTCIRCLE_BUILD_SOURCE_COMMIT="$web_source_commit" \ 321 HARVESTCIRCLE_BUILD_SOURCE_DIRTY="$web_source_dirty" \ 322 HARVESTCIRCLE_BUILD_RADROOTS_REVISION="$web_source_revision" SOURCE_DATE_EPOCH="$web_source_epoch" \ 323 "$make_command" --no-print-directory -C "$dispatch_root" BUILD_MODE="$mode" "$target") 324 } 325 for metadata in empty populated; do 326 web_source_commit= 327 web_source_dirty= 328 web_source_revision= 329 web_source_epoch= 330 if [ "$metadata" = populated ]; then 331 web_source_commit=1111111111111111111111111111111111111111 332 web_source_dirty=true 333 web_source_revision=2222222222222222222222222222222222222222 334 web_source_epoch=1234567890 335 fi 336 for mode in standalone governed; do 337 for target in web-doctor web-install web-dev web-check web-build; do 338 run_web_dispatch > "$fixture/web-output.log" 2>&1 339 # Tabs delimit seven metadata fields before argv. Shell read collapses 340 # empty IFS whitespace fields; awk preserves their positional identity. 341 awk -F '\t' -v root="$dispatch_root" -v mode="$mode" \ 342 -v commit="$web_source_commit" -v dirty="$web_source_dirty" \ 343 -v revision="$web_source_revision" -v epoch="$web_source_epoch" ' 344 ("@" $4) != ("@" commit) || ("@" $5) != ("@" dirty) || ("@" $6) != ("@" revision) || ("@" $7) != ("@" epoch) { 345 print "web dispatch changed source provenance"; exit 1 346 } 347 $1 == "cargo" { 348 if (mode == "governed" && $3 == "no") { 349 if ($2 == root && $8 == "+1.99.0" && $9 == "extbuild" && $10 == "doctor" && NF == 10) next 350 if ($2 == root "/web" && $8 == "extbuild" && $9 == "run" && $10 == "--" && ($11 == "node" || $11 == "corepack")) next 351 } 352 print "web dispatch invoked unexpected Cargo argv or routing"; exit 1 353 } 354 $1 == "node" || $1 == "corepack" { 355 if ($2 == root "/web" && $3 == (mode == "governed" ? "yes" : "no")) next 356 print "web dispatch changed checkout cwd or routing"; exit 1 357 } 358 { print "web dispatch invoked unexpected tool " $1; exit 1 } 359 ' "$fixture/web-dispatch.log" 360 # Compare the actual ordered package invocations, including frozen 361 # installation and all four ordinary web-check constituents. 362 awk -F '\t' '$1 == "corepack" { for (i = 8; i <= NF; i++) printf "%s%s", $i, (i == NF ? "\n" : " ") }' "$fixture/web-dispatch.log" > "$fixture/web-actual.log" 363 case "$target" in 364 web-doctor) : > "$fixture/web-expected.log" ;; 365 web-install) printf '%s\n' 'pnpm install --frozen-lockfile' > "$fixture/web-expected.log" ;; 366 web-dev) printf '%s\n' 'pnpm run dev' > "$fixture/web-expected.log" ;; 367 web-build) printf '%s\n' 'pnpm run build' > "$fixture/web-expected.log" ;; 368 web-check) printf '%s\n' 'pnpm run check' 'pnpm run lint' 'pnpm run test:unit' 'pnpm run test:conformance' > "$fixture/web-expected.log" ;; 369 esac 370 cmp "$fixture/web-expected.log" "$fixture/web-actual.log" 371 [ "$(grep -c '^node[[:space:]]' "$fixture/web-dispatch.log")" -eq 1 ] 372 for missing in node corepack; do 373 if [ "$missing" = corepack ] && [ "$target" = web-doctor ]; then continue; fi 374 mv "$web_bin/$missing" "$fixture/missing-web-tool" 375 if run_web_dispatch > "$fixture/web-missing.log" 2>&1; then 376 printf '%s\n' "$target accepted missing $missing in $mode mode" >&2 377 exit 1 378 fi 379 mv "$fixture/missing-web-tool" "$web_bin/$missing" 380 grep -Eq '(not found|No such file)' "$fixture/web-missing.log" 381 done 382 printf '%s\n' "harvestcircle.web-dispatch.$mode.$target.$metadata=cwd,provenance,ordered-dispatch,tool-isolation,missing-tools:pass" 383 done 384 done 385 done 386 387 # Fail each selected command rather than silently accepting a partial graph. 388 for mode in standalone governed; do 389 for target in dev check build clean; do 390 if HCR_TEST_FAIL_TOOL=gradlew HCR_TEST_FAIL_ARGUMENT=--version \ 391 run_dispatch "$mode" "$target" "$fixture/native-failure.log" > "$fixture/native-failure-output.log" 2>&1; then 392 printf '%s\n' "$target ignored native doctor failure" >&2; exit 1 393 fi 394 grep -q 'Error 91' "$fixture/native-failure-output.log" 395 [ "$(grep -c '^gradlew[[:space:]]' "$fixture/native-failure.log")" -eq 1 ] 396 failure_tool=cargo 397 failure_argument=$target 398 case "$target" in 399 dev) failure_tool=gradlew; failure_argument=:app:desktop:hotRun ;; 400 check) failure_argument=fmt ;; 401 esac 402 if HCR_TEST_FAIL_TOOL="$failure_tool" HCR_TEST_FAIL_ARGUMENT="$failure_argument" \ 403 run_dispatch "$mode" "$target" "$fixture/native-failure.log" > "$fixture/native-failure-output.log" 2>&1; then 404 printf '%s\n' "$target ignored failed $failure_argument" >&2; exit 1 405 fi 406 grep -q 'Error 91' "$fixture/native-failure-output.log" 407 tail -n 1 "$fixture/native-failure.log" | grep -q "$(printf '\t')$failure_argument\($(printf '\t')\|\$\)" 408 done 409 for argument in install dev check lint test:unit test:conformance build; do 410 target=web-check 411 case "$argument" in install) target=web-install ;; dev) target=web-dev ;; build) target=web-build ;; esac 412 if HCR_TEST_FAIL_TOOL=corepack HCR_TEST_FAIL_ARGUMENT="$argument" \ 413 run_web_dispatch > "$fixture/web-failure-output.log" 2>&1; then 414 printf '%s\n' "$target ignored failed $argument" >&2; exit 1 415 fi 416 grep -q 'Error 91' "$fixture/web-failure-output.log" 417 tail -n 1 "$fixture/web-dispatch.log" | grep -q "$(printf '\t')$argument\($(printf '\t')\|\$\)" 418 done 419 printf '%s\n' "harvestcircle.dispatch-failure.$mode=native-doctor,native-command,web-command,stop-on-failure:pass" 420 done 421 422 # Clean executes only in the owned fixture. Preserve browser caches/state, 423 # dirty unrelated source, sibling source and desktop user-state sentinels. 424 ln -s "$(command -v rm)" "$dispatch_bin/rm" 425 for mode in standalone governed; do 426 for path in core/target tools/xtask/target build app/shared/build app/desktop/build build-logic/build; do 427 mkdir -p "$dispatch_root/$path" 428 printf '%s\n' disposable > "$dispatch_root/$path/output" 429 done 430 for path in web/node_modules web/build web/.svelte-kit web/local-state unrelated-source; do 431 mkdir -p "$dispatch_root/$path" 432 printf '%s\n' "preserve:$path" > "$dispatch_root/$path/sentinel" 433 done 434 for path in 'sibling checkout' 'desktop user state'; do 435 mkdir -p "$fixture/$path" 436 printf '%s\n' "preserve:$path" > "$fixture/$path/sentinel" 437 done 438 HCR_TEST_CLEAN=yes HCR_TEST_CHECKOUT="$dispatch_root" \ 439 run_dispatch "$mode" clean "$fixture/clean-dispatch.log" > "$fixture/clean-output.log" 2>&1 440 clean_count=$(awk -F '\t' '($1 == "cargo" && $9 == "clean") || ($1 == "gradlew" && ($9 == "clean" || $11 == "clean")) { n++ } END { print n+0 }' "$fixture/clean-dispatch.log") 441 [ "$clean_count" -eq 4 ] 442 for path in core/target tools/xtask/target build app/shared/build app/desktop/build build-logic/build; do 443 [ ! -e "$dispatch_root/$path" ] || exit 1 444 done 445 for path in web/node_modules web/build web/.svelte-kit web/local-state unrelated-source; do 446 [ "$(cat "$dispatch_root/$path/sentinel")" = "preserve:$path" ] || exit 1 447 done 448 for path in 'sibling checkout' 'desktop user state'; do 449 [ "$(cat "$fixture/$path/sentinel")" = "preserve:$path" ] || exit 1 450 done 451 printf '%s\n' "harvestcircle.clean.$mode=owned-output-removal,sentinel-preservation:pass" 452 done 453 454 printf '%s\n' 'harvestcircle.native-alias-contract=pass' 455 printf '%s\n' 'harvestcircle.build-mode-contract=pass'