From 99b71d5da1dbcceb19921bb32006b71b844ffce0 Mon Sep 17 00:00:00 2001 From: xhd2015 Date: Fri, 7 Jun 2024 08:31:49 +0800 Subject: [PATCH] test https://github.com/xhd2015/xgo/issues/194 --- .github/workflows/custom.yml | 67 ++++++++++++++++++++++++ cmd/xgo/runtime_gen/core/version.go | 4 +- cmd/xgo/version.go | 4 +- runtime/core/version.go | 4 +- runtime/test/issue_194/demo/go.mod | 27 ++++++++++ runtime/test/issue_194/demo/go.sum | 51 ++++++++++++++++++ runtime/test/issue_194/demo/main.go | 13 +++++ runtime/test/issue_194/demo/main_test.go | 8 +++ 8 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/custom.yml create mode 100644 runtime/test/issue_194/demo/go.mod create mode 100644 runtime/test/issue_194/demo/go.sum create mode 100644 runtime/test/issue_194/demo/main.go create mode 100644 runtime/test/issue_194/demo/main_test.go diff --git a/.github/workflows/custom.yml b/.github/workflows/custom.yml new file mode 100644 index 00000000..028a0b24 --- /dev/null +++ b/.github/workflows/custom.yml @@ -0,0 +1,67 @@ +name: Custom Test + +on: + push: + branches: [ "test-issue-194" ] + workflow_dispatch: + inputs: + dummy: + default: nothing + + # 'gin-gonic/gin' ok + # 'fatedier/frp' cannot pass even with go? need to verify + # + # NOTE: use serially job to avoid 'Job Cancelled' which could + # possible be due to memory exhaust +jobs: + + test-with-xgo: + runs-on: macos-latest + timeout-minutes: 360 + steps: + - uses: actions/checkout@v4 + with: + path: xgo + + - name: Prepare Utility Scripts + run: | + cat > util.sh <<'EOF' + function record_exit_code { + local exit_code=$? + echo "exit code: $exit_code" + echo "$exit_code" > test-exit-code.txt + } + trap 'record_exit_code' EXIT + EOF + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + + - name: Install Xgo Locally + run: | + cd xgo + go install ./cmd/xgo + xgo exec --reset-instrument --log-debug go version + xgo revision + + - name: Dep check + run: | + go install github.com/xhd2015/go-inspect/cmd/depcheck@latest + cd xgo/runtime/test/issue_194 + depcheck ./ + + - name: Test with go + continue-on-error: true + run: | + source util.sh + cd xgo/runtime/test/issue_194/demo + go test -v -run TestUserHandler_CreateUser + + - name: Test with xgo + continue-on-error: true + run: | + source util.sh + cd xgo/runtime/test/issue_194/demo + xgo test -v -run TestUserHandler_CreateUser \ No newline at end of file diff --git a/cmd/xgo/runtime_gen/core/version.go b/cmd/xgo/runtime_gen/core/version.go index f6ff5368..d0e6a2f7 100755 --- a/cmd/xgo/runtime_gen/core/version.go +++ b/cmd/xgo/runtime_gen/core/version.go @@ -7,8 +7,8 @@ import ( ) const VERSION = "1.0.39" -const REVISION = "b2c3ae1e20700a8710d719b492b6db9e60fc4800+1" -const NUMBER = 263 +const REVISION = "ceb96b726f89731a8f2bda8239af7c1810e44294+1" +const NUMBER = 264 // these fields will be filled by compiler const XGO_VERSION = "" diff --git a/cmd/xgo/version.go b/cmd/xgo/version.go index 5f1ececb..d618813f 100644 --- a/cmd/xgo/version.go +++ b/cmd/xgo/version.go @@ -3,8 +3,8 @@ package main import "fmt" const VERSION = "1.0.39" -const REVISION = "b2c3ae1e20700a8710d719b492b6db9e60fc4800+1" -const NUMBER = 263 +const REVISION = "ceb96b726f89731a8f2bda8239af7c1810e44294+1" +const NUMBER = 264 func getRevision() string { revSuffix := "" diff --git a/runtime/core/version.go b/runtime/core/version.go index f6ff5368..d0e6a2f7 100644 --- a/runtime/core/version.go +++ b/runtime/core/version.go @@ -7,8 +7,8 @@ import ( ) const VERSION = "1.0.39" -const REVISION = "b2c3ae1e20700a8710d719b492b6db9e60fc4800+1" -const NUMBER = 263 +const REVISION = "ceb96b726f89731a8f2bda8239af7c1810e44294+1" +const NUMBER = 264 // these fields will be filled by compiler const XGO_VERSION = "" diff --git a/runtime/test/issue_194/demo/go.mod b/runtime/test/issue_194/demo/go.mod new file mode 100644 index 00000000..1ddb7f5a --- /dev/null +++ b/runtime/test/issue_194/demo/go.mod @@ -0,0 +1,27 @@ +module test + +go 1.21.7 + +require ( + github.com/bytedance/sonic v1.11.8 + github.com/julienschmidt/httprouter v1.3.0 + github.com/stretchr/testify v1.9.0 + github.com/xhd2015/xgo/runtime v1.0.39 + gorm.io/driver/mysql v1.5.6 + gorm.io/gorm v1.25.10 +) + +require ( + github.com/bytedance/sonic/loader v0.1.1 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-sql-driver/mysql v1.7.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/klauspost/cpuid/v2 v2.0.9 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/runtime/test/issue_194/demo/go.sum b/runtime/test/issue_194/demo/go.sum new file mode 100644 index 00000000..9c22e383 --- /dev/null +++ b/runtime/test/issue_194/demo/go.sum @@ -0,0 +1,51 @@ +github.com/bytedance/sonic v1.11.8 h1:Zw/j1KfiS+OYTi9lyB3bb0CFxPJVkM17k1wyDG32LRA= +github.com/bytedance/sonic v1.11.8/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= +github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/xhd2015/xgo/runtime v1.0.39 h1:Uudjr5VGjlvD4gDIOznRR+pteDVNlr6qOHHcZMzYZbA= +github.com/xhd2015/xgo/runtime v1.0.39/go.mod h1:9GBQ2SzJCzpD3T+HRN+2C0TUOGv7qIz4s0mad1xJ8Jo= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8= +gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= +gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s= +gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/runtime/test/issue_194/demo/main.go b/runtime/test/issue_194/demo/main.go new file mode 100644 index 00000000..fd2aa6b2 --- /dev/null +++ b/runtime/test/issue_194/demo/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "github.com/bytedance/sonic" +) + +func main() { + unmarshal(nil, nil) +} + +func unmarshal(body []byte, u interface{}) { + sonic.Unmarshal(body, u) +} diff --git a/runtime/test/issue_194/demo/main_test.go b/runtime/test/issue_194/demo/main_test.go new file mode 100644 index 00000000..d367d25e --- /dev/null +++ b/runtime/test/issue_194/demo/main_test.go @@ -0,0 +1,8 @@ +package main + +import ( + "testing" +) + +func TestUnmarshal(t *testing.T) { +}