xhd2015 / xgo

All-in-one go testing library
MIT License
323 stars 19 forks source link

windows run `xgo test` error #4

Closed WAY29 closed 5 months ago

WAY29 commented 5 months ago
func TestMethodMock(t *testing.T) {
    myStruct := &MyStruct{
        name: "my struct",
    }
    otherStruct := &MyStruct{
        name: "other struct",
    }
    mock.Mock(myStruct.name, func(ctx context.Context, fn *core.FuncInfo, args core.Object, results core.Object) error {
        results.GetFieldIndex(0).Set("mock struct")
        return nil
    })

    // myStruct is affected
    name := myStruct.Name()
    if name != "mock struct" {
        t.Fatalf("expect myStruct.Name() to be 'mock struct', actual: %s", name)
    }

    // otherStruct is not affected
    otherName := otherStruct.Name()
    if otherName != "other struct" {
        t.Fatalf("expect otherStruct.Name() to be 'other struct', actual: %s", otherName)
    }
}

command: xgo test -run TestMethodMock .\mock_tcp_conn\ error: create ~/.xgo/log: mkdir C:\Users\admin\.xgo\go-instrument\go1.20.5_C:_Us_ad_sc_ap_go_cu_90061880: The directory name is invalid.

maybe create windows dir/file could not include ":"

xhd2015 commented 5 months ago

Noted,will fix it tomorrow morning. Thanks for feedback

xhd2015 commented 5 months ago

This has been fixed, see commit https://github.com/xhd2015/xgo/commit/a651abf3abfec58ea52a4d774a1b04c6f7c70c1d

You may need to update xgo to build again:

cd xgo
git pull
go run ./script/build-release --local
xhd2015 commented 5 months ago

P.S. I managed to get a PC on my hand, I will do a thorough test on windows today. Hope all windows issues be settled tonight, please stay tuned!

WAY29 commented 5 months ago

Alright, It seems to be a new error: replace not permitted:C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5, maybe no permission although I run xgo with administrator

In addition, maybe fix shasum command not found in script/build-release is Urgent, It look like build failed

xhd2015 commented 5 months ago

👌, will fix it this afternoon

xhd2015 commented 5 months ago

Update: have fixed a bunch of issues related to windows. The biggest one seems to be when IR rewriting enabled, windows needs to disable optimization(gcflags=-N). Hopefully most things on windows will be resolved tonight.

xhd2015 commented 5 months ago

Excited to announce windows passed all tests, see commit https://github.com/xhd2015/xgo/commit/f07938bdff12fa4bd066d0e9cfde64e99f17122a (tag v1.0.6)

With this update, xgo v1.0.6 has been released: https://github.com/xhd2015/xgo/releases/tag/v1.0.6. You may need to update xgo to build again:

cd xgo
git pull
go run ./script/build-release --local
WAY29 commented 5 months ago

Maybe something wrong? I test in my windows, and got error:

func TestMethodMock(t *testing.T) {
    myStruct := &MyStruct{
        name: "my struct",
    }
    otherStruct := &MyStruct{
        name: "other struct",
    }
    mock.Mock(myStruct.name, func(ctx context.Context, fn *core.FuncInfo, args core.Object, results core.Object) error {
        results.GetFieldIndex(0).Set("mock struct")
        return nil
    })

    // myStruct is affected
    name := myStruct.Name()
    if name != "mock struct" {
        t.Fatalf("expect myStruct.Name() to be 'mock struct', actual: %s", name)
    }

    // otherStruct is not affected
    otherName := otherStruct.Name()
    if otherName != "other struct" {
        t.Fatalf("expect otherStruct.Name() to be 'other struct', actual: %s", otherName)
    }
}
❯ xgo test -run TestMethodMock -v ./test
# runtime
..\..\..\..\runtime\proc.go:241:1: undefined: __xgo_is_init_finished
..\..\..\..\runtime\proc.go:242:20: undefined: __xgo_on_init_finished_callbacks
..\..\..\..\runtime\proc.go:245:1: undefined: __xgo_on_init_finished_callbacks
..\..\..\..\runtime\proc.go:3627:20: undefined: __xgo_on_goexits
exit status 1

