summaryrefslogtreecommitdiffstats
path: root/src/go/doc/testdata/testing.1.golden
blob: b9d14517a9cfebd00d5292ebabfcf39ddaa6a794 (plain)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
// Package testing provides support for automated testing of Go ...
PACKAGE testing

IMPORTPATH
	testdata/testing

IMPORTS
	bytes
	flag
	fmt
	io
	os
	runtime
	runtime/pprof
	strconv
	strings
	time

FILENAMES
	testdata/benchmark.go
	testdata/example.go
	testdata/testing.go

VARIABLES
	// 
	var (
		// The short flag requests that tests run more quickly, but its functionality
		// is provided by test writers themselves. The testing package is just its
		// home. The all.bash installation script sets it to make installation more
		// efficient, but by default the flag is off so a plain "go test" will do a
		// full test of the package.
		short	= flag.Bool("test.short", false, "run smaller test suite to save time")
	
		// Report as tests are run; default is silent for success.
		chatty		= flag.Bool("test.v", false, "verbose: print additional output")
		match		= flag.String("test.run", "", "regular expression to select tests to run")
		memProfile	= flag.String("test.memprofile", "", "write a memory profile to the named file after execution")
		memProfileRate	= flag.Int("test.memprofilerate", 0, "if >=0, sets runtime.MemProfileRate")
		cpuProfile	= flag.String("test.cpuprofile", "", "write a cpu profile to the named file during execution")
		timeout		= flag.Duration("test.timeout", 0, "if positive, sets an aggregate time limit for all tests")
		cpuListStr	= flag.String("test.cpu", "", "comma-separated list of number of CPUs to use for each test")
		parallel	= flag.Int("test.parallel", runtime.GOMAXPROCS(0), "maximum test parallelism")
	
		cpuList	[]int
	)

	// 
	var benchTime = flag.Duration("test.benchtime", 1*time.Second, "approximate run time for each benchmark")

	// 
	var matchBenchmarks = flag.String("test.bench", "", "regular expression to select benchmarks to run")

	// 
	var timer *time.Timer


FUNCTIONS
	// An internal function but exported because it is cross-package; ...
	func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample)

	// An internal function but exported because it is cross-package; ...
	func RunBenchmarks(matchString func(pat, str string) (bool, error), benchmarks []InternalBenchmark)

	// 
	func RunExamples(examples []InternalExample) (ok bool)

	// 
	func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool)

	// Short reports whether the -test.short flag is set. 
	func Short() bool

	// after runs after all testing. 
	func after()

	// alarm is called if the timeout expires. 
	func alarm()

	// before runs before all testing. 
	func before()

	// decorate inserts the final newline if needed and indentation ...
	func decorate(s string, addFileLine bool) string

	// 
	func max(x, y int) int

	// 
	func min(x, y int) int

	// 
	func parseCpuList()

	// roundDown10 rounds a number down to the nearest power of 10. 
	func roundDown10(n int) int

	// roundUp rounds x up to a number of the form [1eX, 2eX, 5eX]. 
	func roundUp(n int) int

	// startAlarm starts an alarm if requested. 
	func startAlarm()

	// stopAlarm turns off the alarm. 
	func stopAlarm()

	// 
	func tRunner(t *T, test *InternalTest)


