cmptest: add support for comparison with llgo.expect files

Fixes #671
This commit is contained in:
Aofei Sheng
2024-08-12 13:43:44 +08:00
parent 321766fd46
commit 200fe07473
3 changed files with 49 additions and 11 deletions

View File

@@ -37,8 +37,8 @@ var Cmd = &base.Command{
// 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)",
UsageLine: "llgo cmptest [-genexpect] [build flags] package [arguments...]",
Short: "Compile and run with llgo, compare result (stdout/stderr/exitcode) with go or llgo.expect; generate llgo.expect file if -genexpect is specified",
}
func init() {
@@ -55,9 +55,13 @@ func runCmpTest(cmd *base.Command, args []string) {
}
func runCmdEx(cmd *base.Command, args []string, mode build.Mode) {
conf := build.NewDefaultConf(mode)
if mode == build.ModeCmpTest && len(args) > 0 && args[0] == "-genexpect" {
conf.GenExpect = true
args = args[1:]
}
args, runArgs, err := parseRunArgs(args)
check(err)
conf := build.NewDefaultConf(mode)
conf.RunArgs = runArgs
build.Do(args, conf)
}