• Daniel Martí's avatar
    testing: don't warn if -bench was passed · 11ff4b21
    Daniel Martí authored
    In a previous change, cmd/go was taught to show a "no tests ran" warning
    if test did nothing. But it missed a case - if no tests nor examples ran
    but any benchmarks were meant to be run, it would still produce the
    warning. This meant that running only benchmarks, which is common, would
    be confusing:
    
    	 $ go test -run='^$' -bench=.
    	testing: warning: no tests to run
    	BenchmarkFoo-4            300000              5056 ns/op
    	[...]
    
    I believe this was because of a copy-paste error in the tests. This was
    being tested, but on the wrong file which does contain a test that was
    being run. Fix the path and fix the now failing test by never showing
    the warning if -bench was given a non-empty string.
    
    The rationale is that if -bench was given but there was no output, it's
    obvious that nothing happened as benchmarks always produce output even
    without -v. So showing a warning in those cases is redundant.
    
    To make future typos less likely, make sure that no tests are being run
    in the cases where we only want to run benchmarks.
    
    Fixes #17603.
    
    Change-Id: I4c626caf39f72260c6a9761c06446663f465f947
    Reviewed-on: https://go-review.googlesource.com/32157Reviewed-by: 's avatarMarcel van Lohuizen <mpvl@golang.org>
    Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    11ff4b21
Name
Last commit
Last update
..
addr2line Loading commit data...
api Loading commit data...
asm Loading commit data...
cgo Loading commit data...
compile Loading commit data...
cover Loading commit data...
dist Loading commit data...
doc Loading commit data...
fix Loading commit data...
go Loading commit data...
gofmt Loading commit data...
internal Loading commit data...
link Loading commit data...
nm Loading commit data...
objdump Loading commit data...
pack Loading commit data...
pprof Loading commit data...
trace Loading commit data...
vendor Loading commit data...
vet Loading commit data...