TYPES
	// B is a type passed to Benchmark functions to manage benchmark ...
	type B struct {
		common
		N		int
		benchmark	InternalBenchmark
		bytes		int64
		timerOn		bool
		result		BenchmarkResult
	}

	// Error is equivalent to Log() followed by Fail(). 
	func (c *B) Error(args ...interface{})

	// Errorf is equivalent to Logf() followed by Fail(). 
	func (c *B) Errorf(format string, args ...interface{})

	// Fail marks the function as having failed but continues ...
	func (c *B) Fail()

	// FailNow marks the function as having failed and stops its ...
	func (c *B) FailNow()

	// Failed reports whether the function has failed. 
	func (c *B) Failed() bool

	// Fatal is equivalent to Log() followed by FailNow(). 
	func (c *B) Fatal(args ...interface{})

	// Fatalf is equivalent to Logf() followed by FailNow(). 
	func (c *B) Fatalf(format string, args ...interface{})

	// Log formats its arguments using default formatting, analogous ...
	func (c *B) Log(args ...interface{})

	// Logf formats its arguments according to the format, analogous ...
	func (c *B) Logf(format string, args ...interface{})

	// ResetTimer sets the elapsed benchmark time to zero. It does not ...
	func (b *B) ResetTimer()

	// SetBytes records the number of bytes processed in a single ...
	func (b *B) SetBytes(n int64)

	// StartTimer starts timing a test. This function is called ...
	func (b *B) StartTimer()

	// StopTimer stops timing a test. This can be used to pause the ...
	func (b *B) StopTimer()

	// launch launches the benchmark function. It gradually increases ...
	func (b *B) launch()

	// log generates the output. It's always at the same stack depth. 
	func (c *B) log(s string)

	// 
	func (b *B) nsPerOp() int64

	// run times the benchmark function in a separate goroutine. 
	func (b *B) run() BenchmarkResult

	// runN runs a single benchmark for the specified number of ...
	func (b *B) runN(n int)

	// trimOutput shortens the output from a benchmark, which can be ...
	func (b *B) trimOutput()

	// The results of a benchmark run. 
	type BenchmarkResult struct {
		N	int		// The number of iterations.
		T	time.Duration	// The total time taken.
		Bytes	int64		// Bytes processed in one iteration.
	}

	// Benchmark benchmarks a single function. Useful for creating ...
	func Benchmark(f func(b *B)) BenchmarkResult

	// 
	func (r BenchmarkResult) NsPerOp() int64

	// 
	func (r BenchmarkResult) String() string

	// 
	func (r BenchmarkResult) mbPerSec() float64

	// An internal type but exported because it is cross-package; part ...
	type InternalBenchmark struct {
		Name	string
		F	func(b *B)
	}

	// 
	type InternalExample struct {
		Name	string
		F	func()
		Output	string
	}

	// An internal type but exported because it is cross-package; part ...
	type InternalTest struct {
		Name	string
		F	func(*T)
	}

	// T is a type passed to Test functions to manage test state and ...
	type T struct {
		common
		name		string		// Name of test.
		startParallel	chan bool	// Parallel tests will wait on this.
	}

	// Error is equivalent to Log() followed by Fail(). 
	func (c *T) Error(args ...interface{})

	// Errorf is equivalent to Logf() followed by Fail(). 
	func (c *T) Errorf(format string, args ...interface{})

	// Fail marks the function as having failed but continues ...
	func (c *T) Fail()

	// FailNow marks the function as having failed and stops its ...
	func (c *T) FailNow()

	// Failed reports whether the function has failed. 
	func (c *T) Failed() bool

	// Fatal is equivalent to Log() followed by FailNow(). 
	func (c *T) Fatal(args ...interface{})

	// Fatalf is equivalent to Logf() followed by FailNow(). 
	func (c *T) Fatalf(format string, args ...interface{})

	// Log formats its arguments using default formatting, analogous ...
	func (c *T) Log(args ...interface{})

	// Logf formats its arguments according to the format, analogous ...
	func (c *T) Logf(format string, args ...interface{})

	// Parallel signals that this test is to be run in parallel with ...
	func (t *T) Parallel()

	// log generates the output. It's always at the same stack depth. 
	func (c *T) log(s string)

	// 
	func (t *T) report()

	// common holds the elements common between T and B and captures ...
	type common struct {
		output		[]byte		// Output generated by test or benchmark.
		failed		bool		// Test or benchmark has failed.
		start		time.Time	// Time test or benchmark started
		duration	time.Duration
		self		interface{}		// To be sent on signal channel when done.
		signal		chan interface{}	// Output for serial tests.
	}

	// Error is equivalent to Log() followed by Fail(). 
	func (c *common) Error(args ...interface{})

	// Errorf is equivalent to Logf() followed by Fail(). 
	func (c *common) Errorf(format string, args ...interface{})

	// Fail marks the function as having failed but continues ...
	func (c *common) Fail()

	// FailNow marks the function as having failed and stops its ...
	func (c *common) FailNow()

	// Failed reports whether the function has failed. 
	func (c *common) Failed() bool

	// Fatal is equivalent to Log() followed by FailNow(). 
	func (c *common) Fatal(args ...interface{})

	// Fatalf is equivalent to Logf() followed by FailNow(). 
	func (c *common) Fatalf(format string, args ...interface{})

	// Log formats its arguments using default formatting, analogous ...
	func (c *common) Log(args ...interface{})

	// Logf formats its arguments according to the format, analogous ...
	func (c *common) Logf(format string, args ...interface{})

	// log generates the output. It's always at the same stack depth. 
	func (c *common) log(s string)