main: fix tests with default TestConfig.Count=0 doesn't skip all tests

Этот коммит содержится в:
Damian Gryski 2023-03-30 23:07:20 -07:00 коммит произвёл Ron Evans
родитель 9182664845
коммит 84a3273131
2 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -545,7 +545,7 @@ type TestConfig struct {
Verbose bool
Short bool
RunRegexp string
Count int
Count *int
BenchRegexp string
BenchTime string
BenchMem bool

Просмотреть файл

@ -245,8 +245,8 @@ func Test(pkgName string, stdout, stderr io.Writer, options *compileopts.Options
if testConfig.BenchMem {
flags = append(flags, "-test.benchmem")
}
if testConfig.Count != 1 {
flags = append(flags, "-test.count="+strconv.Itoa(testConfig.Count))
if testConfig.Count != nil && *testConfig.Count != 1 {
flags = append(flags, "-test.count="+strconv.Itoa(*testConfig.Count))
}
var buf bytes.Buffer
@ -1420,7 +1420,7 @@ func main() {
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.StringVar(&testConfig.RunRegexp, "run", "", "run: regexp of tests to run")
flag.IntVar(&testConfig.Count, "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.BenchTime, "benchtime", "", "run each benchmark for duration `d`")
flag.BoolVar(&testConfig.BenchMem, "benchmem", false, "show memory stats for benchmarks")