1
0
mirror of https://github.com/golang/go synced 2024-10-01 15:58:33 -06:00
Commit Graph

15 Commits

Author SHA1 Message Date
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
Roger Peppe
63e6ed9258 cmd/stringer: compile error when constants change
When constant values change but stringer has not
been run again, we can get misleading string values.
Protect against this by generating code that will fail
with a compiler error when this happens.
Most compilers should be smart enough to omit the
code containing the checks.

Change-Id: I7a36d20f014cba0e7d88851d1b649a098ee30d76
Reviewed-on: https://go-review.googlesource.com/c/tools/+/163637
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-03-18 00:52:22 +00:00
Brad Fitzpatrick
658e28e1e6 cmd/stringer: add temporary(?) fix to get stringer test working in module mode
Updates golang/go#30874

Change-Id: I170ea99b3f06c8bc4cc624e86b80eeb852ea7115
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167771
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-15 20:35:58 +00:00
Jonathan Amsterdam
b2f7fe607d cmd/stringer: type check using export data
Use go/packages to find and type check packages using export data.

In addition to type checking with export data, this should also enable
cmd/stringer to work correctly when using go modules.

jba: took over CL, tweaked package.Config use.

Change-Id: Ie253378b52fbd909f7194dfd09c039aab63dd8f0
Reviewed-on: https://go-review.googlesource.com/c/126535
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-04 22:01:59 +00:00
Rob Pike
18f0b668f1 cmd/stringer: add a -tags flag that supports build tags
This is reapplying CL121995 after rolling back the change to the importing
methods. There is still a need for a flag to control tags.
The original CL decription:

The feature has been requested but, like build tags in general,
only works in a directory, not when files are specified explicitly.
Unlike the build tools, report when the feature is misused like this
to avoid confusion.

Fixes golang/go#9449

Change-Id: I732627d5f2e6323367e3bdd5de746923868890a9
Reviewed-on: https://go-review.googlesource.com/122537
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-10 05:22:40 +00:00
Rob Pike
827133af57 cmd/stringer: revert back to source importer
Roll back my two recent changes. Stringer is now very slow again,
but works in most use cases.

My git foo is insufficient to do this as a revert, but it is a by-hand
reversion of CLs

	https://go-review.googlesource.com/121884
	https://go-review.googlesource.com/121995

See the issue for a long conversation about the general problem.

Update golang/go#10249
Update golang/go#25650

Change-Id: I7b6ce352a4c7ebf0977883509e9d7189aaac1251
Reviewed-on: https://go-review.googlesource.com/122535
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-07 07:48:14 +00:00
Rob Pike
75d2ffb453 stringer: add a -tags flag that supports build tags
The feature has been requested but, like build tags in general,
only works in a directory, not when files are specified explicitly.
Unlike the build tools, report when the feature is misused like this
to avoid confusion.

Fixes golang/go#9449

Change-Id: I079d363c5eeb5bc647fd2f0f3d88d28d630644d8
Reviewed-on: https://go-review.googlesource.com/121995
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-04 00:06:24 +00:00
Rob Pike
ffe8890671 cmd/stringer: revert CL 40403
Revert "cmd/stringer: use source importer when available"

This reverts CL 40403.

The idea is to avoid type-checking and use just parsing, which should be
enough for stringer.

Separately reopening golang/go#10249 because the original change closed that issue,
but the change is itself causing other problems as described in the discussion
at golang/go#25650.

This reversion restores the old behavior of stringer and will be followed
with other fixes if they can be worked out.

Change-Id: I8404d78da08043ede1a36b0e135a3fc7fdf6728d
Reviewed-on: https://go-review.googlesource.com/121884
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-03 00:36:02 +00:00
Ian Lance Taylor
05e91d0638 cmd/stringer: fix typo in test log message ("no" -> "not")
Fixes golang/go#22623

Change-Id: I62ab82a04f34f379f715f0902a69caa9c74c50d2
Reviewed-on: https://go-review.googlesource.com/76397
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-07 22:55:16 +00:00
Josh Bleecher Snyder
9bf174b4d3 cmd/stringer: use source importer when available
This means that running stringer should always
have the intended effect, without having to
go install the package first, which was a common
source of confusion.

The source importer is marginally slower,
but stringer is run infrequently,
and we're only typechecking one package (and fmt),
not an entire tree, as vet does.

Fixes golang/go#10249

Change-Id: Ib8cde29bd6cc596964dbe7348065932dd59075fc
Reviewed-on: https://go-review.googlesource.com/40403
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-04-12 18:56:47 +00:00
Robert Griesemer
63f996ec75 cmd/stringer: exclude end-to-end test for Android
Change-Id: I37224abb3d9ca902ed23d520493f3b2794ef0471
Reviewed-on: https://go-review.googlesource.com/13261
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-05 22:44:14 +00:00
Nigel Tao
045f02ba9d cmd/stringer: fix ignored error in TestEndToEnd.
Change-Id: Ia139e9da37aecddebe8895c0d3427d7e97d408f8
Reviewed-on: https://go-review.googlesource.com/2931
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-01-15 23:10:50 +00:00
Rob Pike
0e9050009a tools/cmd/vet: check that cgo is enabled before testing it
Should fix the tools builders.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/176530043
2014-12-02 08:15:26 +09:00
Alex Brainman
d39af6c903 go.tools/cmd/stringer: add .exe suffix to executable name in TestEndToEnd
Fixes windows build

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/140360043
2014-09-08 13:55:05 +10:00
Rob Pike
d0448f16e3 go.tools/cmd/stringer: add end-to-end test that compiles, runs, and verifies the generated method
In the process, fix a bug in one of the method generators.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/141130043
2014-09-05 15:42:23 -07:00