compiler: add go test command

This commit is contained in:
Li Jie
2024-12-31 10:53:38 +08:00
parent 6b11c100ba
commit 946f304bb2
13 changed files with 127 additions and 17 deletions

View File

@@ -0,0 +1,33 @@
package test
import (
"fmt"
"os"
"github.com/goplus/llgo/compiler/cmd/internal/base"
"github.com/goplus/llgo/compiler/internal/build"
)
// llgo test
var Cmd = &base.Command{
UsageLine: "llgo test [build flags] package [arguments...]",
Short: "Compile and run Go test",
}
func init() {
Cmd.Run = runCmd
}
func runCmd(cmd *base.Command, args []string) {
runCmdEx(cmd, args, build.ModeRun)
}
func runCmdEx(_ *base.Command, args []string, mode build.Mode) {
conf := build.NewDefaultConf(mode)
conf.Mode = build.ModeTest
_, err := build.Do(args, conf)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}