fix(tests): repair test-runner arithmetic and false-positive checks
Three bugs prevented the validation suite from running cleanly: - run-tests.sh used `((TESTS_PASSED++))` under `set -e`. Post-increment evaluates to the old value, so the first passing test (0 -> 1) made `(( ))` return 1 and errexit aborted the whole run after exactly one test. Use plain arithmetic assignment instead. - https-enforcement.sh's comment filter ran `grep -n` (which prefixes "linenum:") and then tried to drop comment lines with `^[[:space:]]*#`, which never matched the line-number prefix. Every http:// URL in a comment (deprecated curl lines, the strict-mode attribution comment) was flagged as a violation. Match the prefix. - 2fa-validation.sh hardcoded `/home/$user/` for the setup-instructions check, so for root it looked in /home/root (which does not exist) instead of /root. Resolve the home directory with getent. 🤖 Generated with [Crush](https://github.com/charmassociates/crush) Assisted-by: GLM-5 via Crush <crush@charm.land>
This commit is contained in:
@@ -18,7 +18,9 @@ function test_no_http_urls() {
|
||||
if [[ -d "$dir" ]]; then
|
||||
# Find HTTP URLs in shell scripts (excluding comments)
|
||||
while IFS= read -r -d '' file; do
|
||||
if grep -n "http://" "$file" | grep -v "^[[:space:]]*#" | grep -v "schema.org" | grep -v "xmlns"; then
|
||||
# grep -n prefixes "linenum:", so the comment filter must allow
|
||||
# for that prefix before the leading '#' of a comment line.
|
||||
if grep -n "http://" "$file" | grep -vE '^[0-9]+:[[:space:]]*#' | grep -v "schema.org" | grep -v "xmlns"; then
|
||||
echo "❌ HTTP URL found in: $file"
|
||||
((++http_violations))
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user