diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index aff2fbc..92b4547 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,6 +8,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: 1.23.2 + cache: false - name: Checkout code uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 33115c2..0d6ac91 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ export GOPATH ?= $(shell $(GO) env GOPATH) export GOBIN ?= $(GOPATH)/bin # Setup go-make version to use desired build and config scripts. -GOMAKE_DEP ?= github.com/tkrop/go-make@v0.0.106 +GOMAKE_DEP ?= github.com/tkrop/go-make@v0.0.108 INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto # Request targets from go-make targets target. TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \ diff --git a/VERSION b/VERSION index 236c7ad..818944f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.21 +0.0.22 diff --git a/test/context.go b/test/context.go index 63cdd0f..13a0e37 100644 --- a/test/context.go +++ b/test/context.go @@ -2,9 +2,9 @@ package test import ( "math" + "regexp" "runtime" "runtime/debug" - "strings" gosync "sync" "sync/atomic" "testing" @@ -450,10 +450,10 @@ func (t *Context) Failed() bool { return t.failed.Load() } -// Offset fr original stack in case of panic handling. -// -// TODO: check offset or/and find a better solution to handle panic stack. -const panicOriginStackOffset = 10 +// regexPanic is a regular expression to extract the actual important panic +// stack trace removing the distracting parts from the test framework. +var regexPanic = regexp.MustCompile(`(?m)\nruntime\/debug\.Stack\(\)` + + `(\n|.)*runtime\/panic\.go:([0-9]+)[^\n]*\n`) // Panic handles failure notifications of panics that also abort the test // execution immediately. @@ -469,10 +469,8 @@ func (t *Context) Panic(arg any) { defer t.unlock() if t.expect == Success { - stack := strings.SplitN(string(debug.Stack()), - "\n", panicOriginStackOffset) - t.Fatalf("panic: %v\n%s\n%s", arg, stack[0], - stack[panicOriginStackOffset-1]) + stack := regexPanic.Split(string(debug.Stack()), -1) + t.Fatalf("panic: %v\n%s\n%s", arg, stack[0], stack[1]) } else if t.reporter != nil { t.reporter.Panic(arg) } diff --git a/test/context_test.go b/test/context_test.go index ede220e..3d86698 100644 --- a/test/context_test.go +++ b/test/context_test.go @@ -130,7 +130,6 @@ type TestDeadlineParam struct { failure test.Expect } -// TODO: fix unit test for deadline!! var TestDeadlineParams = map[string]TestDeadlineParam{ "failed": { time: 0,