родитель
ee81c31884
коммит
63aaa43072
4 изменённых файлов: 14 добавлений и 6 удалений
|
@ -545,6 +545,7 @@ type TestConfig struct {
|
||||||
Verbose bool
|
Verbose bool
|
||||||
Short bool
|
Short bool
|
||||||
RunRegexp string
|
RunRegexp string
|
||||||
|
SkipRegexp string
|
||||||
Count *int
|
Count *int
|
||||||
BenchRegexp string
|
BenchRegexp string
|
||||||
BenchTime string
|
BenchTime string
|
||||||
|
|
4
main.go
4
main.go
|
@ -236,6 +236,9 @@ func Test(pkgName string, stdout, stderr io.Writer, options *compileopts.Options
|
||||||
if testConfig.RunRegexp != "" {
|
if testConfig.RunRegexp != "" {
|
||||||
flags = append(flags, "-test.run="+testConfig.RunRegexp)
|
flags = append(flags, "-test.run="+testConfig.RunRegexp)
|
||||||
}
|
}
|
||||||
|
if testConfig.SkipRegexp != "" {
|
||||||
|
flags = append(flags, "-test.skip="+testConfig.SkipRegexp)
|
||||||
|
}
|
||||||
if testConfig.BenchRegexp != "" {
|
if testConfig.BenchRegexp != "" {
|
||||||
flags = append(flags, "-test.bench="+testConfig.BenchRegexp)
|
flags = append(flags, "-test.bench="+testConfig.BenchRegexp)
|
||||||
}
|
}
|
||||||
|
@ -1434,6 +1437,7 @@ func main() {
|
||||||
flag.BoolVar(&testConfig.Verbose, "v", false, "verbose: print additional output")
|
flag.BoolVar(&testConfig.Verbose, "v", false, "verbose: print additional output")
|
||||||
flag.BoolVar(&testConfig.Short, "short", false, "short: run smaller test suite to save time")
|
flag.BoolVar(&testConfig.Short, "short", false, "short: run smaller test suite to save time")
|
||||||
flag.StringVar(&testConfig.RunRegexp, "run", "", "run: regexp of tests to run")
|
flag.StringVar(&testConfig.RunRegexp, "run", "", "run: regexp of tests to run")
|
||||||
|
flag.StringVar(&testConfig.SkipRegexp, "skip", "", "run: regexp of tests to run")
|
||||||
testConfig.Count = flag.Int("count", 1, "count: number of times to run tests/benchmarks `count` times")
|
testConfig.Count = flag.Int("count", 1, "count: number of times to run tests/benchmarks `count` times")
|
||||||
flag.StringVar(&testConfig.BenchRegexp, "bench", "", "run: regexp of benchmarks to run")
|
flag.StringVar(&testConfig.BenchRegexp, "bench", "", "run: regexp of benchmarks to run")
|
||||||
flag.StringVar(&testConfig.BenchTime, "benchtime", "", "run each benchmark for duration `d`")
|
flag.StringVar(&testConfig.BenchTime, "benchtime", "", "run each benchmark for duration `d`")
|
||||||
|
|
|
@ -365,7 +365,7 @@ func runBenchmarks(matchString func(pat, str string) (bool, error), benchmarks [
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
ctx := &benchContext{
|
ctx := &benchContext{
|
||||||
match: newMatcher(matchString, *matchBenchmarks, "-test.bench", ""),
|
match: newMatcher(matchString, *matchBenchmarks, "-test.bench", flagSkipRegexp),
|
||||||
}
|
}
|
||||||
var bs []InternalBenchmark
|
var bs []InternalBenchmark
|
||||||
for _, Benchmark := range benchmarks {
|
for _, Benchmark := range benchmarks {
|
||||||
|
|
|
@ -24,10 +24,11 @@ import (
|
||||||
|
|
||||||
// Testing flags.
|
// Testing flags.
|
||||||
var (
|
var (
|
||||||
flagVerbose bool
|
flagVerbose bool
|
||||||
flagShort bool
|
flagShort bool
|
||||||
flagRunRegexp string
|
flagRunRegexp string
|
||||||
flagCount int
|
flagSkipRegexp string
|
||||||
|
flagCount int
|
||||||
)
|
)
|
||||||
|
|
||||||
var initRan bool
|
var initRan bool
|
||||||
|
@ -42,6 +43,8 @@ func Init() {
|
||||||
flag.BoolVar(&flagVerbose, "test.v", false, "verbose: print additional output")
|
flag.BoolVar(&flagVerbose, "test.v", false, "verbose: print additional output")
|
||||||
flag.BoolVar(&flagShort, "test.short", false, "short: run smaller test suite to save time")
|
flag.BoolVar(&flagShort, "test.short", false, "short: run smaller test suite to save time")
|
||||||
flag.StringVar(&flagRunRegexp, "test.run", "", "run: regexp of tests to run")
|
flag.StringVar(&flagRunRegexp, "test.run", "", "run: regexp of tests to run")
|
||||||
|
flag.StringVar(&flagSkipRegexp, "test.skip", "", "skip: regexp of tests to run")
|
||||||
|
|
||||||
flag.IntVar(&flagCount, "test.count", 1, "run each test or benchmark `count` times")
|
flag.IntVar(&flagCount, "test.count", 1, "run each test or benchmark `count` times")
|
||||||
|
|
||||||
initBenchmarkFlags()
|
initBenchmarkFlags()
|
||||||
|
@ -499,7 +502,7 @@ func (m *M) Run() (code int) {
|
||||||
func runTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ran, ok bool) {
|
func runTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ran, ok bool) {
|
||||||
ok = true
|
ok = true
|
||||||
|
|
||||||
ctx := newTestContext(newMatcher(matchString, flagRunRegexp, "-test.run", ""))
|
ctx := newTestContext(newMatcher(matchString, flagRunRegexp, "-test.run", flagSkipRegexp))
|
||||||
t := &T{
|
t := &T{
|
||||||
common: common{
|
common: common{
|
||||||
output: &logger{logToStdout: flagVerbose},
|
output: &logger{logToStdout: flagVerbose},
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче