diff --git a/Makefile b/Makefile index f581236..b225e02 100644 --- a/Makefile +++ b/Makefile @@ -53,10 +53,11 @@ update-golden: build-e2e ## Regenerate golden files for pattern battery tests check-coverage: ## Run tests with coverage and enforce minimum threshold @echo "Running tests with coverage (threshold: $(COVERAGE_THRESHOLD)%)..." - @coverage_file=$$(mktemp); \ + @set -e; \ + coverage_file=$$(mktemp); \ trap 'rm -f "$$coverage_file"' EXIT; \ $(GOTEST) $$(go list ./... | grep -v /e2e) -coverprofile="$$coverage_file"; \ - total=$$($(GOCMD) tool cover -func="$$coverage_file" | grep '^total' | awk '{print $$3}' | tr -d '%'); \ + total=$$(awk 'NR>1 { tot+=$$2; if ($$3>0) cov+=$$2 } END { if (tot>0) printf "%.1f", 100*cov/tot; else print "0.0" }' "$$coverage_file"); \ echo "Total coverage: $${total}%"; \ if ! awk "BEGIN { exit !($$total >= $(COVERAGE_THRESHOLD)) }"; then \ echo "FAIL: coverage $${total}% is below threshold $(COVERAGE_THRESHOLD)%"; exit 1; \ diff --git a/cmd/colref/check_test.go b/cmd/colref/check_test.go index 32b667b..cabf035 100644 --- a/cmd/colref/check_test.go +++ b/cmd/colref/check_test.go @@ -790,9 +790,13 @@ func TestCheckCmd_RunE_InvalidFormat(t *testing.T) { "--orm", "django", "--format", "xml", }) - if err := rootCmd.Execute(); err == nil { + err := rootCmd.Execute() + if err == nil { t.Fatal("expected error for invalid --format") } + if !strings.Contains(err.Error(), `unknown --format "xml"`) { + t.Fatalf("error is not the --format validation failure: %v", err) + } } func TestCheckCmd_RunE_InvalidColor(t *testing.T) {