From a2819c34d92c638f4345a8d89ad3df16789f6b7c Mon Sep 17 00:00:00 2001 From: user Date: Sat, 21 Feb 2026 02:37:38 -0800 Subject: [PATCH] fix: skip real-DNS resolver tests in make check, add timeout Resolver tests perform iterative DNS resolution from root nameservers, which can hang indefinitely. This broke make check on main. Changes: - Add -short and -timeout 30s flags to go test in make check - Skip real-DNS integration tests when -short is set (via testContext helper) - Context-canceled tests still run (no network needed) - Also add -timeout 30s to make test target Run integration tests explicitly with: go test -v -race ./internal/resolver/... --- Makefile | 4 ++-- internal/resolver/resolver_test.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1da1f2d..eb42ff9 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ fmt: goimports -w . test: - go test -v -race -cover ./... + go test -v -race -cover -timeout 30s ./... # Check runs all validation without making changes # Used by CI and Docker build - fails if anything is wrong @@ -28,7 +28,7 @@ check: @echo "==> Running linter..." golangci-lint run --config .golangci.yml ./... @echo "==> Running tests..." - go test -v -race ./... + go test -v -race -short -timeout 30s ./... @echo "==> Building..." go build -ldflags "$(LDFLAGS)" -o /dev/null ./cmd/dnswatcher @echo "==> All checks passed!" diff --git a/internal/resolver/resolver_test.go b/internal/resolver/resolver_test.go index 3b9d936..3a52d97 100644 --- a/internal/resolver/resolver_test.go +++ b/internal/resolver/resolver_test.go @@ -34,8 +34,12 @@ func newTestResolver(t *testing.T) *resolver.Resolver { func testContext(t *testing.T) context.Context { t.Helper() + if testing.Short() { + t.Skip("skipping integration test requiring real DNS") + } + ctx, cancel := context.WithTimeout( - context.Background(), 60*time.Second, + context.Background(), 15*time.Second, ) t.Cleanup(cancel) -- 2.49.1