Граф коммитов

1071 Коммитов

Автор SHA1 Сообщение Дата
Alan Donovan efcd2bdbd9 internal/packagestest: fork go/packages/packagestest
Also, update all imports outside of that package.

Updates golang/go#70229

Change-Id: I8b08f892ec86d560c0406319c2954eb9912d78ad
Reviewed-on: https://go-review.googlesource.com/c/tools/+/625920
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-11-06 21:04:09 +00:00
Rob Findley 45a28e1c11 all: fix x/tools tests that fail with a go1.23.1 go.work file
Delete or selectively skip tests that made either of the following
assumptions:
- The default GODEBUG is that of Go 1.22 (not true given a go.work
  file).
- GOROOT is a development version of Go (not true if GOROOT is prepared
  by cmd/distpack).

Fixes golang/go#70081
Fixes golang/go#70082

Change-Id: I47dfb225427f75e3be833eed3ba677ff454935f1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622896
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-28 22:46:16 +00:00
Tim King 4f6e118e23 all: set gotypesalias=1 when using >=1.23 toolchain
Set gotypesalias=1 when using >=1.23 toolchain on all of
the main packages in x/tools that use go/types. Does not include
packages that are ignored due to build tags.

This effectively upgrades commit https://go.dev/cl/617095.

For golang/go#69772

Change-Id: I434c280b928ad21e1fd9c7f880e1324c14741dc3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/619395
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-10 17:44:59 +00:00
Tim King a4e0a9e3d7 cmd/bundle: enable materialized aliases
Change-Id: If402c12e2412890334c7188b6579964cb4b97454
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-09 17:01:35 +00:00
Rob Findley db26c69117 cmd/stringer: fix test on android
Fix a broken test build on android due to inconsistent build constraints
in test files.

Change-Id: I6350797fb65f2f2699e11b95b01a4aa3b3b84307
Reviewed-on: https://go-review.googlesource.com/c/tools/+/618996
Run-TryBot: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-10-09 16:29:45 +00:00
Tim King a24facf9e5 all: set gotypesalias=0 explicitly
Set GODEBUG variable gotypesalias to off in all main packages
in x/tools that use go/types.

This is a no-op as the x/tools go.mod is uses version 1.22,
which disables gotypesalias in main packages and tests by default.

Change-Id: I1593cd63ec018e230e126d990530bd59fb9a96cf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/617095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Tim King <taking@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-10-02 16:33:07 +00:00
Viktor Blomqvist 4e80b325ef cmd/stringer: support types declared in test files
Adds additional passes over the test variants of the given
package.  Picks the most "narrow" (least amount of files)
package where each type can be found. The generated code
will be placed in the same package and test-or-not-test file
as the original type declaration.

Closes golang/go#66557.

Change-Id: I2354cd44e357a9ce0b45f5e2fadc1c141455a88d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/604535
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-10-01 18:18:17 +00:00
Alan Donovan 34638fc6a4 cmd/{callgraph,ssadump}, gopackages: make -tags flags work
Previously, the -tags flag used the obsolete buildutil.TagsFlag,
which only affects the behavior of the obsolete go/loader.
This change causes the -tags flag to affect go/packages
in these three tools, as it should.

Updates golang/go#69556
Updates golang/go#69538

Change-Id: Ie45c51c7fe04863dba00bc2f81b0a78f1c9bd0e3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614895
TryBot-Bypass: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
2024-09-25 18:06:02 +00:00
Alan Donovan 3bb0ed7baa x/tools: assume go1.22 and simplify
This CL does not include simplifications to gopls.

Updates golang/go#65917
Updates golang/go#69095

Change-Id: I2b54992681e2c671324e22668d8401962a1d2363
Reviewed-on: https://go-review.googlesource.com/c/tools/+/593683
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-20 21:11:01 +00:00
Alan Donovan 1d5e334177 internal/aliases: remove Alias and Unalias
These two declarations can now safely be accessed directly
from go/types.

Also, remove all mention of internal/aliases from gopls/...
We can enable two suppressed tests now that go1.23 is assured.

Updates golang/go#46477

Change-Id: I9ae8536b0d022e3300b285547c18202bed302cf2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614638
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Tim King <taking@google.com>
Reviewed-by: Tim King <taking@google.com>
2024-09-20 19:51:09 +00:00
Alan Donovan 1204c80e1c cmd/gorename: delete
Fixes golang/go#69360

Change-Id: Ifea5e45eae670c45861fbc1f09ebe2872260b2e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614675
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-20 16:28:26 +00:00
Alan Donovan 3921b59364 cmd/gorename: remove replace directive
This makes it so that 'go install golang.org/x/tools/cmd/gorename@latest'
will continue to work. ('go install pkg@version' does not allow
replace directives.)

Updates golang/go#69360

Change-Id: I46a16a5d8dc7d1d1cf6c428388484e27f266f4e2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614635
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-09-20 14:52:37 +00:00
Alan Donovan 8517dc9911 cmd/gorename: create submodule
gorename is deprecated.
(Use gopls's Rename RPC or rename command instead.)

Once this module is tagged, we will delete it.
Clients will be able to use only the last version.

Updates golang/go#69360

Change-Id: I89ea5feade02f9fb15c7244847810f3c2261f7ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/614158
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-19 23:09:10 +00:00
Zvonimir Pavlinovic c758e54fc7 cmd/callgraph: make vta use internal version of CHA
That version is faster and uses less memory.

Change-Id: I1839aa672fab25833da2ffa2dfcb079db67dd922
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610537
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04 17:50:33 +00:00
Alan Donovan a5df6ad55c go/analysis/passes/printf: report non-constant format, no args
Calls such as fmt.Printf(s), where s is non-constant and there
are no arguments to format, are invariably a mistake. This
CL causes the printf checker to report them, and to offer
a suggested fix of fmt.Printf("%s", s).

Also:
- tests
- docs
- fixes to existing violations in x/tools (3 bugs, 2 merely bad form).
- an ignore-tagged main file for the printf checker.

Fixes golang/go#60529

Change-Id: Ic7cc4f3e7487bc1549948fa03b5b0b27959948e5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/585795
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-05 17:36:26 +00:00
Russ Cox d9c6af3f03 cmd/stress: add -count flag, and print number of active commands in status updates
Add -count flag to be able to say 'run 100 and stop'.
This is useful when using stress to test for flakes in
a git bisect loop or other scripts.

Print the number of active commands during status
updates. This is useful for knowing what's going on
as the run reaches its conclusion (and earlier).

Sort flag list.

Change-Id: Iad4ef3069aeebbb58923ea3696909d2c1e9dbd91
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2024-07-11 22:00:49 +00:00
Alan Donovan ae524770c6 cmd/deadcode: fix nil panic in Edge.Site.Pos
Thanks to @ct16k for reporting the crash and suggesting the fix.

Also, a test.

Fixes golang/go#67915

Change-Id: I72472603e52831d5e571cb8a4e053fd15ff49b72
Reviewed-on: https://go-review.googlesource.com/c/tools/+/591615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-06-10 16:24:39 +00:00
ardnew fcea13b66c toolstash: errors output should match errors guarded
The errors guarded against in the `if` conditions are not the errors
printed with`log.Fatalf()` — instead, they are the same errors copied
from the immediately-preceding error checks.
Maybe some sort of copy-paste mistake.

Reasoning:
- The error printed is always `nil` at the changed lines (`err1`).
- The error printed should be a non-`nil` error (`err2`).

Change-Id: I5e4c1e6a460fb37d9d8652b727e641db2245e3c5
GitHub-Last-Rev: 77a4e86342
GitHub-Pull-Request: golang/tools#489
Reviewed-on: https://go-review.googlesource.com/c/tools/+/580235
Reviewed-by: Joedian Reid <joedian@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2024-04-25 20:20:40 +00:00
Alan Donovan 1f580da078 cmd/guru: delete it
RIP guru, Go's LSP server before LSP was invented.

Fixes golang/go#65880

Change-Id: I75adef368e6e940c3b6dfc0ca06ad38ba0cf3656
Reviewed-on: https://go-review.googlesource.com/c/tools/+/569882
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 20:35:12 +00:00
Alan Donovan c6563ca60f cmd/guru: remove replace directive
Updates golang/go#65880

Change-Id: Icb45d94bd2ef0864ab054e76a6aa651b269e2ec5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570139
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-03-08 19:54:13 +00:00
Alan Donovan 9e530fc6f3 cmd/guru: carve out a separate module
This is the first step of deleting guru.

Updates golang/go#65880

Change-Id: Id33729265825f5557a47a5c571b2ae0e2d58336a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570136
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-08 16:29:34 +00:00
Alan Donovan 5bf7d00529 cmd/callgraph: add 'posn' template helper
This change adds a helper function to the template environment
to make it easier to compute the token.Position of an ssa Function.

Also, improve the documentation.

Fixes golang/go#65980

Change-Id: I16d4cc87bb6f96985684da5ce027be296f22a601
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567838
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-29 21:45:52 +00:00
Alan Donovan 283fce21c1 x/tools: drop go1.18 support
Updates golang/go#64407

Change-Id: I247a7ff7f07613674f8e31e4cb9c5a68762d2203
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567418
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-29 16:54:26 +00:00
Alan Donovan 38b0e9bfdb x/tools: add explicit Unalias operations
This change is the result of an audit of all type assertions
and type switches whose operand is a types.Type. (These were
enumerated with an analyzer tool.)

If the operand is already the result of a call to Underlying
or Unalias, there is nothing to do, but in other cases,
explicit Unalias operations were added in order to preserve
the existing behavior when go/types starts creating explicit
Alias types.

This change does not address any desired behavior changes
required for the ideal handling of aliases; they will wait
for a followup. In a number of places I have added comments
matching "TODO.*alias".

It may be prudent to split this change by top-level directory,
both for ease of review, and of later bisection if needed.

During the audit, there appeared to be a recurring need
for the following operators:
- (*types.Func).Signature (golang/go#65772);
- Deref(Type): it's easy to forget to strip off the
  Alias constructor;
- ReceiverName (CL 565075), for destructuring receiver
  types such as T and *T, in which up to two Aliases
  might be present.

Updates golang/go#65294

Change-Id: I5180b9bae1c9191807026b8e0dc6f15ed4953b9a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/565035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-02-28 21:26:44 +00:00
Alan Donovan a6c03c86fe x/tools: update telemetry import (new Start API)
Change-Id: I78701b620029a94b47524f5d4a77c35a86df2e4e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-02-28 20:27:29 +00:00
Alan Donovan 4db45793ff cmd/deadcode: avoid ssautil.AllFunctions
This change causes deadcode to enumerate the "universe set"
of functions based on the source-level declarations, not
the ssautil.AllFunctions helper. The former set is accurate
(and also much cheaper to compute), whereas the latter is
a mess (as its doc comment attests).

In particular, it omits unexported methods of uninstantiated
types, which are of course unreachable. This makes for
some sense for whole-program analysis, but none at all
for a dead code tool that specifically wants to know
the useless functions.

The new logic is pleasantly simpler.

Also, a test.

Fixes golang/go#65915

Change-Id: I7a4a64fd3da18d089044530911cdb2e3b42d0db5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/567156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-02-27 14:29:08 +00:00
Alan Donovan c111c4dfab internal/typesinternal: add ReceiverNamed helper
...and factor numerous places to use it.

(This pattern kept recurring during my types.Alias audit,
golang/go#65294.)

Change-Id: I93228b735f7a8ff70df5c998017437d43742d9f3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/565075
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-02-21 22:46:11 +00:00
Hana (Hyang-Ah) Kim 4231a57faa cmd/getgo: delete package
The last version v0.1.0-deprecated was published.

Fixes golang/go#60951

Change-Id: Ib178384ba3a4010edd509825f8a9106853ccf703
Reviewed-on: https://go-review.googlesource.com/c/tools/+/564657
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Hyang-Ah Hana Kim <hyangah@gmail.com>
2024-02-16 18:21:48 +00:00
Hana (Hyang-Ah) Kim c61f99f1f0 cmd/getgo: create a module in preparation for deprecation
And add deprecation notice.
Updates golang/go#60951

Change-Id: I9d4ffffc03201b038db5cc11563ea1cc5330e668
Reviewed-on: https://go-review.googlesource.com/c/tools/+/563398
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-02-16 17:49:44 +00:00
Alan Donovan 08393e0666 cmd/deadcode: audit for types.Alias safety
Updates golang/go#65294

Change-Id: Ica0197fd5d931244079fdf5b8c29f1bfeed5083b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/559936
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-06 20:28:53 +00:00
Alan Donovan c07f927657 cmd/deadcode: enable crash reporting
Change-Id: I07fe6e5d3058867c2a8c6df7688cc5395700d918
Reviewed-on: https://go-review.googlesource.com/c/tools/+/559459
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-02-01 23:04:19 +00:00
Dmitri Shuralyov 1efbdde366 cmd/stringer, go/loader: use testenv.NeedsTool(t, "cgo")
Using go env CGO_ENABLED has an advantage over build.Default.CgoEnabled
in that it pays attention to whether a C compiler is available in $PATH,
so it correctly skips the test when cgo is not enabled in more contexts.
I haven't found better docs for this than https://go.dev/doc/go1.20#cgo.

Also add this in TestCgoCwdIssue46877, since it requires cgo.

Change-Id: Ib14a983cc179b725a98f154846662887a91edc19
Reviewed-on: https://go-review.googlesource.com/c/tools/+/560175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2024-02-01 17:54:33 +00:00
Quim Muntal b048cf1266 cmd/callgraph: unskip TestCallgraph on windows/arm64
This reverts commit 7d125fe075.

Windows/arm64 builders have been migrated to Azure
using Windows ARM64 hosts instead of qemu + Mac. Let's see if the
issue still reproduces.

Change-Id: I2c55812c9eb9710ac2849e65987f55baf7766b13
Reviewed-on: https://go-review.googlesource.com/c/tools/+/559115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2024-01-29 18:13:43 +00:00
Alan Donovan 95c6ac4a5b gopls/internal/protocol/command: move from ../lsp
The lsp directory is no more.

Change-Id: I7badd01645c7faab841e6219387cb84d8b893f2b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/557741
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-01-24 00:48:14 +00:00
Michael Stapelberg a863a4fcd3 cmd/goimports: fix -trace flag: flush after stopping trace
Without this change, the created trace files cannot be read by "go tool trace":

2023/12/25 09:51:02 Parsing trace...
failed to parse trace: no EvFrequency event

Change-Id: I59964875c8e821262db2cc6bbc82b2be385e1618
Reviewed-on: https://go-review.googlesource.com/c/tools/+/553555
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-03 12:29:34 +00:00
Bryan C. Mills 5b123a2d42 cmd/guru,internal/robustio: make tests robust to os.Symlink errors
Windows sometimes does support symlinks, so we shouldn't over-skip on
that platform. On the other hand, wasip1 sometimes does not support
symlinks, so we should allow Symlink to fail on that platform.

Instead of hard-coding which platforms *don't* support symlinks,
let's  hard-code the ones that always do, and skip on error otherwise.
That way, these tests will be robust to new platforms going forward,
and will default to running the tests if Symlink actually works.

Fixes golang/go#64702.
Fixes golang/go#64701.

Change-Id: I1cd5034effa4d8d66fd2cd3092926c0a2e3e76d8
Cq-Include-Trybots: luci.golang.try:x_tools-gotip-wasip1-wasm_wasmtime,x_tools-gotip-wasip1-wasm_wazero,x_tools-gotip-windows-amd64-longtest,x_tools-gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549555
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-13 21:14:55 +00:00
Alan Donovan 23c86e8ed6 internal/typeparams: delete const Enabled=true and simplify
Change-Id: I8e95226d03d94027aee803a0431320bc7ee83600
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549235
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-12 19:05:48 +00:00
Alan Donovan f580f772b6 cmd/deadcode: publish internal/cmd/deadcode
Fixes golang/go#63501

Change-Id: I794734e4508d7ccbd8653554f14d109ee8ca9927
Reviewed-on: https://go-review.googlesource.com/c/tools/+/547035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-12-11 16:13:35 +00:00
Sebastiaan van Stijn f60f2e6aa4 all: replace all usages of golang.org/x/sys/execabs with os/exec
The "golang.org/x/sys/execabs" package was introduced to address a
security issue on Windows, and changing the default behavior of os/exec
was considered a breaking change. go1.19 applied the behavior that was
previously implemented in the execabs package through CL 403274.

This reverts fe37c9e135 (CL 284773).
Updates #43724.

Change-Id: I53987d0d0009b8dd11e05fc3d17cbffb9625a9c1
GitHub-Last-Rev: 18e93f39c4
GitHub-Pull-Request: golang/tools#455
Reviewed-on: https://go-review.googlesource.com/c/tools/+/539017
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Commit-Queue: Bryan Mills <bcmills@google.com>
2023-11-09 20:10:26 +00:00
Dmitri Shuralyov 71f6a46884 cmd/bundle: drop old +build lines
The +build to go:build syntax conversion has progressed enough that
it's fine to write only the new syntax now. All supported (and many
unsupported) Go releases understand it.

For golang/go#41184.
For golang/go#60268.

Change-Id: I8c1600577a21f4c7c89123302ca976d881a69841
Reviewed-on: https://go-review.googlesource.com/c/tools/+/536075
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-19 16:59:02 +00:00
Ian Lance Taylor cdf1b5eb51 cmd/present: drop NaCl reference from docs
Change-Id: Ic0b04040ab869c69898a0b7b7b17d1fe624aa4cc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/536135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-19 11:56:44 +00:00
Cherry Mui f6d8589ec3 cmd/compilebench: pass linker flags to prebuild
Some linker flag, e.g. -linkmode=external, can change the go
command's behavior, e.g. which packages to include. Pass the
linker flags to prebuild, as well as "go list" for constructing
the importcfg file. This ensures that in -linkmode=external mode
runtime/cgo is built and included, avoiding a linker warning.

Fixes golang/go#63383.

Change-Id: I185e8dd2e6de7601a343739186117bce3c19e492
Reviewed-on: https://go-review.googlesource.com/c/tools/+/533855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-10-10 03:24:50 +00:00
Dmitri Shuralyov 0b06fd80c1 cmd/gonew: skip Test if exec is unsupported
The test can't run on platforms where exec is not implemented.
Make similar skip messages a bit more detailed and consistent.

For golang/go#61104.

Change-Id: I40cecd428cf0a7b6195aee146df6ed92deea0950
Cq-Include-Trybots: luci.golang.try:x_tools-gotip-js-wasm
Reviewed-on: https://go-review.googlesource.com/c/tools/+/533158
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-10-09 14:28:34 +00:00
Than McIntosh d7442965d3 cmd/compilebench: check asm support for -compiling-runtime
Rather than just omitting the -compiling-runtime flag (which is needed
for tip of master as of CL 521697), do a test run of the assembler to
see whether the flag is accepted. If it is, then assume we need it
when running the assembler for package 'reflect', so as to ensure
compilebench keeps working properly for old Go versions.

Change-Id: I17fb54c37a94aef08e0b855579d1d1c333880092
Reviewed-on: https://go-review.googlesource.com/c/tools/+/529560
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-20 18:34:13 +00:00
Than McIntosh 0669fa3126 cmd/compilebench: fix assembler invocation
When building assembly for the "reflect" package, we should no longer
be passing the "-compiling-runtime" flag (it is no longer supported,
since the toolchain now infers the runtime property based on the
import path).

Change-Id: I364959b86038816f34811ab450edc1bc5c0382d0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/529300
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-20 15:44:12 +00:00
Peter Weinberger 365db56d19 tools: clean up after removing all references to ioutil
Although ioutil.ReadDir is deprecated, the suggested replacement has
a different signature, returning []fs.DirEntry rather than []fs.FileEntry.

Some of the places where this occurs are better left referring to ioutil,
as build.Config wants the old behavior. (go/buildutil/util.go and
godoc/vfs/os.go) When someday build gets updated, these can be easily
found, and changed.

Some of the place use Mode().IsRegular() (cmd/toolstash/mail.go and
internal/fastwalk/fastwal_portable.go) and the code needs a minor adjustment.

And, happily, in all the other  places one can use os.ReadDir directly
as only Name() is called.

There are no remaining instances of the generated ioutilReadDir().

Change-Id: I165ca27eafe2fe37fdf14390543b21f7e198281e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/528135
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-18 16:47:49 +00:00
Peter Weinbergr 559c4300da tools: replace references to obsolete package ioutils
ioutil defines 7 functions. 6 of these are replaced by
functions in io or os with the same signature.
ReadDir is deprecated, but the suggested replacement has a different
signature.

These changes were generated by a program, with some manual adjutments.
The program replaces ReadDir with a call to a function named ioutilReadDir
that has the same signature. The code for this function
is added to files if necessary. The program replaces all the others
with their new versions. The program removes the 'io/ioutil' import
and adds, as necessary, 'os', 'io', and 'io/fs', the latter being
needed for the signature of ioutilReadDir.

The automatic process fails in a few ways:
1. ReadFile occurs only in a comment but the program adds an unneeded import.
2. ioutilReadDir is added to more than one file in the same package
Both of these could be viewed as bugs and fixed by looking harder.

After manual adjustment, two tests failed:
1. gopls/internal/lsp/regtesg/mis:TestGenerateProgress. The reason
	 was a use of ioutil in a txtar constant. The calls were changed,
	 but the code is not smart enough to change the import inside the
	 string constant. (Or it's not smart enough not to change the
	 contents of a string.)
2. gopls/internal/lsp/analysis/deprecated, which wants to see a use
	 of ioutil

These tests were adjused by hand, and all tests (-short) pass.

Change-Id: If9efe40bbb0edda36173d9a88afaf71245db8e79
Reviewed-on: https://go-review.googlesource.com/c/tools/+/527675
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-12 20:13:37 +00:00
Rob Findley 9886d9888c all: get tests passing with 1.18 and 1.19
In order to replace gopls legacy builds on Kokoro with LUCI, it is
easiest to get x/tools tests passing at older Go versions.

This CL gets tests passing at 1.18 and 1.19, using various techniques:
 - Where it was easy to carve out some leave node of the package graph,
   just use go:build directives.
 - Add an internal/compat package with compatibility shims (much like
   the typeparams package, which is coincidentally now obsolete). It
   turns out, the only required shim is Appendf.

Notably, some go/ssa and go/ssa/interp tests recurse infinitely due to
a go/types bug, which was not investigated.

Change-Id: Ib2e6cc8a804ead394a324a4598728b200b24091c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/526264
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2023-09-11 19:46:14 +00:00
Bryan C. Mills 627959a8e3 cmd/stringer: log more information in tests
Also associate the stderr and stdout output of subprocesses more
clearly with the specific test.

For golang/go#62534.

Change-Id: I6768f2d8d60e21d4d6465208c17b542691a3f803
Reviewed-on: https://go-review.googlesource.com/c/tools/+/526172
Commit-Queue: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-09-08 20:30:21 +00:00
Russ Cox c16d0be617 cmd/gonew: add new tool for starting a module by copying one
This is an experimental command that perhaps would become "go new"
once we have more experience with it. We want to enable people to
experiment with it and write their own templates and see how it works,
and for that we need to put it in a place where it's reasonable to ask
users to fetch it from. That place is golang.org/x/tools/cmd/gonew.

There is an earlier copy in rsc.io/tmp/gonew, but that isn't the right
place for end users to be fetching something to try.

Once the tool is checked in I intend to start a GitHub discussion
asking for feedback and suggestions about what is missing.
I hope we will be able to identify core functionality that handles a
large fraction of use cases.

I've been using the earlier version myself for a while, and I've found
it very convenient even in other contexts, like I want the code for a
given module and don't want to go look up its Git repo and so on:

	go new rsc.io/quote@v1.5.2
	cd quote

Change-Id: Ifc27cbd5d87ded89bc707b087b3f08fa70b1ef07
Reviewed-on: https://go-review.googlesource.com/c/tools/+/513737
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-31 12:54:47 +00:00