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

@@ -64,11 +64,12 @@ func needLLFile(mode Mode) bool {
}
type Config struct {
BinPath string
AppExt string // ".exe" on Windows, empty on Unix
OutFile string // only valid for ModeBuild when len(pkgs) == 1
RunArgs []string // only valid for ModeRun
Mode Mode
BinPath string
AppExt string // ".exe" on Windows, empty on Unix
OutFile string // only valid for ModeBuild when len(pkgs) == 1
RunArgs []string // only valid for ModeRun
GenExpect bool // only valid for ModeCmpTest
Mode Mode
}
func NewDefaultConf(mode Mode) *Config {
@@ -462,7 +463,7 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, llFiles
os.Exit(s.ExitCode())
}
case ModeCmpTest:
cmpTest("", pkgPath, app, conf.RunArgs)
cmpTest(filepath.Dir(pkg.GoFiles[0]), pkgPath, app, conf.GenExpect, conf.RunArgs)
}
return
}