Repository navigation
Add ShellSpec harness and coverage #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b9c63dd
b0dbd6b
aa06ec5
318c1e1
1010155
721bfc0
9d8b256
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1 +1,35 @@ | ||||||||||
| #!/usr/bin/env bash | ||||||||||
|
|
||||||||||
| set -euo pipefail | ||||||||||
|
|
||||||||||
| mock_bin_setup() { | ||||||||||
| MOCK_BIN="$(mktemp -d)" | ||||||||||
| MOCK_LOG="$MOCK_BIN/mock.log" | ||||||||||
| : >"$MOCK_LOG" | ||||||||||
|
|
||||||||||
| MOCK_ORIGINAL_PATH="${PATH:-}" | ||||||||||
| export MOCK_BIN MOCK_LOG MOCK_ORIGINAL_PATH | ||||||||||
| export PATH="$MOCK_BIN:$MOCK_ORIGINAL_PATH" | ||||||||||
|
|
||||||||||
| local cmd | ||||||||||
| for cmd in "$@"; do | ||||||||||
| cat >"$MOCK_BIN/$cmd" <<'EOF' | ||||||||||
| #!/usr/bin/env bash | ||||||||||
| set -euo pipefail | ||||||||||
| : "${MOCK_LOG:?MOCK_LOG must be set}" | ||||||||||
| printf '%s\n' "$0 $*" >>"$MOCK_LOG" | ||||||||||
|
||||||||||
| printf '%s\n' "$0 $*" >>"$MOCK_LOG" | |
| printf '%s' "$0" >>"$MOCK_LOG" | |
| for arg in "$@"; do printf ' %s' "$arg" >>"$MOCK_LOG"; done | |
| printf '\n' >>"$MOCK_LOG" |
Copilot
AI
Dec 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mock harness functions lack documentation comments. Consider adding comments to explain the purpose and usage of mock_bin_setup and mock_bin_cleanup, including the environment variables they set (MOCK_BIN, MOCK_LOG, MOCK_ORIGINAL_PATH) and how they should be used in tests. This would improve maintainability and help other developers understand how to use these testing utilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better robustness and portability, it's recommended to use
printfinstead ofechowhen piping variable content to other commands.echocan have surprising behavior if the variable's content starts with a hyphen (-) or contains backslash escape sequences, and its implementation varies between shells.printf '%s' "$command"is a safer alternative that will print the string exactly as is.