`go test` for package失败但单独测试运行正常,包编译得很好

时间:2015-06-14 17:40:44

标签: 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]

虽然上述测试失败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

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

go build的输出是什么

$ go build github.com/dm03514/go-edu-db/...
$

go version is

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

2 个答案:

答案 0 :(得分:0)

我安装了ubuntu golang

$ go version
go version go1.2.1 linux/amd64

现在运行包测试时会收到有意义的错误消息:

$ go test github.com/dm03514/go-edu-db/..

答案 1 :(得分:0)

我重新安排了测试顺序,它对我有用。我想有些例行泄漏。