xgo on  master [!] via 🐹 v1.20.5 
❯ xgo version
1.0.6
xhd2015 commented 5 months ago

May I ask what is your go version, and go env GOROOT? Is there any space inside the GOROOT?

WAY29 commented 5 months ago
golang\src\gotest via 🐹 v1.20.5 took 2s 
❯ go version
go version go1.20.5 windows/amd64

golang\src\gotest via 🐹 v1.20.5 
❯ go env GOROOT
C:\Users\admin\scoop\apps\go\current
xhd2015 commented 5 months ago

And also the output of xgo exec go version of xgo exec go env GOROOT? Seems the above error is due to the GOROOT pointing to original go source, not the instrumented source.

WAY29 commented 5 months ago

And also the output of xgo exec go version of xgo exec go env GOROOT? Seems the above error is due to the GOROOT pointing to original go source, not the instrumented source.

Got same error, maybe build --local error? See #8, I remove duplicate suffix manually

Or maybe I Install golang by scoop? (C:\Users\admin\scoop\apps\go\current Is link but not a directory)

xhd2015 commented 5 months ago

Ok understood,I've not tested that against a symbolic GOROOT on windows. Can you run xgo test --with-goroot your/real/goroot ... (replace your/real/goroot with the actual goroot on your machine), this forces xgo uses the specified GOROOT instead of environment value.

WAY29 commented 5 months ago

Ok understood,I've not tested that against a symbolic GOROOT on windows. Can you run xgo test --with-goroot your/real/goroot ... (replace your/real/goroot with the actual goroot on your machine), this forces xgo uses the specified GOROOT instead of environment value.

Not work, got same error

xhd2015 commented 5 months ago

I just tested with a symbolic link on windows, got error:

PS C:\Projects\xgo> xgo exec --with-goroot C:\installed\go1.22.1-sym.lnk go version
exec: "C:\\installed\\go1.22.1-sym.lnk\\bin\\go": executable file not found in %PATH%

It is obvious that windows does not think go1.22.1-sym.lnk to be a directory.

Can you verify if your GOROOT installed by scoop is a link? And if it is, can you run the above command with your goroot to check what will happen?

xhd2015 commented 5 months ago

Ok so I installed scoop, and successfully ran all tests on windows(powershell):

cd xgo

$Env:Path="C:\Users\xhd2015\scoop\apps\go\current\bin;C:\Users\xhd2015\.xgo\bin"

xgo test -v .\test\xgo_test\...

Output:

=== RUN   TestTrapSet
--- PASS: TestTrapSet (0.00s)
PASS
ok      github.com/xhd2015/xgo/test/xgo_test/link_on_init_finished      0.273s
=== RUN   TestMemEqual
--- PASS: TestMemEqual (0.00s)
PASS
ok      github.com/xhd2015/xgo/test/xgo_test/mem_equal  0.234s
=== RUN   TestMethodShouldHaveFMSuffix
--- PASS: TestMethodShouldHaveFMSuffix (0.00s)
PASS
ok      github.com/xhd2015/xgo/test/xgo_test/method_fm_suffix   0.255s
=== RUN   TestMethodRecvValueShouldBeCopied
--- PASS: TestMethodRecvValueShouldBeCopied (0.00s)
PASS
ok      github.com/xhd2015/xgo/test/xgo_test/method_recv_value  0.217s
=== RUN   TestMethodValueCompare
--- PASS: TestMethodValueCompare (0.00s)
PASS
ok      github.com/xhd2015/xgo/test/xgo_test/method_value_cmp   0.179s
=== RUN   TestRewriteChallenge
--- PASS: TestRewriteChallenge (0.00s)
PASS
ok      github.com/xhd2015/xgo/test/xgo_test/rewrite_challenge  0.175s
=== RUN   TestTrapSet
--- PASS: TestTrapSet (0.00s)
PASS
ok      github.com/xhd2015/xgo/test/xgo_test/trap_set   0.178s
WAY29 commented 5 months ago

