xgo: xgo failed to run tests on Windows
I created a test with xgo on https://github.com/Zxilly/go-size-analyzer/blob/master/internal/printer/json_xgo_test.go. But when I run the test with
xgo test -v -race -covermode=atomic -cover ./... -tags xgo,embed
It tolds me
open C:\Users\zxilly\.xgo\go-instrument\go1.22.3_C_Us_12_go_pk_mo_go_to_7f0da9bd\go1.22.3\src\runtime\proc.go: The system cannot find the path specified.
The dir structure of C:\Users\zxilly\.xgo\go-instrument\go1.22.3_C_Us_12_go_pk_mo_go_to_7f0da9bd\ is
Directory: C:\Users\zxilly\.xgo\go-instrument\go1.22.3_C_Us_12_go_pk_mo_go_to_7f0da9bd
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2024/5/10 11:36 pkgdata
nothing in the pkgdata directory.
I’m running go 1.22.3 and xgo 1.0.31, build with go install.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (10 by maintainers)
@Zxilly
--trap-stdlibhas been made default when runningxgo test, released with https://github.com/xhd2015/xgo/releases/tag/v1.0.38.To install xgo v1.0.38:
Thanks.
It is possible to automatically add
--trap-stdlibwhenxgo testis used. But since xgo v1.0.36 is the first release introducing this flag, I think I need to test this flag against some large projects like kubernetes to see if it has any impact.If all tests go well, I’ll make this flag default in the future version.
@Zxilly This is being resolved in this PR: https://github.com/xhd2015/xgo/pull/117 . Will be available in the next version of xgo at 2024-05-20.
I tried to support as more stdlib packages as possible, however due the nature of the implementations, these packages cannot be mocked:
User needs to add
--trap-stdlibto explicitly enable mocking stdlib functions: