cl/cltest: TestCompileEx check debug flag
This commit is contained in:
@@ -144,11 +144,11 @@ func testFrom(t *testing.T, pkgDir, sel string, byLLGen bool) {
|
|||||||
t.Fatalf("\n==> got:\n%s\n==> expected:\n%s\n", v, expected)
|
t.Fatalf("\n==> got:\n%s\n==> expected:\n%s\n", v, expected)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TestCompileEx(t, nil, in, expected)
|
TestCompileEx(t, nil, in, expected, dbg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompileEx(t *testing.T, src any, fname, expected string) {
|
func TestCompileEx(t *testing.T, src any, fname, expected string, dbg bool) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
fset := token.NewFileSet()
|
fset := token.NewFileSet()
|
||||||
f, err := parser.ParseFile(fset, fname, src, parser.ParseComments)
|
f, err := parser.ParseFile(fset, fname, src, parser.ParseComments)
|
||||||
@@ -159,8 +159,12 @@ func TestCompileEx(t *testing.T, src any, fname, expected string) {
|
|||||||
name := f.Name.Name
|
name := f.Name.Name
|
||||||
pkg := types.NewPackage(name, name)
|
pkg := types.NewPackage(name, name)
|
||||||
imp := packages.NewImporter(fset)
|
imp := packages.NewImporter(fset)
|
||||||
|
mode := ssa.SanityCheckFunctions | ssa.InstantiateGenerics
|
||||||
|
if dbg {
|
||||||
|
mode |= ssa.GlobalDebug
|
||||||
|
}
|
||||||
foo, _, err := ssautil.BuildPackage(
|
foo, _, err := ssautil.BuildPackage(
|
||||||
&types.Config{Importer: imp}, fset, pkg, files, ssa.SanityCheckFunctions|ssa.InstantiateGenerics|ssa.GlobalDebug)
|
&types.Config{Importer: imp}, fset, pkg, files, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("BuildPackage failed:", err)
|
t.Fatal("BuildPackage failed:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
func testCompile(t *testing.T, src, expected string) {
|
func testCompile(t *testing.T, src, expected string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
cltest.TestCompileEx(t, src, "foo.go", expected)
|
cltest.TestCompileEx(t, src, "foo.go", expected, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFromTestgo(t *testing.T) {
|
func TestFromTestgo(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user