/usr/share/gocode/src/github.com/smartystreets/goconvey/execution/scope.go is in golang-github-smartystreets-goconvey-dev 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | package execution
import (
"fmt"
"strings"
"github.com/smartystreets/goconvey/reporting"
)
func (parent *scope) adopt(child *scope) {
if parent.hasChild(child) {
return
}
parent.birthOrder = append(parent.birthOrder, child)
parent.children[child.name] = child
}
func (parent *scope) hasChild(child *scope) bool {
for _, ordered := range parent.birthOrder {
if ordered.name == child.name && ordered.title == child.title {
return true
}
}
return false
}
func (self *scope) registerReset(action *Action) {
self.resets[action.name] = action
}
func (self *scope) visited() bool {
return self.panicked || self.child >= len(self.birthOrder)
}
func (parent *scope) visit() {
defer parent.exit()
parent.enter()
parent.action.Invoke()
parent.visitChildren()
}
func (parent *scope) enter() {
parent.reporter.Enter(parent.report)
}
func (parent *scope) visitChildren() {
if len(parent.birthOrder) == 0 {
parent.cleanup()
} else {
parent.visitChild()
}
}
func (parent *scope) visitChild() {
child := parent.birthOrder[parent.child]
child.visit()
if child.visited() {
parent.cleanup()
parent.child++
}
}
func (parent *scope) cleanup() {
for _, reset := range parent.resets {
reset.Invoke()
}
}
func (parent *scope) exit() {
if problem := recover(); problem != nil {
if strings.HasPrefix(fmt.Sprintf("%v", problem), ExtraGoTest) {
panic(problem)
}
parent.panicked = true
parent.reporter.Report(reporting.NewErrorReport(problem))
}
parent.reporter.Exit()
}
func newScope(entry *Registration, reporter reporting.Reporter) *scope {
self := &scope{}
self.reporter = reporter
self.name = entry.Action.name
self.title = entry.Situation
self.action = entry.Action
self.children = make(map[string]*scope)
self.birthOrder = []*scope{}
self.resets = make(map[string]*Action)
self.report = reporting.NewScopeReport(self.title, self.name)
return self
}
type scope struct {
name string
title string
action *Action
children map[string]*scope
birthOrder []*scope
child int
resets map[string]*Action
panicked bool
reporter reporting.Reporter
report *reporting.ScopeReport
}
|