testing: nudge functions closer to upstream order, to make diffing easier. No functional change.
Этот коммит содержится в:
		
							родитель
							
								
									a743580734
								
							
						
					
					
						коммит
						78a36f7724
					
				
					 2 изменённых файлов: 59 добавлений и 45 удалений
				
			
		| 
						 | 
					@ -56,6 +56,23 @@ type common struct {
 | 
				
			||||||
	name   string // Name of test or benchmark.
 | 
						name   string // Name of test or benchmark.
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Short reports whether the -test.short flag is set.
 | 
				
			||||||
 | 
					func Short() bool {
 | 
				
			||||||
 | 
						return flagShort
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// CoverMode reports what the test coverage mode is set to.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Test coverage is not supported; this returns the empty string.
 | 
				
			||||||
 | 
					func CoverMode() string {
 | 
				
			||||||
 | 
						return ""
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Verbose reports whether the -test.v flag is set.
 | 
				
			||||||
 | 
					func Verbose() bool {
 | 
				
			||||||
 | 
						return flagVerbose
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TB is the interface common to T and B.
 | 
					// TB is the interface common to T and B.
 | 
				
			||||||
type TB interface {
 | 
					type TB interface {
 | 
				
			||||||
	Error(args ...interface{})
 | 
						Error(args ...interface{})
 | 
				
			||||||
| 
						 | 
					@ -204,11 +221,6 @@ func (c *common) Helper() {
 | 
				
			||||||
	// Unimplemented.
 | 
						// Unimplemented.
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Parallel is not implemented, it is only provided for compatibility.
 | 
					 | 
				
			||||||
func (c *common) Parallel() {
 | 
					 | 
				
			||||||
	// Unimplemented.
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Cleanup registers a function to be called when the test (or subtest) and all its
 | 
					// Cleanup registers a function to be called when the test (or subtest) and all its
 | 
				
			||||||
// subtests complete. Cleanup functions will be called in last added,
 | 
					// subtests complete. Cleanup functions will be called in last added,
 | 
				
			||||||
// first called order.
 | 
					// first called order.
 | 
				
			||||||
| 
						 | 
					@ -232,6 +244,17 @@ func (c *common) runCleanup() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Parallel is not implemented, it is only provided for compatibility.
 | 
				
			||||||
 | 
					func (c *common) Parallel() {
 | 
				
			||||||
 | 
						// Unimplemented.
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// InternalTest is a reference to a test that should be called during a test suite run.
 | 
				
			||||||
 | 
					type InternalTest struct {
 | 
				
			||||||
 | 
						Name string
 | 
				
			||||||
 | 
						F    func(*T)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func tRunner(t *T, fn func(t *T)) {
 | 
					func tRunner(t *T, fn func(t *T)) {
 | 
				
			||||||
	defer func() {
 | 
						defer func() {
 | 
				
			||||||
		t.runCleanup()
 | 
							t.runCleanup()
 | 
				
			||||||
| 
						 | 
					@ -276,12 +299,6 @@ func (t *T) Run(name string, f func(t *T)) bool {
 | 
				
			||||||
	return !sub.failed
 | 
						return !sub.failed
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InternalTest is a reference to a test that should be called during a test suite run.
 | 
					 | 
				
			||||||
type InternalTest struct {
 | 
					 | 
				
			||||||
	Name string
 | 
					 | 
				
			||||||
	F    func(*T)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// M is a test suite.
 | 
					// M is a test suite.
 | 
				
			||||||
type M struct {
 | 
					type M struct {
 | 
				
			||||||
	// tests is a list of the test names to execute
 | 
						// tests is a list of the test names to execute
 | 
				
			||||||
| 
						 | 
					@ -291,6 +308,19 @@ type M struct {
 | 
				
			||||||
	deps testDeps
 | 
						deps testDeps
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type testDeps interface {
 | 
				
			||||||
 | 
						MatchString(pat, str string) (bool, error)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func MainStart(deps interface{}, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M {
 | 
				
			||||||
 | 
						Init()
 | 
				
			||||||
 | 
						return &M{
 | 
				
			||||||
 | 
							Tests:      tests,
 | 
				
			||||||
 | 
							Benchmarks: benchmarks,
 | 
				
			||||||
 | 
							deps:       deps.(testDeps),
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Run the test suite.
 | 
					// Run the test suite.
 | 
				
			||||||
func (m *M) Run() int {
 | 
					func (m *M) Run() int {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -351,23 +381,6 @@ func (m *M) Run() int {
 | 
				
			||||||
	return failures
 | 
						return failures
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Short reports whether the -test.short flag is set.
 | 
					 | 
				
			||||||
func Short() bool {
 | 
					 | 
				
			||||||
	return flagShort
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Verbose reports whether the -test.v flag is set.
 | 
					 | 
				
			||||||
func Verbose() bool {
 | 
					 | 
				
			||||||
	return flagVerbose
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// CoverMode reports what the test coverage mode is set to.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Test coverage is not supported; this returns the empty string.
 | 
					 | 
				
			||||||
func CoverMode() string {
 | 
					 | 
				
			||||||
	return ""
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// AllocsPerRun returns the average number of allocations during calls to f.
 | 
					// AllocsPerRun returns the average number of allocations during calls to f.
 | 
				
			||||||
// Although the return value has type float64, it will always be an integral
 | 
					// Although the return value has type float64, it will always be an integral
 | 
				
			||||||
// value.
 | 
					// value.
 | 
				
			||||||
| 
						 | 
					@ -381,23 +394,6 @@ func AllocsPerRun(runs int, f func()) (avg float64) {
 | 
				
			||||||
	return 0
 | 
						return 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestMain(m *M) {
 | 
					 | 
				
			||||||
	os.Exit(m.Run())
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type testDeps interface {
 | 
					 | 
				
			||||||
	MatchString(pat, s string) (bool, error)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func MainStart(deps interface{}, tests []InternalTest, benchmarks []InternalBenchmark, examples []InternalExample) *M {
 | 
					 | 
				
			||||||
	Init()
 | 
					 | 
				
			||||||
	return &M{
 | 
					 | 
				
			||||||
		Tests:      tests,
 | 
					 | 
				
			||||||
		Benchmarks: benchmarks,
 | 
					 | 
				
			||||||
		deps:       deps.(testDeps),
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type InternalExample struct {
 | 
					type InternalExample struct {
 | 
				
			||||||
	Name      string
 | 
						Name      string
 | 
				
			||||||
	F         func()
 | 
						F         func()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/testing/testing_test.go
									
										
									
									
									
										Обычный файл
									
								
							
							
						
						
									
										18
									
								
								src/testing/testing_test.go
									
										
									
									
									
										Обычный файл
									
								
							| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					// Copyright 2014 The Go Authors. All rights reserved.
 | 
				
			||||||
 | 
					// Use of this source code is governed by a BSD-style
 | 
				
			||||||
 | 
					// license that can be found in the LICENSE file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package testing_test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// This is exactly what a test would do without a TestMain.
 | 
				
			||||||
 | 
					// It's here only so that there is at least one package in the
 | 
				
			||||||
 | 
					// standard library with a TestMain, so that code is executed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func TestMain(m *testing.M) {
 | 
				
			||||||
 | 
						os.Exit(m.Run())
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче