From: Shane Jaroch Date: Wed, 7 Jan 2026 21:03:11 +0000 (-0500) Subject: fixups/tweaks X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=8b4e66f4d66ade33d83702eebb79b7334d40ba1d;p=gamesguru%2Fgit-remote-gcrypt.git fixups/tweaks --- diff --git a/.envrc b/.envrc index 0c60dc4..125610a 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,8 @@ -# NOTE: for fish add .fish on end +#!/bin/bash + +# in kilobytes +export GCRYPT_TEST_REPACK_SCENARIO_BLOB_SIZE=100 + +# NOTE: for fish add .fish on end; zsh has its own script, too source ./completions/$(basename $SHELL)/git-remote-gcrypt diff --git a/Makefile b/Makefile index 63dd839..8aea4b5 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ _all: lint test/installer test/system .PHONY: vars vars: ##H Display all Makefile variables (simple) - @echo "=== Makefile Variables (file/command/line origin) ===" + $(info === Makefile Variables (file/command/line origin) ===) @$(foreach V,$(sort $(.VARIABLES)), \ $(if $(filter file command line,$(origin $(V))), \ $(info $(shell printf "%-30s" "$(V)") = $(value $(V))) \ @@ -124,22 +124,25 @@ test/system: check/deps ##H Run coverage tests (Dynamic Bash) trap - EXIT -define CHECK_COVERAGE -XML_FILE=$$(find $(1) -name "cobertura.xml" 2>/dev/null | grep "merged" | head -n 1); \ -[ -z "$$XML_FILE" ] && XML_FILE=$$(find $(1) -name "cobertura.xml" 2>/dev/null | head -n 1); \ -if [ -f "$$XML_FILE" ]; then \ - echo ""; \ - echo "Report for: file://$$(dirname "$$XML_FILE")/index.html"; \ - XML_FILE="$$XML_FILE" PATT="$(2)" FAIL_UNDER="$(3)" python3 tests/coverage_report.py; \ -else \ - echo ""; \ - echo "Error: No coverage report found for $(2) in $(1)"; \ - exit 1; \ -fi -endef +# Find coverage XML: preference for "merged" > any other (search depth: 2 subdirs) +find_coverage_xml = $(or \ + $(filter %/merged/cobertura.xml, $(wildcard $(1)/cobertura.xml $(1)/*/cobertura.xml $(1)/*/*/cobertura.xml)), \ + $(firstword $(wildcard $(1)/cobertura.xml $(1)/*/cobertura.xml $(1)/*/*/cobertura.xml)) \ +) + +CHECK_COVERAGE = $(if $(call find_coverage_xml,$(1)), \ + echo "" ; \ + echo "Report for: file://$(abspath $(dir $(call find_coverage_xml,$(1))))/index.html" ; \ + XML_FILE="$(call find_coverage_xml,$(1))" PATT="$(2)" FAIL_UNDER="$(3)" python3 tests/coverage_report.py, \ + echo "" ; \ + echo "Error: No coverage report found for $(2) in $(1)" ; \ + exit 1) -.PHONY: test/cov +.PHONY: test/cov _test_cov_internal test/cov: ##H Show coverage gaps + $(MAKE) _test_cov_internal + +_test_cov_internal: @err=0; \ $(call CHECK_COVERAGE,$(COV_SYSTEM),git-remote-gcrypt,60) || err=1; \ $(call CHECK_COVERAGE,$(COV_INSTALL),install.sh,80) || err=1; \ diff --git a/tests/coverage_report.py b/tests/coverage_report.py index 7e310ae..b7ba127 100644 --- a/tests/coverage_report.py +++ b/tests/coverage_report.py @@ -34,7 +34,9 @@ if total_lines > 0: else: print(f"Coverage: N/A (0 lines found for {patt})") if int(os.environ.get("FAIL_UNDER") or 0) > 0: - print(f"\033[31;1mFAIL: Coverage N/A is below threshold {os.environ.get('FAIL_UNDER')}%\033[0m") + print( + f"\033[31;1mFAIL: Coverage N/A is below threshold {os.environ.get('FAIL_UNDER')}%\033[0m" + ) sys.exit(1) @@ -50,5 +52,7 @@ if missed: fail_under = int(os.environ.get("FAIL_UNDER") or 0) if total_lines > 0: if pct < fail_under: - print(f"\033[31;1mFAIL: Coverage {pct:.1f}% is below threshold {fail_under}%\033[0m") + print( + f"\033[31;1mFAIL: Coverage {pct:.1f}% is below threshold {fail_under}%\033[0m" + ) sys.exit(1)