I test in my work computer and got same error, I don't know the reason for this error

xhd2015 commented 5 months ago
❯ xgo test -run TestMethodMock -v ./test
# runtime
..\..\..\..\runtime\proc.go:241:1: undefined: __xgo_is_init_finished
..\..\..\..\runtime\proc.go:242:20: undefined: __xgo_on_init_finished_callbacks
..\..\..\..\runtime\proc.go:245:1: undefined: __xgo_on_init_finished_callbacks
..\..\..\..\runtime\proc.go:3627:20: undefined: __xgo_on_goexits

This looks weird, I will add a debug flag to enable log to see what's going on.(The log will contain environment info and building log).

By the way, what kind of terminal are you using on windows, powershell or other thing?

WAY29 commented 5 months ago
❯ xgo test -run TestMethodMock -v ./test
# runtime
..\..\..\..\runtime\proc.go:241:1: undefined: __xgo_is_init_finished
..\..\..\..\runtime\proc.go:242:20: undefined: __xgo_on_init_finished_callbacks
..\..\..\..\runtime\proc.go:245:1: undefined: __xgo_on_init_finished_callbacks
..\..\..\..\runtime\proc.go:3627:20: undefined: __xgo_on_goexits

This looks weird, I will add a debug flag to enable log to see what's going on.(The log will contain environment info and building log).

By the way, what kind of terminal are you using on windows, powershell or other thing?

powershell 5.1

xhd2015 commented 5 months ago

@WAY29 I have added a flag to log internal compile process, see https://github.com/xhd2015/xgo/commit/a90c6ef098ea021488a507ab255b738b8712c3be

First, upgrade xgo:

cd xgo
git pull
go run ./script/build-release --local

Then, run xgo with --log-debug:

xgo test --log-debug -run TestMethodMock -v ./test

And check debug.log in your current directory. Debug log example:

