This file is indexed.

/usr/share/gocode/src/github.com/smartystreets/goconvey/web/server/executor/executor_test.go is in golang-github-smartystreets-goconvey-dev 1.6.1-2.

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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package executor

import (
	"strings"
	"testing"
	"time"

	. "github.com/smartystreets/goconvey/convey"
	"github.com/smartystreets/goconvey/web/server/contract"
)

func TestExecutor(t *testing.T) {
	t.Skip("BROKEN!")

	Convey("Subject: Execution of test packages and aggregation of parsed results", t, func() {
		fixture := newExecutorFixture()

		Convey("When tests packages are executed", func() {
			fixture.ExecuteTests()

			Convey("The result should include parsed results for each test package.",
				fixture.ResultShouldBePopulated)
		})

		Convey("When the executor is idle", func() {
			Convey("The status of the executor should be 'idle'", func() {
				So(fixture.executor.Status(), ShouldEqual, Idle)
			})
		})

		Convey("When the status is updated", func() {
			fixture.executor.setStatus(Executing)

			Convey("The status flag should be set to true", func() {
				So(fixture.executor.statusFlag, ShouldBeTrue)
			})
		})

		Convey("During test execution", func() {
			status := fixture.CaptureStatusDuringExecutionPhase()

			Convey("The status of the executor should be 'executing'", func() {
				So(status, ShouldEqual, Executing)
			})
		})
	})
}

type ExecutorFixture struct {
	executor *Executor
	tester   *FakeTester
	parser   *FakeParser
	folders  []*contract.Package
	result   *contract.CompleteOutput
	expected *contract.CompleteOutput
	stamp    time.Time
}

func (self *ExecutorFixture) ExecuteTests() {
	self.result = self.executor.ExecuteTests(self.folders)
}

func (self *ExecutorFixture) CaptureStatusDuringExecutionPhase() string {
	nap, _ := time.ParseDuration("25ms")
	self.tester.addDelay(nap)
	return self.delayedExecution(nap)
}

func (self *ExecutorFixture) delayedExecution(nap time.Duration) string {
	go self.ExecuteTests()
	time.Sleep(nap)
	return self.executor.Status()
}

func (self *ExecutorFixture) ResultShouldBePopulated() {
	So(self.result, ShouldResemble, self.expected)
}

var (
	prefix   = "/Users/blah/gopath/src/"
	packageA = "github.com/smartystreets/goconvey/a"
	packageB = "github.com/smartystreets/goconvey/b"
	resultA  = &contract.PackageResult{PackageName: packageA}
	resultB  = &contract.PackageResult{PackageName: packageB}
)

func newExecutorFixture() *ExecutorFixture {
	self := new(ExecutorFixture)
	self.tester = newFakeTester()
	self.parser = newFakeParser()
	self.executor = NewExecutor(self.tester, self.parser, make(chan chan string))
	self.folders = []*contract.Package{
		&contract.Package{Path: prefix + packageA, Name: packageA},
		&contract.Package{Path: prefix + packageB, Name: packageB},
	}
	self.stamp = time.Now()
	now = func() time.Time { return self.stamp }

	self.expected = &contract.CompleteOutput{
		Packages: []*contract.PackageResult{
			resultA,
			resultB,
		},
		Revision: self.stamp.String(),
	}
	return self
}

/******** FakeTester ********/

type FakeTester struct {
	nap time.Duration
}

func (self *FakeTester) SetBatchSize(batchSize int) { panic("NOT SUPPORTED") }
func (self *FakeTester) TestAll(folders []*contract.Package) {
	for _, p := range folders {
		p.Output = p.Path
	}
	time.Sleep(self.nap)
}
func (self *FakeTester) addDelay(nap time.Duration) {
	self.nap = nap
}

func newFakeTester() *FakeTester {
	self := new(FakeTester)
	zero, _ := time.ParseDuration("0")
	self.nap = zero
	return self
}

/******** FakeParser ********/

type FakeParser struct {
	nap time.Duration
}

func (self *FakeParser) Parse(packages []*contract.Package) {
	time.Sleep(self.nap)
	for _, package_ := range packages {
		if package_.Name == packageA && strings.HasSuffix(package_.Output, packageA) {
			package_.Result = resultA
		}
		if package_.Name == packageB && strings.HasSuffix(package_.Output, packageB) {
			package_.Result = resultB
		}
	}
}

func (self *FakeParser) addDelay(nap time.Duration) {
	self.nap = nap
}

func newFakeParser() *FakeParser {
	self := new(FakeParser)
	zero, _ := time.ParseDuration("0")
	self.nap = zero
	return self
}