Files
llgo/cmd/internal/test/test.go

39 lines
713 B
Go
Raw Normal View History

2024-12-31 10:53:38 +08:00
package test
import (
"fmt"
"os"
2025-04-03 15:52:18 +08:00
"github.com/goplus/llgo/cmd/internal/base"
2025-04-18 12:54:04 +08:00
"github.com/goplus/llgo/cmd/internal/flags"
2025-04-03 15:52:18 +08:00
"github.com/goplus/llgo/internal/build"
2024-12-31 10:53:38 +08:00
)
// llgo test
var Cmd = &base.Command{
UsageLine: "llgo test [build flags] package [arguments...]",
Short: "Compile and run Go test",
}
func init() {
Cmd.Run = runCmd
2025-04-18 12:54:04 +08:00
flags.AddBuildFlags(&Cmd.Flag)
2024-12-31 10:53:38 +08:00
}
func runCmd(cmd *base.Command, args []string) {
2025-04-18 12:54:04 +08:00
if err := cmd.Flag.Parse(args); err != nil {
panic(err)
}
conf := build.NewDefaultConf(build.ModeTest)
conf.Tags = flags.Tags
conf.Verbose = flags.Verbose
2024-12-31 10:53:38 +08:00
2025-04-18 12:54:04 +08:00
args = cmd.Flag.Args()
2024-12-31 10:53:38 +08:00
_, err := build.Do(args, conf)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}