2024-03-25 17:55:24 start: [C:\Users\lukas\AppData\Local\Temp\go-build2111748048\b001\exe\xgo.exe exec --log-debug go version]
2024-03-25 17:55:24 runtime.GOOS=windows
2024-03-25 17:55:24 runtime.GOARCH=amd64
2024-03-25 17:55:24 runtime.Version()=go1.22.1
2024-03-25 17:55:25 effective GOROOT: C:\installed\go1.22.1
2024-03-25 17:55:25 go version: go1.22.1
2024-03-25 17:55:25 instrument dir: C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a
2024-03-25 17:55:25 sync goroot C:\installed\go1.22.1 -> C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1
2024-03-25 17:55:25 patch compiler at: C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1
2024-03-25 17:55:26 setup dev dir: C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1
2024-03-25 17:55:27 compiler changed: false
2024-03-25 17:55:27 tool exec flags: -toolexec=C:\Users\lukas\.xgo\bin\exec_tool.exe --enable --
2024-03-25 17:55:27 command: [go version]
2024-03-25 17:55:27 command env: [ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\lukas\AppData\Roaming CHROME_CRASHPAD_PIPE_NAME=\\.\pipe\crashpad_7388_YDEVBNMAIHLMTUHG CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=DESKTOP-Q4TKH82 ComSpec=C:\Windows\system32\cmd.exe DriverData=C:\Windows\System32\Drivers\DriverData FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer FPS_BROWSER_USER_PROFILE_STRING=Default GOPATH=C:\Projects\gopath GOROOT=C:\installed\go1.22.1 HOMEDRIVE=C: HOMEPATH=\Users\lukas LOCALAPPDATA=C:\Users\lukas\AppData\Local LOGONSERVER=\\DESKTOP-Q4TKH82 NUMBER_OF_PROCESSORS=4 OneDrive=C:\Users\lukas\OneDrive ORIGINAL_XDG_CURRENT_DESKTOP=undefined OS=Windows_NT Path=C:\installed\go1.22.1\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\installed\go1.22.1\bin;C:\cygwin64\bin;C:\Users\lukas\.xgo\bin;C:\Projects\gopath\bin;C:\Projects\gopath\bin;C:\Users\lukas\scoop\shims;C:\Users\lukas\AppData\Local\Microsoft\WindowsApps;C:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\bin PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=9e0a ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PSModulePath=C:\Users\lukas\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules PUBLIC=C:\Users\Public SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\Windows TEMP=C:\Users\lukas\AppData\Local\Temp TMP=C:\Users\lukas\AppData\Local\Temp USERDOMAIN=DESKTOP-Q4TKH82 USERDOMAIN_ROAMINGPROFILE=DESKTOP-Q4TKH82 USERNAME=lukas USERPROFILE=C:\Users\lukas windir=C:\Windows TERM_PROGRAM=vscode TERM_PROGRAM_VERSION=1.87.2 LANG=en_US.UTF-8 COLORTERM=truecolor GIT_ASKPASS=c:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass.sh VSCODE_GIT_ASKPASS_NODE=C:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\Code.exe VSCODE_GIT_ASKPASS_EXTRA_ARGS= VSCODE_GIT_ASKPASS_MAIN=c:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass-main.js VSCODE_GIT_IPC_HANDLE=\\.\pipe\vscode-git-3c257e6a92-sock VSCODE_INJECTION=1 GOROOT=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1 PATH=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1\bin;C:\installed\go1.22.1\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\installed\go1.22.1\bin;C:\cygwin64\bin;C:\Users\lukas\.xgo\bin;C:\Projects\gopath\bin;C:\Projects\gopath\bin;C:\Users\lukas\scoop\shims;C:\Users\lukas\AppData\Local\Microsoft\WindowsApps;C:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\bin GOCACHE=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\build-cache XGO_COMPILER_BIN=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\compile.exe]
2024-03-25 17:55:27 command dir: 
2024-03-25 17:55:27 command executable path: C:\installed\go1.22.1\bin\go.exe
2024-03-25 17:55:27 finished successfully
WAY29 commented 5 months ago

@WAY29 I have added a flag to log internal compile process, see a90c6ef

First, upgrade xgo:

cd xgo
git pull
go run ./script/build-release --local

Then, run xgo with --log-debug:

xgo test --log-debug -run TestMethodMock -v ./test

And check debug.log in your current directory. Debug log example:

