llgo cmptest (#391)

This commit is contained in:
xushiwei
2024-06-23 00:48:20 +08:00
parent 24d345a970
commit cd6d4021b1
9 changed files with 112 additions and 44 deletions

View File

@@ -35,14 +35,29 @@ var Cmd = &base.Command{
Short: "Compile and run Go program",
}
// llgo cmptest
var CmpTestCmd = &base.Command{
UsageLine: "llgo cmptest [build flags] package [arguments...]",
Short: "Compile programs by llgo and go, run them and do comparative tests (stdout/stderr/exitcode)",
}
func init() {
Cmd.Run = runCmd
CmpTestCmd.Run = runCmpTest
}
func runCmd(cmd *base.Command, args []string) {
runCmdEx(cmd, args, build.ModeRun)
}
func runCmpTest(cmd *base.Command, args []string) {
runCmdEx(cmd, args, build.ModeCmpTest)
}
func runCmdEx(cmd *base.Command, args []string, mode build.Mode) {
args, runArgs, err := parseRunArgs(args)
check(err)
conf := build.NewDefaultConf(build.ModeRun)
conf := build.NewDefaultConf(mode)
conf.RunArgs = runArgs
build.Do(args, conf)
}

View File

@@ -43,6 +43,7 @@ func init() {
build.Cmd,
install.Cmd,
run.Cmd,
run.CmpTestCmd,
clean.Cmd,
}
}