1
0
mirror of https://github.com/golang/go synced 2024-10-01 07:38:32 -06:00
Commit Graph

51 Commits

Author SHA1 Message Date
Bryan C. Mills
df13fa7beb all: do not write to testdata directories
I got tired of spurious 'git' diffs while a 'go test' was running, so
I fixed the test that produced the diffs. (We need to do that anyway
in order to run them in the module cache, plus it's just good hygiene
not to have tests interfering with each other's sources.)

Tested using:

	$ chmod -R ugo-w . && go test ./...; chmod -R u+w .

Updates golang/go#28387

Change-Id: Ie17e31aecf0e3cb022df5503d7c443000366a5c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192577
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-30 17:05:20 +00:00
Bryan C. Mills
c17b040389 all: skip tests if required tools are not found
Fixes golang/go#33950

Change-Id: Iefcb757e773bc052793611c099c25a457fd7e243
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192400
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 15:40:57 +00:00
Daniel Martí
354f9f8b43 cmd/cover: check os.Create error im html output
The error was being written over by Execute.

Change-Id: Id5965542bf4d414043fdbe70ee3f2f790728c01d
Reviewed-on: https://go-review.googlesource.com/34954
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-01-08 00:00:17 +00:00
Dominik Honnef
361bcb2be3 all: address vet issues, fix print calls
This fixes some print calls with wrong format directives. Additionally,
struct initialisers were changed to use keyed fields, purely to reduce
the amount of noise generated by go vet.

Change-Id: Ib9f6fd8f2dff7ce84826478de0ba83dda9746270
Reviewed-on: https://go-review.googlesource.com/21180
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-27 20:36:34 +00:00
Robert Griesemer
958ab4f550 x/tools: disable tests not supported on Android
For golang/go#11811.

Change-Id: Icf16a2d47fcf2fe0d79dd825ccb851a3d63a660f
Reviewed-on: https://go-review.googlesource.com/13268
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-06 00:36:03 +00:00
Rob Pike
27e692e6ec cmd/cover: check error
The variable was assigned but not used, as caught by a tool
written by gorden.klaus@gmail.com.

Change-Id: I84ca3d00896287a35561bd122a0cf64212854a86
Reviewed-on: https://go-review.googlesource.com/10610
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-02 04:29:08 +00:00
Rob Pike
96f6cfbb92 cmd/cover: document that it is moving to the standard repository
Change-Id: I876afaa2c468f0f6f5d30bff8bc884e3beb33c7f
Reviewed-on: https://go-review.googlesource.com/9539
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-01 00:38:25 +00:00
Rob Pike
65b5a8eca7 cmd/cover: cover funcs in if, for, switch clauses
This peculiar case arose in range statements but there are other contexts
and one turned up in the auto-generated translation of the compiler.
Take care of it always.

	for i := 0; i < 0; func() {i++; q=q.Link}() { ... }

That code has been given the obvious rewrite but we should still handle it.

Odd but easy to fix (tricky to test).

Fixes #10269.

Change-Id: I66e1404eb24da15a24be7f67403e19ed66fba0a7
Reviewed-on: https://go-review.googlesource.com/8284
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-03-31 19:20:52 +00:00
Rob Pike
0c09ff325a cmd/cover: preserve //go: comments
Cover deleted all comments because they can break the simple way that
counters are injected into the rewritten source. But //go: comments have
semantic value, and for instance go test -cover runtime fails during
compilation because of their absence from the annotated source.

We can keep the //go: comments because they are at the beginning of
the line and are not affected by our counter injection.

Fixes #10270.

After this CL, go test -cover runtime works.
A testing strategy that does not involve a golden file would be welcome
but I can't think of one.

Change-Id: I73f7b7a36383a8efed8e33fa2414cd0eac7d015a
Reviewed-on: https://go-review.googlesource.com/8173
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-03-27 21:01:39 +00:00
Rob Pike
e77366c32d cmd/cover: do not cover statements after panic
Given
	x()
	panic(1)
	y()

the y should not show as covered.

Fixes #10185

Change-Id: Iec61f1b096a888e6727be5f4526508654f5d3c91
Reviewed-on: https://go-review.googlesource.com/8140
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-03-27 17:59:54 +00:00
Rob Pike
53f3b29c5d cmd/cover: fix race in test
Silly test added yesterday requires that some code in a goroutine executes.
Make sure it does.

Change-Id: I7e852454736e300151473986cc437a70b41dc9b7
Reviewed-on: https://go-review.googlesource.com/7691
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-17 21:45:36 +00:00
Rob Pike
26365e4e90 cmd/cover: fix handling of empty type switch
Just missed a case (ha!) in the tree walk. Dup the code for an empty switch, add test.

Fixes #10163.

Change-Id: I3d50ab6cb450ca21e87213291eaab8cbe924fac5
Reviewed-on: https://go-review.googlesource.com/7641
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-16 22:10:38 +00:00
David Symonds
24257c8cd2 tools: add import comments.
Change-Id: Idda6e64580432cb9a731e4ebf4005ee4ceb4202d
Reviewed-on: https://go-review.googlesource.com/1244
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-09 22:42:16 +00:00
Andrew Gerrand
5ebbcd132f go.tools: use golang.org/x/... import paths
Rewrite performed with this command:
  sed -i '' 's_code.google.com/p/go\._golang.org/x/_g' \
    $(grep -lr 'code.google.com/p/go.' *)

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/170920043
2014-11-10 08:50:40 +11:00
Fatih Arslan
ba91af23b8 cmd/cover: add start lines numbers to each function in -func mode
This CL aims to fix the problem described here:

https://groups.google.com/forum/#!topic/golang-nuts/R6ms1n9KjiY

This makes it easier to parse via external tools such as editors. Editors can
show each function in a list and jump directly to each function with this
additional information. This pattern can be seen in other Go tools such as "go
test" in the form of:

--- FAIL: TestCover (0.52 seconds)
        cover_test.go:43: example error

LGTM=adg
R=r, adg, josharian, dave
CC=golang-codereviews
https://golang.org/cl/131820043
2014-08-21 16:28:12 -07:00
Rob Pike
f11381f265 go.tools/cmd/cover: don't assume code is gofmt'd
We want to make an if look like two blocks and have the coverage
report for the else block decorate the "else" keyword with the right
color. To do this, we adjust the apparent starting point of the else
block to include the "else".

The previous code assumed the way to do this was to move the
width of "else " backwards from the else block's opening brace, but
that assumes there is a space there. Instead, we now just start the
else block exactly at the end of the if block. Simpler, cleaner, and
fixes a bug.

Fixes golang/go#8557.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/127620043
2014-08-20 11:14:50 -07:00
Andrew Gerrand
573fa9f0bd cmd/cover: show file coverage in HTML drop down
As requested on Stack Overflow: http://goo.gl/ams9fY
(Kudos to sberry for his JavaScript solution, provided there.
This change does the same thing on the server side.)

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/127030043
2014-08-12 09:22:11 +10:00
Robert Griesemer
30b1abe2f7 go.tools: fix various typos
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/97920045
2014-05-02 14:38:08 -07:00
Andrew Wilkins
df34f98521 go.tools/cover: split parsing code out from cmd/cover
Split the profile parsing code out of cmd/cover into
a reusable package, to support third-party coverage
tools.

R=golang-dev, r, adg
CC=golang-dev
https://golang.org/cl/36050045
2013-12-03 20:55:21 -08:00
Rob Pike
e4256a40f4 go.tools/cmd/cover: for range loops might contain function literals
Break the basic block at the function literal. The code to do this analysis
was already there; this CL just factors it out more nicely and uses it in
one new place. Also adds a test.

Fixes golang/go#6555.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14601043
2013-10-11 10:32:36 -07:00
Andrew Gerrand
ce4c627192 go.tools/cmd/cover: move docs to separate doc.go
The doc.go files will be copied into the binary distributions'
source tree that "godoc cover" works.

R=r
CC=golang-dev
https://golang.org/cl/14599045
2013-10-11 09:13:58 +09:00
Alan Donovan
f5b337da55 go.tools/cmd/cover: preserve comments, as other build tools may need "// +build" directives.
Also: fix a crash when a file already contains 'import "sync/atomic"'.

R=r, gri
CC=golang-dev
https://golang.org/cl/14441052
2013-10-10 15:29:24 -04:00
Rob Pike
51613a10d7 go.tools/cmd/cover: sort the file names in the output presentation
Present the files in lexical order so the output is reproducible
and easier to navigate. Do a little type rearrangement to simplify
things while we're there.

R=adg
CC=golang-dev
https://golang.org/cl/14357043
2013-10-03 16:37:34 -07:00
Nathan John Youngman
cb07517a77 go.tools/cover: validate flags with appropriate error messages
Fixes golang/go#6444.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13956043
2013-09-26 18:11:03 +10:00
Nathan John Youngman
84cae5a52d go.tools/cover: clean up usage information
R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/13532052
2013-09-24 17:27:26 +10:00
Andrew Gerrand
eb130cb481 go.tools/cmd/cover: add content-type meta tag to HTML output
Fixes golang/go#6435.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13822045
2013-09-23 13:57:03 +10:00
Andrew Gerrand
4709d08a36 go.toos/cmd/cover: "add" package comment
R=r
CC=golang-dev
https://golang.org/cl/13463046
2013-09-16 14:39:12 +10:00
Rob Pike
28fe5aa8d3 go.tools/cmd/cover: s/ParseInt/Atoi/
So people stop asking me to do this.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12691044
2013-08-09 13:48:46 +10:00
Rob Pike
4622486b62 go.tools/cmd/cover: add -func mode to print per-function coverage
fmt/format.go:	init			100.0%
fmt/format.go:	clearflags		100.0%
fmt/format.go:	init			100.0%
fmt/format.go:	computePadding		84.6%
fmt/format.go:	writePadding		83.3%
...
total:		(statements)		91.3%

Fixes golang/go#5985.

R=golang-dev, dave, gri
CC=golang-dev
https://golang.org/cl/12454043
2013-08-09 12:55:21 +10:00
Rob Pike
9ac8940d29 all: be more idiomatic when documenting boolean return values.
Phrases like "returns whether or not the image is opaque" could be
describing what the function does (it always returns, regardless of
the opacity) or what it returns (a boolean indicating the opacity).
Even when the "or not" is missing, the phrasing is bizarre.

Go with "reports whether", which is still clunky but at least makes
it clear we're talking about the return value.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/11458046
2013-07-23 10:37:43 +10:00
Rob Pike
1c382c95b2 go.tools/cmd/cover: get cover counters on if conditions
This requires a little more tree rewriting to put a block around the if of an "else if".
More tests too.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11042045
2013-07-10 15:20:52 +10:00
Andrew Gerrand
5b27bc1db9 go.talks/cmd/cover: show simpler legend for "set" mode
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10738044
2013-07-10 14:03:35 +10:00
Andrew Gerrand
c659fcb7c8 go.tools/cmd/cover: add floating bar with file selector and legend
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11076043
2013-07-10 13:22:04 +10:00
Andrew Gerrand
2b6515094c go.talks/cmd/cover: better color scheme and fonts
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11032043
2013-07-09 16:58:15 +10:00
Andrew Gerrand
a82eaff6b7 go.tools/cmd/cover: change color scheme and add legend
R=r, dsymonds
CC=golang-dev
https://golang.org/cl/10991043
2013-07-08 15:24:34 +10:00
Andrew Gerrand
00268482c0 go.tools/cmd/cover: use html/template for html generation
Also includes simple JavaScript dropdown picker.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10838045
2013-07-06 16:58:50 +10:00
Andrew Gerrand
d9e6cbb135 go.tools/cmd/cover: use a gradient to colorize "count" profiles
R=r
CC=golang-dev
https://golang.org/cl/10858047
2013-07-05 13:53:09 +10:00
Rob Pike
78efac5f33 go.tools/cmd/cover: yet another attempt at a usage message (YAAAAUM) for go tool cover
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10710044
2013-06-27 14:48:27 -07:00
Rob Pike
b52f745c3a go.tools/cmd/cover: delete TODO that is NOWDONE
R=adg
CC=golang-dev
https://golang.org/cl/10505044
2013-06-27 09:20:34 -07:00
Rob Pike
40caf1ff72 go.tools/cmd/cover: better usage message
R=adg, rsc
CC=golang-dev
https://golang.org/cl/10453044
2013-06-24 12:56:25 -07:00
Rob Pike
78d364c43e go.tools/cmd/cover: fix build
Need the ./ for the path. Quick fix to get the build green, but what really is the right answer for Windows?

R=golang-dev
CC=golang-dev
https://golang.org/cl/10359044
2013-06-21 14:47:04 -07:00
Rob Pike
c28528d489 go.tools/cmd/cover: add a test
Test the statistics work as expected for a simple program, which can be extended as needed. This is all a bit meta.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10392050
2013-06-21 14:35:09 -07:00
Rob Pike
decfd079c5 go.tools/cmd/cover: skip mode line (first line of profile)
Still to do: use the mode to affect how to present the data.

R=adg, rsc
CC=golang-dev
https://golang.org/cl/10364050
2013-06-21 14:19:57 -07:00
Rob Pike
33ae2b030f go.tools.cmd/cover: define a block to end at the closing brace rather than last statement
Makes for prettier output in many cases.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/10360049
2013-06-19 09:11:32 -07:00
Andrew Gerrand
16c6244c27 go.tools/cmd/cover: add HTML output
R=r, dsymonds
CC=golang-dev
https://golang.org/cl/10277043
2013-06-15 08:53:10 +10:00
Rob Pike
3162ce0df2 go.tools/cmd/cover: record statements-per-block
This number will allow us to give a conventional meaning to "coverage":
the percentage of executable statements visited by the test.

R=adonovan
CC=golang-dev
https://golang.org/cl/10271045
2013-06-13 14:27:22 -07:00
Rob Pike
e330494adc go.tool/cmd/cover: use a struct instead of multiple variables
We are going to need one more piece of data, so rather than create
a third variable let's just put it all in one struct. The interface gets
easier too.

R=adonovan
CC=golang-dev
https://golang.org/cl/10271044
2013-06-13 12:50:30 -07:00
Rob Pike
0ca15cc618 go.tools/cmd/cover: add -o outputfile option
Makes it easier to get error output when run from the go tool.

R=adonovan
CC=golang-dev
https://golang.org/cl/10190043
2013-06-11 10:18:55 -07:00
Rob Pike
73612ddbfd go.tools/cmd/cover: handle empty select
Putting a coverage counter inside select{} is invalid Go.

R=adonovan
CC=golang-dev
https://golang.org/cl/10175043
2013-06-10 15:58:32 -07:00
Rob Pike
ba51e7a586 go.tools/cmd/cover: make -mode=atomic work again
It was broken by a previous simplification. The import was missing.

R=adonovan
CC=golang-dev
https://golang.org/cl/10117045
2013-06-10 10:58:08 -07:00