build: make llgen, cltest, gentests call build.Do
This commit is contained in:
@@ -50,7 +50,7 @@ func InitDebug() {
|
||||
llssa.SetDebug(llssa.DbgFlagAll)
|
||||
}
|
||||
|
||||
func FromDir(t *testing.T, sel, relDir string, byLLGen bool) {
|
||||
func FromDir(t *testing.T, sel, relDir string) {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal("Getwd failed:", err)
|
||||
@@ -66,7 +66,7 @@ func FromDir(t *testing.T, sel, relDir string, byLLGen bool) {
|
||||
continue
|
||||
}
|
||||
t.Run(name, func(t *testing.T) {
|
||||
testFrom(t, dir+"/"+name, sel, byLLGen)
|
||||
testFrom(t, dir+"/"+name, sel)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -121,12 +121,11 @@ func isDbgSymEnabled(flagsFile string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func testFrom(t *testing.T, pkgDir, sel string, byLLGen bool) {
|
||||
func testFrom(t *testing.T, pkgDir, sel string) {
|
||||
if sel != "" && !strings.Contains(pkgDir, sel) {
|
||||
return
|
||||
}
|
||||
log.Println("Parsing", pkgDir)
|
||||
in := pkgDir + "/in.go"
|
||||
out := pkgDir + "/out.ll"
|
||||
dbg := isDbgSymEnabled(pkgDir + "/flags.txt")
|
||||
if dbg {
|
||||
@@ -139,12 +138,8 @@ func testFrom(t *testing.T, pkgDir, sel string, byLLGen bool) {
|
||||
t.Fatal("ReadFile failed:", err)
|
||||
}
|
||||
expected := string(b)
|
||||
if byLLGen {
|
||||
if v := llgen.GenFrom(in); v != expected && expected != ";" { // expected == ";" means skipping out.ll
|
||||
t.Fatalf("\n==> got:\n%s\n==> expected:\n%s\n", v, expected)
|
||||
}
|
||||
} else {
|
||||
TestCompileEx(t, nil, in, expected, dbg)
|
||||
if v := llgen.GenFrom(pkgDir); v != expected && expected != ";" { // expected == ";" means skipping out.ll
|
||||
t.Fatalf("\n==> got:\n%s\n==> expected:\n%s\n", v, expected)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,34 +30,37 @@ func testCompile(t *testing.T, src, expected string) {
|
||||
}
|
||||
|
||||
func TestFromTestgo(t *testing.T) {
|
||||
cltest.FromDir(t, "", "./_testgo", false)
|
||||
cltest.FromDir(t, "", "./_testgo")
|
||||
}
|
||||
|
||||
func TestFromTestpy(t *testing.T) {
|
||||
cltest.FromDir(t, "", "./_testpy", false)
|
||||
cltest.FromDir(t, "", "./_testpy")
|
||||
}
|
||||
|
||||
func TestFromTestlibgo(t *testing.T) {
|
||||
cltest.FromDir(t, "", "./_testlibgo", true)
|
||||
cltest.FromDir(t, "", "./_testlibgo")
|
||||
}
|
||||
|
||||
func TestFromTestlibc(t *testing.T) {
|
||||
cltest.FromDir(t, "", "./_testlibc", true)
|
||||
cltest.FromDir(t, "", "./_testlibc")
|
||||
}
|
||||
|
||||
func TestFromTestrt(t *testing.T) {
|
||||
cl.SetDebug(cl.DbgFlagAll)
|
||||
cltest.FromDir(t, "", "./_testrt", true)
|
||||
cltest.FromDir(t, "", "./_testrt")
|
||||
cl.SetDebug(0)
|
||||
}
|
||||
|
||||
func TestFromTestdata(t *testing.T) {
|
||||
cltest.FromDir(t, "", "./_testdata", false)
|
||||
cltest.FromDir(t, "", "./_testdata")
|
||||
}
|
||||
|
||||
func TestGoPkgMath(t *testing.T) {
|
||||
conf := build.NewDefaultConf(build.ModeInstall)
|
||||
build.Do([]string{"math"}, conf)
|
||||
_, err := build.Do([]string{"math"}, conf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVar(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user