Skip to content

Commit

Permalink
modify getTestMap func
Browse files Browse the repository at this point in the history
  • Loading branch information
moricho committed Sep 3, 2020
1 parent c448147 commit 76d5ee2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tparallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ func getTestMap(ssaanalyzer *buildssa.SSA, testTyp types.Type) map[*ssa.Function

trun := analysisutil.MethodOf(testTyp, "Run")
for _, f := range ssaanalyzer.SrcFuncs {
if strings.HasPrefix(f.Name(), "Test") && f.Parent() == (*ssa.Function)(nil) {
testMap[f] = []*ssa.Function{}
for _, block := range f.Blocks {
for _, instr := range block.Instrs {
called := analysisutil.Called(instr, nil, trun)
if called {
testMap[f] = appendTestMap(testMap[f], instr)
}
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 {
testMap[f] = appendTestMap(testMap[f], instr)
}
}
}
Expand All @@ -106,5 +107,6 @@ func appendTestMap(subtests []*ssa.Function, instr ssa.Instruction) []*ssa.Funct
subtests = append(subtests, arg)
}
}

return subtests
}

0 comments on commit 76d5ee2

Please sign in to comment.