2024-03-25 17:55:24 start: [C:\Users\lukas\AppData\Local\Temp\go-build2111748048\b001\exe\xgo.exe exec --log-debug go version]
2024-03-25 17:55:24 runtime.GOOS=windows
2024-03-25 17:55:24 runtime.GOARCH=amd64
2024-03-25 17:55:24 runtime.Version()=go1.22.1
2024-03-25 17:55:25 effective GOROOT: C:\installed\go1.22.1
2024-03-25 17:55:25 go version: go1.22.1
2024-03-25 17:55:25 instrument dir: C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a
2024-03-25 17:55:25 sync goroot C:\installed\go1.22.1 -> C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1
2024-03-25 17:55:25 patch compiler at: C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1
2024-03-25 17:55:26 setup dev dir: C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1
2024-03-25 17:55:27 compiler changed: false
2024-03-25 17:55:27 tool exec flags: -toolexec=C:\Users\lukas\.xgo\bin\exec_tool.exe --enable --
2024-03-25 17:55:27 command: [go version]
2024-03-25 17:55:27 command env: [ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\lukas\AppData\Roaming CHROME_CRASHPAD_PIPE_NAME=\\.\pipe\crashpad_7388_YDEVBNMAIHLMTUHG CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=DESKTOP-Q4TKH82 ComSpec=C:\Windows\system32\cmd.exe DriverData=C:\Windows\System32\Drivers\DriverData FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer FPS_BROWSER_USER_PROFILE_STRING=Default GOPATH=C:\Projects\gopath GOROOT=C:\installed\go1.22.1 HOMEDRIVE=C: HOMEPATH=\Users\lukas LOCALAPPDATA=C:\Users\lukas\AppData\Local LOGONSERVER=\\DESKTOP-Q4TKH82 NUMBER_OF_PROCESSORS=4 OneDrive=C:\Users\lukas\OneDrive ORIGINAL_XDG_CURRENT_DESKTOP=undefined OS=Windows_NT Path=C:\installed\go1.22.1\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\installed\go1.22.1\bin;C:\cygwin64\bin;C:\Users\lukas\.xgo\bin;C:\Projects\gopath\bin;C:\Projects\gopath\bin;C:\Users\lukas\scoop\shims;C:\Users\lukas\AppData\Local\Microsoft\WindowsApps;C:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\bin PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=9e0a ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PSModulePath=C:\Users\lukas\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules PUBLIC=C:\Users\Public SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\Windows TEMP=C:\Users\lukas\AppData\Local\Temp TMP=C:\Users\lukas\AppData\Local\Temp USERDOMAIN=DESKTOP-Q4TKH82 USERDOMAIN_ROAMINGPROFILE=DESKTOP-Q4TKH82 USERNAME=lukas USERPROFILE=C:\Users\lukas windir=C:\Windows TERM_PROGRAM=vscode TERM_PROGRAM_VERSION=1.87.2 LANG=en_US.UTF-8 COLORTERM=truecolor GIT_ASKPASS=c:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass.sh VSCODE_GIT_ASKPASS_NODE=C:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\Code.exe VSCODE_GIT_ASKPASS_EXTRA_ARGS= VSCODE_GIT_ASKPASS_MAIN=c:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass-main.js VSCODE_GIT_IPC_HANDLE=\\.\pipe\vscode-git-3c257e6a92-sock VSCODE_INJECTION=1 GOROOT=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1 PATH=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\go1.22.1\bin;C:\installed\go1.22.1\bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\installed\go1.22.1\bin;C:\cygwin64\bin;C:\Users\lukas\.xgo\bin;C:\Projects\gopath\bin;C:\Projects\gopath\bin;C:\Users\lukas\scoop\shims;C:\Users\lukas\AppData\Local\Microsoft\WindowsApps;C:\Users\lukas\AppData\Local\Programs\Microsoft VS Code\bin GOCACHE=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\build-cache XGO_COMPILER_BIN=C:\Users\lukas\.xgo\go-instrument-dev\go1.22.1_C_in_go_5dd13d4a\compile.exe]
2024-03-25 17:55:27 command dir: 
2024-03-25 17:55:27 command executable path: C:\installed\go1.22.1\bin\go.exe
2024-03-25 17:55:27 finished successfully

I try --log-debug but got same error without extra information image

xhd2015 commented 5 months ago

I see you are using sudo, can you run it without sudo?

WAY29 commented 5 months ago

I see you are using sudo, can you run it without sudo?

It got same error.

xhd2015 commented 5 months ago

And I'm curios that there is sudo for windows? Is it built in?

WAY29 commented 5 months ago

And I'm curios that there is sudo for windows? Is it built in?

no. I install it by scoop install busybox

xhd2015 commented 5 months ago

Is there any debug.log?

xhd2015 commented 5 months ago

Your shell is busy box? Maybe I can install that on my local machine and try to reproduce

WAY29 commented 5 months ago

Your shell is busy box? Maybe I can install that on my local machine and try to reproduce

No, It just a tool sets named busybox

WAY29 commented 5 months ago

Your shell is busy box? Maybe I can install that on my local machine and try to reproduce

Yes I found it:

