|
201 | 201 | [ "$seeded" -eq 2 ] || exit 1 |
202 | 202 | ' _ "$ROOT" |
203 | 203 |
|
204 | | -# Theme switches stage files and publish theme.json last, preserving a complete |
205 | | -# active pack while the watcher is running. |
206 | | -SWITCH_HOME="$TMP/switch-home" |
207 | | -SWITCH_STATE="$SWITCH_HOME/Library/Application Support/CodexDreamSkinStudio" |
208 | | -/bin/mkdir -p "$SWITCH_STATE/themes/preset-switch-fixture" "$SWITCH_STATE/theme" |
209 | | -/bin/cp "$ROOT/assets/portal-hero.png" "$SWITCH_STATE/themes/preset-switch-fixture/background.png" |
210 | | -/usr/bin/printf '%s\n' \ |
211 | | - '{"schemaVersion":1,"id":"preset-switch-fixture","name":"切换测试","image":"background.png"}' \ |
212 | | - > "$SWITCH_STATE/themes/preset-switch-fixture/theme.json" |
213 | | -/usr/bin/printf '%s\n' '{"schemaVersion":1,"id":"old","name":"旧主题","image":"old.png"}' \ |
214 | | - > "$SWITCH_STATE/theme/theme.json" |
215 | | -: > "$SWITCH_STATE/theme/old.png" |
216 | | -if /usr/bin/env HOME="$SWITCH_HOME" NODE="$NODE" \ |
217 | | - "$ROOT/scripts/switch-theme-macos.sh" --id '../escape' --no-apply >/dev/null 2>&1; then |
218 | | - printf 'switch-theme unexpectedly accepted a path traversal theme id.\n' >&2 |
219 | | - exit 1 |
| 204 | +run_signed_runtime_switch_test() { |
| 205 | + local switch_home="$TMP/switch-home" |
| 206 | + local switch_state="$switch_home/Library/Application Support/CodexDreamSkinStudio" |
| 207 | + /bin/mkdir -p "$switch_state/themes/preset-switch-fixture" "$switch_state/theme" |
| 208 | + /bin/cp "$ROOT/assets/portal-hero.png" "$switch_state/themes/preset-switch-fixture/background.png" |
| 209 | + /usr/bin/printf '%s\n' \ |
| 210 | + '{"schemaVersion":1,"id":"preset-switch-fixture","name":"切换测试","image":"background.png"}' \ |
| 211 | + > "$switch_state/themes/preset-switch-fixture/theme.json" |
| 212 | + /usr/bin/printf '%s\n' '{"schemaVersion":1,"id":"old","name":"旧主题","image":"old.png"}' \ |
| 213 | + > "$switch_state/theme/theme.json" |
| 214 | + : > "$switch_state/theme/old.png" |
| 215 | + if /usr/bin/env HOME="$switch_home" NODE="$NODE" \ |
| 216 | + "$ROOT/scripts/switch-theme-macos.sh" --id '../escape' --no-apply >/dev/null 2>&1; then |
| 217 | + printf 'switch-theme unexpectedly accepted a path traversal theme id.\n' >&2 |
| 218 | + exit 1 |
| 219 | + fi |
| 220 | + /usr/bin/env HOME="$switch_home" NODE="$NODE" \ |
| 221 | + "$ROOT/scripts/switch-theme-macos.sh" --id preset-switch-fixture --no-apply >/dev/null |
| 222 | + /usr/bin/cmp -s "$switch_state/theme/background.png" \ |
| 223 | + "$switch_state/themes/preset-switch-fixture/background.png" |
| 224 | + [ ! -e "$switch_state/theme/old.png" ] |
| 225 | + "$NODE" -e ' |
| 226 | + const fs = require("fs"); |
| 227 | + const theme = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); |
| 228 | + if (theme.id !== "preset-switch-fixture" || theme.name !== "切换测试") process.exit(1); |
| 229 | + ' "$switch_state/theme/theme.json" |
| 230 | + [ -z "$(/usr/bin/find "$switch_state" -maxdepth 1 -name '.theme-switch.*' -print -quit)" ] |
| 231 | +} |
| 232 | + |
| 233 | +if [ "${CODEX_DREAM_SKIN_SKIP_SIGNED_RUNTIME_TESTS:-0}" = "1" ]; then |
| 234 | + printf 'SKIP: switch-theme integration requires an installed, signed Codex app.\n' |
| 235 | + SWITCH_RUNTIME_RESULT="skipped" |
| 236 | +else |
| 237 | + run_signed_runtime_switch_test |
| 238 | + SWITCH_RUNTIME_RESULT="passed" |
220 | 239 | fi |
221 | | -/usr/bin/env HOME="$SWITCH_HOME" NODE="$NODE" \ |
222 | | - "$ROOT/scripts/switch-theme-macos.sh" --id preset-switch-fixture --no-apply >/dev/null |
223 | | -/usr/bin/cmp -s "$SWITCH_STATE/theme/background.png" \ |
224 | | - "$SWITCH_STATE/themes/preset-switch-fixture/background.png" |
225 | | -[ ! -e "$SWITCH_STATE/theme/old.png" ] |
226 | | -"$NODE" -e ' |
227 | | - const fs = require("fs"); |
228 | | - const theme = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); |
229 | | - if (theme.id !== "preset-switch-fixture" || theme.name !== "切换测试") process.exit(1); |
230 | | -' "$SWITCH_STATE/theme/theme.json" |
231 | | -[ -z "$(/usr/bin/find "$SWITCH_STATE" -maxdepth 1 -name '.theme-switch.*' -print -quit)" ] |
232 | 240 |
|
233 | 241 | RUNTIME_HOME="$TMP/runtime-home" |
234 | 242 | RUNTIME_STATE_ROOT="$RUNTIME_HOME/Library/Application Support/CodexDreamSkinStudio" |
@@ -296,6 +304,7 @@ UNTRUSTED_TEAM_ID="TEAM'ID" |
296 | 304 | if pid_is_codex_executable "$$" || pid_is_codex_descendant "$$"; then exit 1; fi |
297 | 305 | ' _ "$ROOT" |
298 | 306 |
|
| 307 | +run_signed_runtime_state_tests() { |
299 | 308 | # A reused live PID must never be killed or treated as a successfully stopped |
300 | 309 | # injector when its command identity does not match the recorded watcher. |
301 | 310 | STOP_HOME="$TMP/stop-home" |
@@ -488,6 +497,15 @@ for state_payload in '{' '{}'; do |
488 | 497 | ' _ "$ROOT" "$TEST_INJECTOR_JOB_LABEL" |
489 | 498 | /usr/bin/cmp -s "$STOP_STATE_ROOT/state.json" "$STOP_STATE_ROOT/state.original" |
490 | 499 | done |
| 500 | +} |
| 501 | + |
| 502 | +if [ "${CODEX_DREAM_SKIN_SKIP_SIGNED_RUNTIME_TESTS:-0}" = "1" ]; then |
| 503 | + printf 'SKIP: runtime-state integration requires an installed, signed Codex app.\n' |
| 504 | + RUNTIME_STATE_RESULT="skipped" |
| 505 | +else |
| 506 | + run_signed_runtime_state_tests |
| 507 | + RUNTIME_STATE_RESULT="passed" |
| 508 | +fi |
491 | 509 |
|
492 | 510 | /bin/mkdir -p "$TMP/theme" |
493 | 511 | /bin/cp "$ROOT/assets/portal-hero.png" "$TMP/theme/background.png" |
@@ -821,6 +839,14 @@ CRLF_BACKUP="$TMP/config-crlf-backup.json" |
821 | 839 | "$NODE" "$ROOT/scripts/theme-config.mjs" restore "$CRLF_CONFIG" "$CRLF_BACKUP" >/dev/null |
822 | 840 | /usr/bin/cmp -s "$CRLF_CONFIG" "$TMP/original-crlf.toml" |
823 | 841 |
|
824 | | -/usr/bin/env -u HOME /bin/bash -c '. "$1/scripts/common-macos.sh"; [ -n "$HOME" ] && [ "$SKIN_VERSION" = "$(/bin/cat "$ROOT/VERSION" 2>/dev/null | /usr/bin/tr -d '\''\n\r'\'')" ]' _ "$ROOT""$ROOT/scripts/doctor-macos.sh" >/dev/null |
| 842 | +/usr/bin/env -u HOME /bin/bash -c '. "$1/scripts/common-macos.sh"; [ -n "$HOME" ] && [ "$SKIN_VERSION" = "$(/bin/cat "$ROOT/VERSION" 2>/dev/null | /usr/bin/tr -d '\''\n\r'\'')" ]' _ "$ROOT" |
| 843 | +if [ "${CODEX_DREAM_SKIN_SKIP_DOCTOR:-0}" = "1" ]; then |
| 844 | + printf 'SKIP: Doctor requires an installed, signed Codex app.\n' |
| 845 | + DOCTOR_RESULT="skipped" |
| 846 | +else |
| 847 | + "$ROOT/scripts/doctor-macos.sh" >/dev/null |
| 848 | + DOCTOR_RESULT="passed" |
| 849 | +fi |
825 | 850 |
|
826 | | -printf 'PASS: syntax, payload, bundled presets, preset seeding, runtime-state safety, custom-theme, config round-trips, HOME recovery, signature, and doctor checks.\n' |
| 851 | +printf 'PASS: syntax, payload, bundled presets, preset seeding, runtime-state safety, custom-theme, config round-trips, HOME recovery, signature, switch-theme signed runtime %s, runtime-state integration %s, and Doctor %s.\n' \ |
| 852 | + "$SWITCH_RUNTIME_RESULT" "$RUNTIME_STATE_RESULT" "$DOCTOR_RESULT" |
0 commit comments