Closed ccoVeille closed 2 months ago
You could try install go-task/task, and run test with task test.
I'm using tasker on other repositories as well.
$ task --version
Task version: v3.35.1 (h1:zjQ3tLv+LIStDDTzOQx8F97NE/8FSTanjZuwgy/hwro=)
$ task test
task: [test] GOEXPERIMENT=nocoverageredesign go test -race -cover -coverprofile=coverage.out \
-covermode=atomic ./... ./tests/... ./examples/... \
-coverpkg .,./cmd/...,./internal/...
pattern ./tests/...: directory prefix tests does not contain main module or its selected dependencies
pattern ./examples/...: directory prefix examples does not contain main module or its selected dependencies
task: Failed to run task "test": exit status 1
I manage to get further by editing Taskfile.yml
and remove the ./tests/... ./examples
(I don't think you need it as you are already using ./...) from test
task
But then I get the exact same error.
$ task test
task: [test] GOEXPERIMENT=nocoverageredesign go test -race -cover -coverprofile=coverage.out \
-covermode=atomic ./... \
-coverpkg .,./cmd/...,./internal/...
--- FAIL: TestGraph (0.01s)
--- FAIL: TestGraph/linux_amd64 (0.01s)
callgraph_test.go:32:
Error Trace: kod/cmd/kod/internal/callgraph_test.go:32
Error: Expected nil, but got: &exec.ExitError{ProcessState:(*os.ProcessState)(0xc000012360), Stderr:[]uint8(nil)}
Test: TestGraph/linux_amd64
panic: open graphcase: no such file or directory [recovered]
panic: open graphcase: no such file or directory
Even by fixing #151 and #153, the issue remains
Could you try launching the tests in a fresh docker instance to see it doesn't work as expected
@ccoVeille It's quite weird, seems like the path located in your system is different from mine, and everything works fine in github actions and my mac system.
➜ kod git:(main) ✗ task test
task: [test] GOEXPERIMENT=nocoverageredesign go test -race -cover -coverprofile=coverage.out \
-covermode=atomic ./... ./tests/... ./examples/... \
-coverpkg .,./cmd/...,./internal/...
? github.com/go-kod/kod/cmd/kod [no test files]
? github.com/go-kod/kod/interceptor/kaccesslog [no test files]
? github.com/go-kod/kod/interceptor/kcircuitbreaker [no test files]
? github.com/go-kod/kod/interceptor/kprotovalidate [no test files]
? github.com/go-kod/kod/interceptor/kratelimit [no test files]
? github.com/go-kod/kod/interceptor/kmetric [no test files]
? github.com/go-kod/kod/interceptor/krecovery [no test files]
? github.com/go-kod/kod/interceptor/kretry [no test files]
? github.com/go-kod/kod/interceptor/ktimeout [no test files]
? github.com/go-kod/kod/interceptor/ktrace [no test files]
? github.com/go-kod/kod/interceptor/kvalidate [no test files]
? github.com/go-kod/kod/internal/callgraph [no test files]
? github.com/go-kod/kod/internal/hooks [no test files]
ok github.com/go-kod/kod 1.081s coverage: 10.7% of statements in ., ./cmd/..., ./internal/...
? github.com/go-kod/kod/internal/mock [no test files]
? github.com/go-kod/kod/internal/paths [no test files]
? github.com/go-kod/kod/internal/reflects [no test files]
? github.com/go-kod/kod/internal/registry [no test files]
? github.com/go-kod/kod/internal/signals [no test files]
? github.com/go-kod/kod/internal/singleton [no test files]
? github.com/go-kod/kod/tests/graphcase [no test files]
? github.com/go-kod/kod/tests/proto/examplev1 [no test files]
? github.com/go-kod/kod/examples/cmd/app/helloworld [no test files]
? github.com/go-kod/kod/examples/infra/redis [no test files]
? github.com/go-kod/kod/examples/log [no test files]
ok github.com/go-kod/kod/cmd/kod/internal 12.933s coverage: 45.9% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/interceptor 1.086s coverage: 0.7% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/interceptor/internal/circuitbreaker 2.077s coverage: 0.7% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/interceptor/internal/kerror 1.080s coverage: 0.7% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/interceptor/internal/ratelimit 2.082s coverage: 2.5% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/internal/kslog 1.098s coverage: 3.8% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/internal/rolling 5.231s coverage: 13.2% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/tests/case1 1.256s coverage: 26.3% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/tests/case2 1.096s coverage: 6.5% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/tests/case3 1.096s coverage: 6.4% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/tests/case4 1.091s coverage: 11.9% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/examples/app/helloworld 1.080s coverage: 9.7% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/examples/config 1.095s coverage: 11.4% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/examples/domain/ranklist 1.087s coverage: 11.4% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/examples/domain/shorturl 1.070s coverage: 11.6% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/examples/domain/snowflake 1.051s coverage: 12.7% of statements in ., ./cmd/..., ./internal/...
ok github.com/go-kod/kod/examples/domain/user 1.076s coverage: 13.0% of statements in ., ./cmd/..., ./internal/...
@ccoVeille please check your go version
I manage to get further by editing Taskfile.yml and remove the ./tests/... ./examples (I don't think you need it as you are already using ./...) from test task
The reason to add ./tests/... and ./examples/... is we seperate these two directory as individual modules.
I'll review everything, thanks
If GitHub Action works, there is indeed something strange with my setup
I'm using go 1.22.4 I tried with earlier Go version it's still the same :thinking:
I'm unable to make it work locally. I quit 🤔🤣
I'm closing the issue, maybe someone will face it again and might reference this issue later
Hi @ccoVeille , I would like to know your detailed system info, maybe we can find something out.
Maybe you did not get the compiled graphcase here, or you can try this command directly.
cd cmd/kod/internal
go build -o tests/graphcase ../../../tests/graphcase
Links:
Here is what I get
$ cd cmd/kod/internal
$ ls ../../../tests/graphcase/
case.go kod_gen.go kod_gen_interface.go kod_gen_mock.go
$ go build -o tests/graphcase ../../../tests/graphcase
main module (github.com/go-kod/kod) does not contain package github.com/go-kod/kod/tests/graphcase
I hope it would help
try add ./ before the ../../../tests/graphcase path?
Same results, but this worked
cd tests/graphcase
go build -o ../../internal/tests/graphcase .
but then tests doesn't work, as it tries to launch this
[pid 2392453] execve("/home/linuxbrew/.linuxbrew/Cellar/go/1.22.4/libexec/bin/go", ["go", "build", "-o", "graphcase", "../../../tests/graphcase"], 0xc00022db08 / 70 vars /) = 0
It looks like there is something wrong with go, maybe something with homebrew :thinking:, or your code, but I don't see why it would cause problem
try run
cd cmd/kod/internal
go build -o graphcase ./../../../tests/graphcase
Same as previously, this fail
$ go build -o graphcase ./../../../tests/graphcase
main module (github.com/go-kod/kod) does not contain package github.com/go-kod/kod/tests/graphcase
I'm afraid I'm unable to tell you why it's happening :shrug:
emm,I got it,do you init go module workspace? check if go.work exist?
Please try run go env and show me the result
I don't have a go.work or go.work.sum in kod folder, and none if folder above my dev folder
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/redacted/.cache/go-build'
GOENV='/home/redacted/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/redacted/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/redacted/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/linuxbrew/.linuxbrew/Cellar/go/1.22.4/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/linuxbrew/.linuxbrew/Cellar/go/1.22.4/libexec/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/home/redacted/Documents/dev/kod/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2225665431=/tmp/go-build -gno-record-gcc-switches'
that's it, you should run task first to generate go.work and then run task test
it worked, what a journey
then I'm surprised task test do not depend on build go work, maybe
So maybe something in the readme, would help
also something were there is a problem
Your project should have a .golangci.yml
or you should update task to use golangci-lint run --no-config
because, right now, with the way golangci-lint works, if there is a golangci file in the parent folder, it would apply its settings, and my settings are way more restrictive than the default value.
I can open a PR or create an issue, just tell me
Edited: Provided by #174 with #176
Great, pr is welcome
I've enhanced Taskfile, please checkout when convenient, thanks a lot~
Closed, golangci related things can open another issue or pr.
Thanks a lot for fixing test.
It will be easier to contribute now.
I'll open PR about fixing bugs/style then
https://github.com/go-kod/kod/pull/176 was opened for records