From cfef31bc4a9643201c3a89446016a928e4e2080e Mon Sep 17 00:00:00 2001 From: nighca Date: Wed, 28 Aug 2024 17:31:11 +0800 Subject: [PATCH] add case for package-patch issue --- gopbuild/build_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gopbuild/build_test.go b/gopbuild/build_test.go index 27a692bd..6010d59f 100644 --- a/gopbuild/build_test.go +++ b/gopbuild/build_test.go @@ -501,3 +501,26 @@ func main() { t.Fatal("build error:\n", string(data)) } } + +func TestPackagePatchRun(t *testing.T) { + ctx := igop.NewContext(0) + RegisterPackagePatch(ctx, "github.com/qiniu/x/gsh", `package gsh +type Point struct { + X int + Y int +}`) + src := ` +println 1 +` + data, err := BuildFile(ctx, "main.gsh", src) + if err != nil { + t.Fatal(err) + } + code, err := ctx.RunFile("main.go", data, nil) + if err != nil { + t.Fatal("RunFile error:", err) + } + if code != 0 { + t.Fatal("run error:", code) + } +}