2024-03-25 19:38:20 start: [C:\Users\admin\.xgo\bin\xgo.exe exec --log-debug go version]
2024-03-25 19:38:20 runtime.GOOS=windows
2024-03-25 19:38:20 runtime.GOARCH=amd64
2024-03-25 19:38:20 runtime.Version()=go1.20.5
2024-03-25 19:38:20 os exe suffix: .exe
2024-03-25 19:38:20 os force copy unsym: true
2024-03-25 19:38:20 effective GOROOT: C:\Users\admin\scoop\apps\go\current
2024-03-25 19:38:20 go version: go1.20.5
2024-03-25 19:38:20 instrument dir: C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880
2024-03-25 19:38:20 current revision: 1.0.6 a90c6ef098ea021488a507ab255b738b8712c3be_DEV_2024-03-25T11:38:16Z BUILD_103, last revision:  from file C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\xgo-revision.txt
2024-03-25 19:38:20 revision changed, reset C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880
2024-03-25 19:38:21 sync goroot C:\Users\admin\scoop\apps\go\current -> C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5
2024-03-25 19:38:22 patch compiler at: C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5
2024-03-25 19:38:22 finished with error: exit status 1
xhd2015 commented 5 months ago

Huh, maybe the line revision changed is an indicator.Normally it should take some seconds to finish. I guess your directory is not writable. Can you try to add a line into C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5\src\runtime\proc.go

xhd2015 commented 5 months ago

I know exactly which line caused the problem. I'll fix it.

It seems there were something blocking windows from using an existing go runtime.

Let me deliver a fix quickly.

xhd2015 commented 5 months ago

I know exactly which line caused the problem. I'll fix it.

It seems there were something blocking windows from using an existing go runtime.

Let me deliver a fix quickly.

It's because when patching the runtime code, xgo will invoke go to run $GOROOT/src/cmd/compile/internal/typecheck/mkbuiltin.go.

The implementation that causes this problem is the go being used is inside ~/.xgo/go-instrument/GOROOT, which is incomplete due to some reason.

The incompleteness is caused by this line:

dstFile := filepath.Join(goroot, "src", "runtime", "xgo_trap.go")
...
content = bytes.Replace(content, []byte("//go:build ignore\n"), nil, 1)

We are using \n, however on windows this should be \r\n.

So to fix this issue:

xhd2015 commented 5 months ago

@WAY29 Thanks for following on this issue, I've made another commit https://github.com/xhd2015/xgo/commit/c5d26155557db3f039bbf0c92c4da64e34143738

You can git pull and build it again, and run xgo exec go version to test again.

WAY29 commented 5 months ago

Got another error:

❯ xgo test --log-debug -run TestMethodMock -v .\mock_tcp_conn\             
# github.com/jtolds/gls
C:\coding\golang\src\gotest\__xgo_autogen_register_func_info.go:2:6: internal compiler error: LookupRuntime: can't find runtime.__xgo_trap
https://go.dev/issue/new
# github.com/agiledragon/gomonkey/v2/creflect
C:\coding\golang\src\gotest\__xgo_autogen_register_func_info.go:2:6: internal compiler error: LookupRuntime: can't find runtime.__xgo_trap

Please file a bug report including a short program that triggers the error.https://go.dev/issue/new
# github.com/xhd2015/xgo/runtime/functab
..\..\pkg\mod\github.com\xhd2015\xgo\runtime@v1.0.6\functab\functab.go:169:6: internal compiler error: LookupRuntime: can't find runtime.__xgo_retrieve_all_funcs_and_clear  

Please file a bug report including a short program that triggers the error.https://go.dev/issue/new
# github.com/smartystreets/assertions/internal/go-render/render
C:\coding\golang\src\gotest\__xgo_autogen_register_func_info.go:2:6: internal compiler error: LookupRuntime: can't find runtime.__xgo_trap

Please file a bug report including a short program that triggers the error.https://go.dev/issue/new
# github.com/smartystreets/assertions/internal/oglematchers
C:\coding\golang\src\gotest\__xgo_autogen_register_func_info.go:2:6: internal compiler error: LookupRuntime: can't find runtime.__xgo_trap

Please file a bug report including a short program that triggers the error.https://go.dev/issue/new
# golang.org/x/arch/x86/x86asm
C:\coding\golang\src\gotest\__xgo_autogen_register_func_info.go:2:6: internal compiler error: LookupRuntime: can't find runtime.__xgo_trap

