包的“go test”失败,但单独测试运行良好,并且包编译良好

dm0*_*514 6 unit-testing go

当我go test对整个包执行时,测试失败并显示:

$ go test github.com/dm03514/go-edu-db/...
# github.com/dm03514/go-edu-db/backends
go1: internal compiler error: in read_type, at go/gofrontend/import.cc:669
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gccgo-4.9/README.Bugs> for instructions.
FAIL    github.com/dm03514/go-edu-db/backends [build failed]
?       github.com/dm03514/go-edu-db/cmd        [no test files]
# github.com/dm03514/go-edu-db/httpd
go1: internal compiler error: in read_type, at go/gofrontend/import.cc:669
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gccgo-4.9/README.Bugs> for instructions.
FAIL    github.com/dm03514/go-edu-db/httpd [build failed]
?       github.com/dm03514/go-edu-db/logging    [no test files]
Run Code Online (Sandbox Code Playgroud)

虽然上述测试无法go install正确构建,但我可以正确运行每个单独的测试:

$ go test github.com/dm03514/go-edu-db/backends/backends_test.go
ok      command-line-arguments  0.025s


go test github.com/dm03514/go-edu-db/httpd/handlers_test.go
ok      command-line-arguments  0.021s
Run Code Online (Sandbox Code Playgroud)

以前有人遇到过这个吗?我是 Go 的新手,为了解决这个问题,我刚刚单独执行了每个测试文件。

go build 的输出什么也没有

$ go build github.com/dm03514/go-edu-db/...
$
Run Code Online (Sandbox Code Playgroud)

去版本是

$ go version
go version xgcc (Ubuntu 4.9-20140406-0ubuntu1) 4.9.0 20140405 (experimental) [trunk revision 209157] linux/amd64
Run Code Online (Sandbox Code Playgroud)

Piy*_*shh -1

可能存在常规泄漏。您可能正在测试中修改/更新全局变量,并且不会恢复第二次测试。此错误的第二个原因可能是您的测试没有在封闭的环境中运行。并进行其他测试。您可以重新构建测试,以便首先运行给出错误的测试,以便成功