Add shellspec coverage for pure/read-only subcommands#2
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Complex PR? Review this PR in Change Stack to move by importance, not file order. 📝 WalkthroughWalkthrough本 PR は、texenv の複数のサブコマンドに対する shellspec ベースのテストスイートと、テスト実行を支援する共通ヘルパー関数群を新規追加します。テスト環境を一元管理する Changesテスト仕様追加
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR improves the ShellSpec test suite by extracting common spec helpers into a shared module and adding new specs to cover the “pure/read-only” subcommands (plus their help/alias entrypoints), without changing any libexec/* production scripts.
Changes:
- Added
spec/support/helpers.shand moved commonly used setup/invocation helpers there (also used by the existingrestorespec). - Added new ShellSpec coverage for 8 pure/read-only subcommands:
root,shims,commands,where,which,whence,---help,--h. - Initialized and exported
TEX_CMD_LIST_CACHEinspec_helper.shto supporttexenv-whenceunderset -u.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| spec/support/helpers.sh | New shared helper functions for version file setup, per-dir invocation, and shim/version command setup. |
| spec/spec_helper.sh | Sources new helpers; initializes/exports TEX_CMD_LIST_CACHE in the test environment. |
| spec/libexec/texenv-restore_spec.sh | Switches to shared invoke_in_dir (and shared set_global_version). |
| spec/libexec/texenv-root_spec.sh | Adds specs for texenv-root output, help flags, and error paths. |
| spec/libexec/texenv-shims_spec.sh | Adds specs for shim listing behavior, help flags, and error paths. |
| spec/libexec/texenv-commands_spec.sh | Adds specs for subcommand enumeration and exclusion rules, plus help/missing-component paths. |
| spec/libexec/texenv-where_spec.sh | Adds specs for resolving command paths in the selected version and related error/help cases. |
| spec/libexec/texenv-which_spec.sh | Adds specs for shim resolution and related error/help cases. |
| spec/libexec/texenv-whence_spec.sh | Adds specs for cross-version search behavior including cache-file usage and error/help cases. |
| spec/libexec/texenv---help_spec.sh | Adds specs for the ---help alias behavior and missing-help error. |
| spec/libexec/texenv--h_spec.sh | Adds specs for the --h alias behavior and missing-help error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
spec/libexec/texenv-whence_spec.sh (1)
56-67: ⚡ Quick win
--helpフラグのテストケースが不足しています。他のすべての spec ファイルは
-hと--helpの両方をテストしていますが、このファイルには-hのテスト(56-60 行目)のみが含まれています。一貫性を保つため、--helpフラグのテストケースも追加することを推奨します。PR の目的にも follow-up として記載されているため、今後の対応で問題ありません。
📋 推奨される追加テストケース
It 'execs texenv-help whence when -h is given' When call invoke -h The status should equal 0 The output should include 'Usage: texenv whence' End + It 'execs texenv-help whence when --help is given' + When call invoke --help + The status should equal 0 + The output should include 'Usage: texenv whence' + End + It 'errors when texenv-help is missing'🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/libexec/texenv-whence_spec.sh` around lines 56 - 67, Add a parallel test to the existing "-h" case to assert "--help" behavior: duplicate the "It 'execs texenv-help whence when -h is given'" block but call invoke with "--help" instead of "-h", assert status is 0 and output includes 'Usage: texenv whence'; keep the existing "errors when texenv-help is missing" test untouched. This ensures the spec in spec/libexec/texenv-whence_spec.sh covers both -h and --help flags consistently.spec/libexec/texenv-where_spec.sh (1)
56-61: ⚡ Quick wintexenv-help 欠落時のテストケースが不足しています。
他のすべての spec ファイル(commands, root, shims, which, whence)には「
texenv-helpが欠落している場合のエラー」テストが含まれていますが、このファイルにはtexenv-libs欠落のテストのみが存在します。texenv-whereは-h/--helpフラグをサポートしているため(44-54 行目)、texenv-helpへの依存も検証すべきです。一貫性を保つため、以下のテストケースの追加を推奨します:
📋 推奨される追加テストケース
It 'errors when texenv-libs is missing' rm -f "${TEXENV_SPEC_BIN}/texenv-libs" When call invoke The status should equal 1 The stderr should include 'required component(s) missing' End + + It 'errors when texenv-help is missing' + rm -f "${TEXENV_SPEC_BIN}/texenv-help" + When call invoke + The status should equal 1 + The stderr should include 'required component(s) missing' + End End🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@spec/libexec/texenv-where_spec.sh` around lines 56 - 61, Add a parallel test to spec/libexec/texenv-where_spec.sh that checks failure when texenv-help is missing: remove "${TEXENV_SPEC_BIN}/texenv-help" before calling the existing test helper (the same helper invoked by "When call invoke"), then assert the exit status is 1 and stderr contains 'required component(s) missing'—mirror the existing "errors when texenv-libs is missing" test to ensure texenv-where's dependency on texenv-help is verified.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@spec/libexec/texenv-where_spec.sh`:
- Line 8: The spec is missing a test for the "texenv-help missing" case and also
relies on texenv_make_version (which is defined in spec/spec_helper.sh), so add
a new test in spec/libexec/texenv-where_spec.sh mirroring the existing
"texenv-libs missing" test: set up the environment so the texenv-help component
is absent (e.g., remove/rename from PATH or mock its absence), call the same
test helper(s) that invoke texenv-where, assert the exit status and that the
output contains the "help component(s) missing" message, and ensure you
reference texenv_make_version (from spec/spec_helper.sh) as used by the other
specs for version setup so the new test is consistent with the rest.
---
Nitpick comments:
In `@spec/libexec/texenv-whence_spec.sh`:
- Around line 56-67: Add a parallel test to the existing "-h" case to assert
"--help" behavior: duplicate the "It 'execs texenv-help whence when -h is
given'" block but call invoke with "--help" instead of "-h", assert status is 0
and output includes 'Usage: texenv whence'; keep the existing "errors when
texenv-help is missing" test untouched. This ensures the spec in
spec/libexec/texenv-whence_spec.sh covers both -h and --help flags consistently.
In `@spec/libexec/texenv-where_spec.sh`:
- Around line 56-61: Add a parallel test to spec/libexec/texenv-where_spec.sh
that checks failure when texenv-help is missing: remove
"${TEXENV_SPEC_BIN}/texenv-help" before calling the existing test helper (the
same helper invoked by "When call invoke"), then assert the exit status is 1 and
stderr contains 'required component(s) missing'—mirror the existing "errors when
texenv-libs is missing" test to ensure texenv-where's dependency on texenv-help
is verified.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2c3f23e8-61a7-4f8d-9629-2578b13c070a
📒 Files selected for processing (11)
spec/libexec/texenv---help_spec.shspec/libexec/texenv--h_spec.shspec/libexec/texenv-commands_spec.shspec/libexec/texenv-restore_spec.shspec/libexec/texenv-root_spec.shspec/libexec/texenv-shims_spec.shspec/libexec/texenv-whence_spec.shspec/libexec/texenv-where_spec.shspec/libexec/texenv-which_spec.shspec/spec_helper.shspec/support/helpers.sh
| where_before() { | ||
| texenv_setup | ||
| texenv_install_libexec texenv-where texenv-libs texenv-help | ||
| texenv_make_version 2025.01 |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# texenv_make_version の定義を検索
rg -n 'texenv_make_version' --type=shRepository: redpeacock78/texenv
Length of output: 386
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) 関連 spec を確認
echo "=== spec/spec_helper.sh (texenv_make_version 周辺) ==="
sed -n '60,110p' spec/spec_helper.sh
echo
echo "=== spec/libexec/texenv-where_spec.sh ==="
nl -ba spec/libexec/texenv-where_spec.sh | sed -n '1,120p'
echo
echo "=== spec/libexec/texenv-restore_spec.sh ==="
nl -ba spec/libexec/texenv-restore_spec.sh | sed -n '1,160p'
# 2) texenv-help 未存在テストが他ファイルにあるか探索
echo
echo "=== テスト文字列探索(texenv-help missing) ==="
rg -n "texenv-help.*missing|help.*missing|--help.*missing" spec/libexec --type=sh || true
rg -n "texenv_make_version" spec --type=shRepository: redpeacock78/texenv
Length of output: 1014
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== spec/libexec/texenv-where_spec.sh (先頭〜120行) ==="
sed -n '1,120p' spec/libexec/texenv-where_spec.sh | awk '{printf "%4d:%s\n", NR, $0}'
echo
echo "=== spec/libexec/texenv-restore_spec.sh (先頭〜180行) ==="
sed -n '1,180p' spec/libexec/texenv-restore_spec.sh | awk '{printf "%4d:%s\n", NR, $0}'
echo
echo "=== テスト文字列探索(texenv-help missing 系) ==="
rg -n "texenv-help.*missing|help.*missing|--help.*missing" spec/libexec --type=sh || true
echo
echo "=== texenv_make_version の参照箇所(spec 配下) ==="
rg -n "texenv_make_version" spec --type=shRepository: redpeacock78/texenv
Length of output: 7808
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n "texenv-help" spec/libexec/texenv-where_spec.sh --type=shRepository: redpeacock78/texenv
Length of output: 235
texenv_make_version の定義場所と、texenv-help 欠落テスト不足の指摘
texenv_make_version は spec/spec_helper.sh に定義されています(helpers.sh ではありません)。
ただし spec/libexec/texenv-where_spec.sh には texenv-libs 欠落時のテストはある一方で、他の spec と同様の「texenv-help 欠落時(help component(s) missing)」のテストがありません。追加して整合性を取ってください。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@spec/libexec/texenv-where_spec.sh` at line 8, The spec is missing a test for
the "texenv-help missing" case and also relies on texenv_make_version (which is
defined in spec/spec_helper.sh), so add a new test in
spec/libexec/texenv-where_spec.sh mirroring the existing "texenv-libs missing"
test: set up the environment so the texenv-help component is absent (e.g.,
remove/rename from PATH or mock its absence), call the same test helper(s) that
invoke texenv-where, assert the exit status and that the output contains the
"help component(s) missing" message, and ensure you reference
texenv_make_version (from spec/spec_helper.sh) as used by the other specs for
version setup so the new test is consistent with the rest.
Summary
spec/support/helpers.shを新設し、set_global_version/set_local_version/invoke_in_dir/setup_shim/setup_version_bin_commandの 5 関数を抽出。restore spec も新ヘルパに移行。spec_helper.shにTEX_CMD_LIST_CACHEの初期化 + export を追加 (texenv-whence がset -u下で参照するため)。Coverage
Test Plan
shellspec→50 examples, 0 failures確認Out of scope
Follow-up tickets
should not include '-help') を行単位マッチへ tighten--help例追加 (現状-hのみ)errors when texenv-help is missingパターンの helper 共通化検討🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
texenv-help、texenv-commands、texenv-root、texenv-shims、texenv-whence、texenv-where、texenv-which)に対する仕様テストスイートを追加しました。