From c6ee0a62b8e6ebbab9b3016abb32505119405e7f Mon Sep 17 00:00:00 2001 From: okash1n <48118431+okash1n@users.noreply.github.com> Date: Tue, 8 Sep 2026 14:00:43 +0900 Subject: [PATCH] =?UTF-8?q?test:=20if-=E3=82=B5=E3=83=96=E3=82=B7=E3=82=A7?= =?UTF-8?q?=E3=83=AB=E6=9D=A1=E4=BB=B6=E5=86=85=E3=81=A7=E7=84=A1=E5=8A=B9?= =?UTF-8?q?=E5=8C=96=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=9F=E4=B8=AD?= =?UTF-8?q?=E9=96=93=E3=82=A2=E3=82=B5=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=92=E6=8B=98=E6=9D=9F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bash は if の条件として実行される ( ... ) サブシェルとその内部の set -e に 対して errexit を無視し、( ... ) || rc=$? も同じ扱いになる。最後のコマンド の終了コードしか判定に使われないため、途中の [[ ]] や関数呼び出しの失敗は 無視されていた(#170 で test-native-file-tools.sh の 3 ブロックを修正済み)。 tests/unit/*.sh の該当ブロックを全数監査し、実際に非拘束だった 12 文に house style の `|| exit 1` を付けた。 - test-deploy-refactor.sh (2): build_settings_file の終了コードが捨てられ、 MDM 側は最終判定が `! jq -e` なのでビルド失敗でも空振りで pass していた - test-ghostty.sh (5): 否定テストの fixture 生成(_ghostty_test_make_app、 ln -s)と deploy_ghostty_config の終了コード。fixture が作れなくても 「拒否された」扱いで pass していた - test-mdm-install.sh (5): launcher の quiescence / quick-exit ケースは 最後のコマンドが trap - EXIT や while で _rc が常に 0 になり、PGID と group 状態のアサーションが死んでいた 他の 5 ファイル(fonts / prerequisites / update-refactor / setup-refactor / mdm-detect)は既に拘束済みで変更なし。各修正はアサーションを反転させる mutation check で FAIL に転じることを確認した。MDM ファイルは CI の run-mdm-tests.sh が実行時検証。 Claude-Session: https://claude.ai/code/session_01C9mrbbXQgV9fJ8Zy5UoEYc --- tests/unit/test-deploy-refactor.sh | 4 ++-- tests/unit/test-ghostty.sh | 10 +++++----- tests/unit/test-mdm-install.sh | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/unit/test-deploy-refactor.sh b/tests/unit/test-deploy-refactor.sh index 4331787..dcec8e7 100644 --- a/tests/unit/test-deploy-refactor.sh +++ b/tests/unit/test-deploy-refactor.sh @@ -201,7 +201,7 @@ EOF done KIT_MDM_MANAGED=false _build_tmp="$(mktemp -d)" - build_settings_file "$_build_tmp/settings.json" >/dev/null 2>&1 + build_settings_file "$_build_tmp/settings.json" >/dev/null 2>&1 || exit 1 jq -e 'any(.hooks.SessionStart[]?.hooks[]?.command?; contains("feature-recommendation/check-pending.sh"))' \ "$_build_tmp/settings.json" >/dev/null @@ -221,7 +221,7 @@ EOF done KIT_MDM_MANAGED=true _build_tmp="$(mktemp -d)" - build_settings_file "$_build_tmp/settings.json" >/dev/null 2>&1 + build_settings_file "$_build_tmp/settings.json" >/dev/null 2>&1 || exit 1 ! jq -e 'any(.hooks.SessionStart[]?.hooks[]?.command?; contains("feature-recommendation/check-pending.sh"))' \ "$_build_tmp/settings.json" >/dev/null diff --git a/tests/unit/test-ghostty.sh b/tests/unit/test-ghostty.sh index 729ae93..ec9fb21 100644 --- a/tests/unit/test-ghostty.sh +++ b/tests/unit/test-ghostty.sh @@ -80,7 +80,7 @@ _ghostty_test_make_app() { mkdir -p "$_app/Contents/MacOS" printf 'outside' > "$_tmpdir/ghostty" chmod +x "$_tmpdir/ghostty" - ln -s "$_tmpdir/ghostty" "$_app/Contents/MacOS/ghostty" + ln -s "$_tmpdir/ghostty" "$_app/Contents/MacOS/ghostty" || exit 1 _codesign_called=0 _ghostty_codesign() { _codesign_called=1; return 0; } ! ghostty_mdm_is_trusted "$_app" \ @@ -97,7 +97,7 @@ _ghostty_test_make_app() { if ( _tmpdir="$(mktemp -d)" _app="$_tmpdir/Ghostty.app" - _ghostty_test_make_app "$_app" + _ghostty_test_make_app "$_app" || exit 1 _ghostty_codesign() { return 1; } ! ghostty_mdm_is_trusted "$_app" ); then @@ -262,7 +262,7 @@ _ghostty_test_make_app() { mkdir -p "$_config_dir" printf 'old\n' > "$_config" printf 'new\n' > "$_template" - deploy_ghostty_config "$_template" >/dev/null 2>&1 + deploy_ghostty_config "$_template" >/dev/null 2>&1 || exit 1 _backups=("$_config".backup.*) [[ "$(cat "$_config")" == new && ! -e "${_backups[0]}" ]] ); then @@ -288,7 +288,7 @@ _ghostty_test_make_app() { printf 'old\n' > "$_config" printf 'new\n' > "$_template" date() { printf '%s' 20000101000000; } - deploy_ghostty_config "$_template" >/dev/null 2>&1 + deploy_ghostty_config "$_template" >/dev/null 2>&1 || exit 1 [[ "$(cat "$_config")" == new \ && "$(cat "$_config.backup.20000101000000")" == old ]] ); then @@ -313,7 +313,7 @@ _ghostty_test_make_app() { printf 'old\n' > "$_config" printf 'new\n' > "$_template" date() { printf '%s' 20000101000000; } - deploy_ghostty_config "$_template" >/dev/null 2>&1 + deploy_ghostty_config "$_template" >/dev/null 2>&1 || exit 1 [[ "$(cat "$_config")" == new \ && "$(cat "$_config.backup.20000101000000")" == old ]] ); then diff --git a/tests/unit/test-mdm-install.sh b/tests/unit/test-mdm-install.sh index 02e3d09..d2f3596 100644 --- a/tests/unit/test-mdm-install.sh +++ b/tests/unit/test-mdm-install.sh @@ -2096,7 +2096,7 @@ fi /bin/sleep 0.01 _attempt=$((_attempt + 1)) done - [[ -e "$_ready" && "$_actual_pgid" == "$_leader" ]] + [[ -e "$_ready" && "$_actual_pgid" == "$_leader" ]] || exit 1 /bin/kill -STOP -- "-$_leader" _attempt=0 while ! _mdm_launcher_group_quiesced "$_leader" \ @@ -2108,14 +2108,14 @@ fi _member_count="$(printf '%s\n' "$_listing" \ | /usr/bin/awk -v pgid="$_leader" '$1 == pgid { count++ } END { print count + 0 }')" - [[ "$_member_count" -ge 2 ]] - _mdm_launcher_group_quiesced "$_leader" + [[ "$_member_count" -ge 2 ]] || exit 1 + _mdm_launcher_group_quiesced "$_leader" || exit 1 exec 2>/dev/null /bin/kill -KILL -- "-$_leader" 2>/dev/null || true _mdm_launcher_wait_child_bounded "$_leader" 100 || true _state=0 _mdm_launcher_group_state "$_leader" || _state=$? - [[ "$_state" -eq 1 ]] + [[ "$_state" -eq 1 ]] || exit 1 _leader="" trap - EXIT ) > "$_diagnostic" 2>&1 || _rc=$? @@ -2145,7 +2145,7 @@ fi LC_ALL=C /bin/ps -p "$_quick_pid" -o pgid= 2>/dev/null || true )" _actual_pgid="${_actual_pgid//[[:space:]]/}" - [[ -z "$_actual_pgid" || "$_actual_pgid" == "$_quick_pgid" ]] + [[ -z "$_actual_pgid" || "$_actual_pgid" == "$_quick_pgid" ]] || exit 1 wait "$_quick_pid" _quick_pid="" _quick_pgid="" _quick_starting=0 _attempt=$((_attempt + 1))