亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

`go test` 包失敗,但單獨測試運行良好,包編譯正常

`go test` 包失敗,但單獨測試運行良好,包編譯正常

Go
慕村225694 2021-10-18 10:04:34
當我執行go test整個包時,測試失敗:$ go test github.com/dm03514/go-edu-db/...# github.com/dm03514/go-edu-db/backendsgo1: internal compiler error: in read_type, at go/gofrontend/import.cc:669Please 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/httpdgo1: internal compiler error: in read_type, at go/gofrontend/import.cc:669Please 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.gook      command-line-arguments  0.025sgo test github.com/dm03514/go-edu-db/httpd/handlers_test.gook      command-line-arguments  0.021s有沒有人遇到過這個問題?我是 Go 的新手,為了解決這個問題,我剛剛單獨執行了我的每個測試文件。go build 的輸出是什么$ go build github.com/dm03514/go-edu-db/...$轉到版本是$ go versiongo version xgcc (Ubuntu 4.9-20140406-0ubuntu1) 4.9.0 20140405 (experimental) [trunk revision 209157] linux/amd64
查看完整描述

3 回答

?
慕婉清6462132

TA貢獻1804條經驗 獲得超2個贊

這也發生在我身上。我最終只是評論了不同的測試,直到我能夠看到有用的輸出并看到它何時開始通過。根本原因是在測試完成后,我同時運行的測試 goroutine 正在調用之一t.Errorf(具體來說,我使用的是testify /assert 包,但這最終調用了 t.Errorf)。使用的輸出go test -v最終有這個錯誤信息:

TestTradeReader_Subscribe 完成后 goroutine 失敗

對我來說,發生這種情況是因為我正在使用httptest.Server(在我的測試期間同時運行)并且正在檢查快速退出且不需要此檢查的測試用例的輸入。


查看完整回答
反對 回復 2021-10-18
?
蠱毒傳說

TA貢獻1895條經驗 獲得超3個贊

可能是例行泄漏。您可能正在修改/更新測試中的全局變量,而不是在第二個測試中恢復。此錯誤的第二個原因可能是您的測試未在封閉的環境中運行。并在之后進行其他測試。您可以重新構建您的測試,以便給出錯誤的測試首先運行,以便它成功


查看完整回答
反對 回復 2021-10-18
  • 3 回答
  • 0 關注
  • 461 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號