Files
llgo/cmd/internal/test/test.go
Li Jie daf0d7e56e feat(cmd): enable -target parameter for build, run, and test commands
- Update build command: llgo build -target platform
- Update run command: llgo run -target platform
- Update test command: llgo test -target platform
- Wire target flag to build configuration
- Update usage documentation for new parameter

Examples:
- llgo build -target rp2040 ./firmware
- llgo run -target wasi ./main.go
- llgo test -target cortex-m ./tests

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 20:16:29 +08:00

41 lines
757 B
Go

package test
import (
"fmt"
"os"
"github.com/goplus/llgo/cmd/internal/base"
"github.com/goplus/llgo/cmd/internal/flags"
"github.com/goplus/llgo/internal/build"
)
// llgo test
var Cmd = &base.Command{
UsageLine: "llgo test [-target platform] [build flags] package [arguments...]",
Short: "Compile and run Go test",
}
func init() {
Cmd.Run = runCmd
flags.AddBuildFlags(&Cmd.Flag)
}
func runCmd(cmd *base.Command, args []string) {
if err := cmd.Flag.Parse(args); err != nil {
return
}
conf := build.NewDefaultConf(build.ModeTest)
conf.Tags = flags.Tags
conf.Verbose = flags.Verbose
conf.Target = flags.Target
args = cmd.Flag.Args()
_, err := build.Do(args, conf)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}