ondrajz / go-callvis

Visualize call graph of a Go program using Graphviz
https://ofabry.github.io/go-callvis
MIT License
5.94k stars 409 forks source link

flag '-tests' is not work #82

Closed timmyyuan closed 3 years ago

timmyyuan commented 3 years ago

I create a go test file (my_test.go) in a empty directory:

package my_test

import (
        "go.uber.org/goleak"
        "testing"
)

func TestFunc(t *testing.T) {
        defer goleak.VerifyNone(t)
        var x int
        x = 1 / x
}

And then add its mod file:

module my_test

go 1.15

require go.uber.org/goleak v1.1.10

Then, I use go-callvis to visit the call graph of my_test.go by

 go-callvis -tests .

There should be a function "TestFunc" displayed on the browser but I could not find it. Is this caused by my wrong operations?

Some system information:

$ OS
ubuntu 20.04 in windows WSL2
$ go version
go version go1.15.6 linux/amd64
go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/yuanting/.cache/go-build"
GOENV="/home/yuanting/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/yuanting/go/pkg/mod"
GONOPROXY="github.com/timmyyuan/pautil"
GONOSUMDB="github.com/timmyyuan/pautil"
GOOS="linux"
GOPATH="/home/yuanting/go"
GOPRIVATE="github.com/timmyyuan/pautil"
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/pautil-test-896714642/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build989666205=/tmp/go-build -gno-record-gcc-switches"
timmyyuan commented 3 years ago

I can't reproduce it on MacOS.

timmyyuan commented 3 years ago

Sorry it's my mistake, the node of "TestFunc" should in testing package because it is called by tRunner actually.