go/callgraph/vta: move test code to testdata/src

This is a more common practice.

Change-Id: I45e37219a4d813a75fb239f0ce309489abe3616b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380794
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Guodong Li <guodongli@google.com>
Reviewed-by: Tim King <taking@google.com>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
This commit is contained in:
Zvonimir Pavlinovic 2022-01-25 10:18:23 -08:00
parent fe74b5f080
commit 135791db47
32 changed files with 35 additions and 35 deletions

View File

@ -18,15 +18,15 @@ import (
func TestNodeInterface(t *testing.T) {
// Since ssa package does not allow explicit creation of ssa
// values, we use the values from the program testdata/simple.go:
// values, we use the values from the program testdata/src/simple.go:
// - basic type int
// - struct X with two int fields a and b
// - global variable "gl"
// - "main" function and its
// - first register instruction t0 := *gl
prog, _, err := testProg("testdata/simple.go")
prog, _, err := testProg("testdata/src/simple.go")
if err != nil {
t.Fatalf("couldn't load testdata/simple.go program: %v", err)
t.Fatalf("couldn't load testdata/src/simple.go program: %v", err)
}
pkg := prog.AllPackages()[0]
@ -78,9 +78,9 @@ func TestNodeInterface(t *testing.T) {
func TestVtaGraph(t *testing.T) {
// Get the basic type int from a real program.
prog, _, err := testProg("testdata/simple.go")
prog, _, err := testProg("testdata/src/simple.go")
if err != nil {
t.Fatalf("couldn't load testdata/simple.go program: %v", err)
t.Fatalf("couldn't load testdata/src/simple.go program: %v", err)
}
glPtrType, ok := prog.AllPackages()[0].Var("gl").Type().(*types.Pointer)
@ -170,25 +170,25 @@ func subGraph(g1, g2 []string) bool {
func TestVTAGraphConstruction(t *testing.T) {
for _, file := range []string{
"testdata/store.go",
"testdata/phi.go",
"testdata/type_conversions.go",
"testdata/type_assertions.go",
"testdata/fields.go",
"testdata/node_uniqueness.go",
"testdata/store_load_alias.go",
"testdata/phi_alias.go",
"testdata/channels.go",
"testdata/select.go",
"testdata/stores_arrays.go",
"testdata/maps.go",
"testdata/ranges.go",
"testdata/closures.go",
"testdata/function_alias.go",
"testdata/static_calls.go",
"testdata/dynamic_calls.go",
"testdata/returns.go",
"testdata/panic.go",
"testdata/src/store.go",
"testdata/src/phi.go",
"testdata/src/type_conversions.go",
"testdata/src/type_assertions.go",
"testdata/src/fields.go",
"testdata/src/node_uniqueness.go",
"testdata/src/store_load_alias.go",
"testdata/src/phi_alias.go",
"testdata/src/channels.go",
"testdata/src/select.go",
"testdata/src/stores_arrays.go",
"testdata/src/maps.go",
"testdata/src/ranges.go",
"testdata/src/closures.go",
"testdata/src/function_alias.go",
"testdata/src/static_calls.go",
"testdata/src/dynamic_calls.go",
"testdata/src/returns.go",
"testdata/src/panic.go",
} {
t.Run(file, func(t *testing.T) {
prog, want, err := testProg(file)

View File

@ -15,7 +15,7 @@ import (
)
func TestVTACallGraphGo117(t *testing.T) {
file := "testdata/go117.go"
file := "testdata/src/go117.go"
prog, want, err := testProg(file)
if err != nil {
t.Fatalf("couldn't load test file '%s': %s", file, err)

View File

@ -14,13 +14,13 @@ import (
func TestVTACallGraph(t *testing.T) {
for _, file := range []string{
"testdata/callgraph_static.go",
"testdata/callgraph_ho.go",
"testdata/callgraph_interfaces.go",
"testdata/callgraph_pointers.go",
"testdata/callgraph_collections.go",
"testdata/callgraph_fields.go",
"testdata/callgraph_field_funcs.go",
"testdata/src/callgraph_static.go",
"testdata/src/callgraph_ho.go",
"testdata/src/callgraph_interfaces.go",
"testdata/src/callgraph_pointers.go",
"testdata/src/callgraph_collections.go",
"testdata/src/callgraph_fields.go",
"testdata/src/callgraph_field_funcs.go",
} {
t.Run(file, func(t *testing.T) {
prog, want, err := testProg(file)
@ -43,12 +43,12 @@ func TestVTACallGraph(t *testing.T) {
// enabled by having an arbitrary function set as input to CallGraph
// instead of the whole program (i.e., ssautil.AllFunctions(prog)).
func TestVTAProgVsFuncSet(t *testing.T) {
prog, want, err := testProg("testdata/callgraph_nested_ptr.go")
prog, want, err := testProg("testdata/src/callgraph_nested_ptr.go")
if err != nil {
t.Fatalf("couldn't load test `testdata/callgraph_nested_ptr.go`: %s", err)
t.Fatalf("couldn't load test `testdata/src/callgraph_nested_ptr.go`: %s", err)
}
if len(want) == 0 {
t.Fatal("couldn't find want in `testdata/callgraph_nested_ptr.go`")
t.Fatal("couldn't find want in `testdata/src/callgraph_nested_ptr.go`")
}
allFuncs := ssautil.AllFunctions(prog)