Please file a bug report including a short program that triggers the error.https://go.dev/issue/new
# testing
C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5\src\sync\atomic\type.go:43:6: internal compiler error: LookupRuntime: can't find runtime.__xgo_get_test_starts

Please file a bug report including a short program that triggers the error.https://go.dev/issue/new
FAIL    gotest/mock_tcp_conn [build failed]
FAIL

debug log:

2024-03-25 20:41:07 start: [C:\Users\admin\.xgo\bin\xgo.exe test --log-debug -run TestMethodMock -v .\mock_tcp_conn\]
2024-03-25 20:41:07 runtime.GOOS=windows
2024-03-25 20:41:07 runtime.GOARCH=amd64
2024-03-25 20:41:07 runtime.Version()=go1.20.5
2024-03-25 20:41:07 os exe suffix: .exe
2024-03-25 20:41:07 os force copy unsym: true
2024-03-25 20:41:07 effective GOROOT: C:\Users\admin\scoop\apps\go\current
2024-03-25 20:41:07 go version: go1.20.5
2024-03-25 20:41:07 instrument dir: C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880
2024-03-25 20:41:07 current revision: 1.0.6 c5d26155557db3f039bbf0c92c4da64e34143738 BUILD_104, last revision: 1.0.6 c5d26155557db3f039bbf0c92c4da64e34143738 BUILD_104 from file C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\xgo-revision.txt
2024-03-25 20:41:07 setup dev dir: C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5
2024-03-25 20:41:08 compiler changed: false
2024-03-25 20:41:08 tool exec flags: -toolexec=C:\Users\admin\.xgo\bin\exec_tool.exe --enable --
2024-03-25 20:41:08 command: C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5\bin\go [test -toolexec=C:\Users\admin\.xgo\bin\exec_tool.exe --enable -- -v -run TestMethodMock .\mock_tcp_conn\]
2024-03-25 20:41:08 command env: [ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\admin\AppData\Roaming asl.log=Destination=file CHROME_CRASHPAD_PIPE_NAME=\\.\pipe\crashpad_11028_ETUTRCPZWWELHHDR CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=LONGLONE-PC ComSpec=C:\Windows\system32\cmd.exe CPLUS_INCLUDE_PATH=C:\Users\admin\scoop\apps\gcc\current\include C_INCLUDE_PATH=C:\Users\admin\scoop\apps\gcc\current\include DriverData=C:\Windows\System32\Drivers\DriverData GIT_INSTALL_ROOT=C:\Users\admin\scoop\apps\git\current HOMEDRIVE=C: HOMEPATH=\Users\admin https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 JAVA_HOME=C:\Users\admin\scoop\apps\openjdk11\current LOCALAPPDATA=C:\Users\admin\AppData\Local LOGONSERVER=\\LONGLONE-PC NODE_PATH=C:\Users\admin\scoop\apps\yarn\current\global\node_modules NUMBER_OF_PROCESSORS=24 OneDrive=C:\Users\admin\OneDrive ORIGINAL_XDG_CURRENT_DESKTOP=undefined OS=Windows_NT Path=C:\Program Files\PowerShell\7;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Applications\bandizip\Bandizip;C:\Program Files\Google\Chrome\Application;C:\Program Files\dotnet\;C:\Program Files (x86)\ZeroTier\One\;C:\Program Files\PowerShell\7\;C:\Program Files\Tailscale\;C:\Users\admin\scoop\apps\yarn\current\global\node_modules\.bin;C:\Users\admin\scoop\apps\yarn\current\bin;C:\Users\admin\scoop\apps\nodejs16\current;C:\Users\admin\scoop\apps\nodejs16\current\bin;C:\Users\admin\scoop\apps\python39\current\Scripts;C:\Users\admin\scoop\apps\python39\current;C:\Users\admin\scoop\apps\openjdk11\current\bin;C:\coding\golang\bin;C:\Users\admin\scoop\apps\gcc\current\bin;C:\Users\admin\scoop\shims;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;C:\Applications\Microsoft VS Code\bin;C:\Users\admin\yakit-projects\yak-engine;C:\tools;c:\users\admin\.local\bin;C:\Users\admin\.xgo\bin; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL POWERSHELL_DISTRIBUTION_CHANNEL=MSI:Windows 10 Pro PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 183 Stepping 1, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=b701 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PSModulePath=C:\Users\admin\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules PUBLIC=C:\Users\Public PYTHONPATH=c:\users\admin\scoop\apps\python39\current\lib\site-packages\pdm\pep582 RELOADEDIIMODS=C:\Users\admin\Desktop\Reloaded-II\Mods SESSIONNAME=Console STARSHIP_SESSION_KEY=PC04WbasOG38Mrfk STARSHIP_SHELL=pwsh SystemDrive=C: SystemRoot=C:\Windows TEMP=C:\Users\admin\AppData\Local\Temp TMP=C:\Users\admin\AppData\Local\Temp USERDOMAIN=LONGLONE-PC USERDOMAIN_ROAMINGPROFILE=LONGLONE-PC USERNAME=admin USERPROFILE=C:\Users\admin VIRTUAL_ENV_DISABLE_PROMPT=1 windir=C:\Windows YAKIT_HOME=C:\Applications\Yakit\yakit-projects ZES_ENABLE_SYSMAN=1 TERM_PROGRAM=vscode TERM_PROGRAM_VERSION=1.87.2 LANG=zh_CN.UTF-8 COLORTERM=truecolor GIT_ASKPASS=c:\Applications\Microsoft VS Code\resources\app\extensions\git\dist\askpass.sh VSCODE_GIT_ASKPASS_NODE=C:\Applications\Microsoft VS Code\Code.exe VSCODE_GIT_ASKPASS_EXTRA_ARGS= VSCODE_GIT_ASKPASS_MAIN=c:\Applications\Microsoft VS Code\resources\app\extensions\git\dist\askpass-main.js VSCODE_GIT_IPC_HANDLE=\\.\pipe\vscode-git-e52b05db31-sock VSCODE_INJECTION=1 GOROOT=C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5 PATH=C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5\bin;C:\Program Files\PowerShell\7;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Applications\bandizip\Bandizip;C:\Program Files\Google\Chrome\Application;C:\Program Files\dotnet\;C:\Program Files (x86)\ZeroTier\One\;C:\Program Files\PowerShell\7\;C:\Program Files\Tailscale\;C:\Users\admin\scoop\apps\yarn\current\global\node_modules\.bin;C:\Users\admin\scoop\apps\yarn\current\bin;C:\Users\admin\scoop\apps\nodejs16\current;C:\Users\admin\scoop\apps\nodejs16\current\bin;C:\Users\admin\scoop\apps\python39\current\Scripts;C:\Users\admin\scoop\apps\python39\current;C:\Users\admin\scoop\apps\openjdk11\current\bin;C:\coding\golang\bin;C:\Users\admin\scoop\apps\gcc\current\bin;C:\Users\admin\scoop\shims;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;C:\Applications\Microsoft VS Code\bin;C:\Users\admin\yakit-projects\yak-engine;C:\tools;c:\users\admin\.local\bin;C:\Users\admin\.xgo\bin; GOCACHE=C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\build-cache XGO_COMPILER_BIN=C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\compile.exe]
2024-03-25 20:41:08 command dir: 
2024-03-25 20:41:08 command executable path: C:\Users\admin\.xgo\go-instrument\go1.20.5_C_Us_ad_sc_ap_go_cu_90061880\go1.20.5\bin\go
2024-03-25 20:41:12 finished with error: 
xhd2015 commented 5 months ago

Lol 😂 another fix: https://github.com/xhd2015/xgo/commit/42bc8080ae3bca80a1f32b5d60bead4a55ea942c

Please git pull and try again

WAY29 commented 5 months ago

Work well.

xhd2015 commented 5 months ago

Thanks for your patience, the bugs found were so meaningful haha.