From df7e8b2e64b2a6ca9e57198d75a1275c491b465c Mon Sep 17 00:00:00 2001 From: visualfc Date: Wed, 30 Oct 2024 10:18:58 +0800 Subject: [PATCH] cl/cltest: TestCompileEx check debug flag --- cl/cltest/cltest.go | 10 +++++++--- cl/compile_test.go | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cl/cltest/cltest.go b/cl/cltest/cltest.go index bd0b0178..821f51a8 100644 --- a/cl/cltest/cltest.go +++ b/cl/cltest/cltest.go @@ -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) } } 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() fset := token.NewFileSet() 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 pkg := types.NewPackage(name, name) imp := packages.NewImporter(fset) + mode := ssa.SanityCheckFunctions | ssa.InstantiateGenerics + if dbg { + mode |= ssa.GlobalDebug + } 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 { t.Fatal("BuildPackage failed:", err) } diff --git a/cl/compile_test.go b/cl/compile_test.go index 7bc61564..47f1773c 100644 --- a/cl/compile_test.go +++ b/cl/compile_test.go @@ -26,7 +26,7 @@ import ( func testCompile(t *testing.T, src, expected string) { t.Helper() - cltest.TestCompileEx(t, src, "foo.go", expected) + cltest.TestCompileEx(t, src, "foo.go", expected, false) } func TestFromTestgo(t *testing.T) {