aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/moricho/tparallel/testmap.go
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2025-01-22 16:07:17 +0100
committerTaras Madan <tarasmadan@google.com>2025-01-23 10:42:36 +0000
commit7b4377ad9d8a7205416df8d6217ef2b010f89481 (patch)
treee6fec4fd12ff807a16d847923f501075bf71d16c /vendor/github.com/moricho/tparallel/testmap.go
parent475a4c203afb8b7d3af51c4fd32bb170ff32a45e (diff)
vendor: delete
Diffstat (limited to 'vendor/github.com/moricho/tparallel/testmap.go')
-rw-r--r--vendor/github.com/moricho/tparallel/testmap.go67
1 files changed, 0 insertions, 67 deletions
diff --git a/vendor/github.com/moricho/tparallel/testmap.go b/vendor/github.com/moricho/tparallel/testmap.go
deleted file mode 100644
index fd6a3b432..000000000
--- a/vendor/github.com/moricho/tparallel/testmap.go
+++ /dev/null
@@ -1,67 +0,0 @@
-package tparallel
-
-import (
- "go/types"
- "strings"
-
- "github.com/gostaticanalysis/analysisutil"
- "golang.org/x/tools/go/analysis/passes/buildssa"
- "golang.org/x/tools/go/ssa"
-
- "github.com/moricho/tparallel/pkg/ssainstr"
-)
-
-// getTestMap gets a set of a top-level test and its sub-tests
-func getTestMap(ssaanalyzer *buildssa.SSA, testTyp types.Type) map[*ssa.Function][]*ssa.Function {
- testMap := map[*ssa.Function][]*ssa.Function{}
-
- trun := analysisutil.MethodOf(testTyp, "Run")
- for _, f := range ssaanalyzer.SrcFuncs {
- if !strings.HasPrefix(f.Name(), "Test") || !(f.Parent() == (*ssa.Function)(nil)) {
- continue
- }
- testMap[f] = []*ssa.Function{}
- for _, block := range f.Blocks {
- for _, instr := range block.Instrs {
- called := analysisutil.Called(instr, nil, trun)
-
- if !called && ssainstr.HasArgs(instr, types.NewPointer(testTyp)) {
- if instrs, ok := ssainstr.LookupCalled(instr, trun); ok {
- for _, v := range instrs {
- testMap[f] = appendTestMap(testMap[f], v)
- }
- }
- } else if called {
- testMap[f] = appendTestMap(testMap[f], instr)
- }
- }
- }
- }
-
- return testMap
-}
-
-// appendTestMap converts ssa.Instruction to ssa.Function and append it to a given sub-test slice
-func appendTestMap(subtests []*ssa.Function, instr ssa.Instruction) []*ssa.Function {
- call, ok := instr.(ssa.CallInstruction)
- if !ok {
- return subtests
- }
-
- ssaCall := call.Value()
- if ssaCall == nil {
- return subtests
- }
-
- for _, arg := range ssaCall.Call.Args {
- switch arg := arg.(type) {
- case *ssa.Function:
- subtests = append(subtests, arg)
- case *ssa.MakeClosure:
- fn, _ := arg.Fn.(*ssa.Function)
- subtests = append(subtests, fn)
- }
- }
-
- return subtests
-}