While following up on the failing Outputs advice to install missing gpg test, I noticed that the test correctly identifies misbehaving code.
Test output:
not ok 5 Outputs advice to install missing gpg
# (in test file sig/test/test.bats, line 31)
# `echo "${output}" | grep "apt install gpg"' failed
There are multiple problems:
command -v "1ドル" >/dev/null || die "Error: $cmd not found"
incorrectly checks against 1ドル instead of the $cmd within the loop. As a result, all checks are against git, not against the actual $cmd binaries.
The last commit 03bbbcc350 generalized the gpg command name by switching to GIT_SIG_GPG_VERIFY_COMMAND and GIT_SIG_SIGN_COMMAND. However, the code then uses GIT_SIG_VERIFY_COMMAND in multiple places, which does not exist (note the missing _GPG substring). This leads to the check_tools git head cut find sort sed getopt openssl call which does not check for gpg.
Note that other commands are affected by this as well.
If gpg is missing from $PATH, as the test simulates, the program will exit 1 on
command -v "1ドル" >/dev/null || die "Error: $cmd not found"
instead of calling die_pkg() which gives the command installation recommendation that the test is looking for. die_pkg() is called in check_version(), which runs only if the target command is available for a version check.
While following up on the failing `Outputs advice to install missing gpg` test, I noticed that the test correctly identifies misbehaving code.
Test output:
```
not ok 5 Outputs advice to install missing gpg
# (in test file sig/test/test.bats, line 31)
# `echo "${output}" | grep "apt install gpg"' failed
```
There are multiple problems:
https://codeberg.org/distrust/git-sig/src/commit/03bbbcc350177fe359892d70789e0c8a60bd30dd/git-sig#L101 incorrectly checks against `1ドル` instead of the `$cmd` within the loop. As a result, all checks are against `git`, not against the actual `$cmd` binaries.
The last commit 03bbbcc350177fe359892d70789e0c8a60bd30dd generalized the gpg command name by switching to GIT_SIG_GPG_VERIFY_COMMAND` and GIT_SIG_SIGN_COMMAND`. However, the code then uses `GIT_SIG_VERIFY_COMMAND` in multiple places, which does not exist (note the missing `_GPG` substring). This leads to the `check_tools git head cut find sort sed getopt openssl` call which does not check for `gpg`.
Note that other commands are affected by this as well.
If gpg is missing from $PATH, as the test simulates, the program will `exit 1` on https://codeberg.org/distrust/git-sig/src/commit/03bbbcc350177fe359892d70789e0c8a60bd30dd/git-sig#L101 instead of calling `die_pkg()` which gives the command installation recommendation that the test is looking for. `die_pkg()` is called in `check_version()`, which runs only if the target command is available for a version check.