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

8 Коммитов

Автор SHA1 Сообщение Дата
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
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
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
Robert Findley c276ee52bc internal/robustio: fix signature of getFileID on plan9
Also fix the failing new gopls command integration tests, which observe
a different exit code on plan9.

Change-Id: I5d0c11549deb3d3643f4d7772f0659dfda3600ea
Reviewed-on: https://go-review.googlesource.com/c/tools/+/464297
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-01 18:41:57 +00:00
Robert Findley ae242ec327 gopls: fix windows file corruption
Fix the bug that gopls finds the wrong content when formatting an open
URI whose spelling does not match the spelling on disk (i.e. because of
case insensitivity).

Remove the whole View.filesByBase mechanism: it is problematic as we
can't generally know whether or not we want to associate two different
spellings of the same file: for the purposes of finding packages we may
want to treat Foo.go as foo.go, but we don't want to treat a symlink of
foo.go in another directory the same.

Instead, use robustio.FileID to de-duplicate content in the cache, and
otherwise treat URIs as we receive them. This fixes the formatting
corruption, but means that we don't find packages for the corresponding
file (because go/packages.Load("file=foo.go") fails).  A failing test is
added for the latter bug.

Also: use a seenFiles map in the view to satisfy the concern of tracking
relevant files, with a TODO to delete this problematic map.

Along the way, refactor somewhat to separate and normalize the
implementations of source.FileSource.

For golang/go#57081

Change-Id: I02971a1702f057b644fa18a873790e8f0d98a323
Reviewed-on: https://go-review.googlesource.com/c/tools/+/462819
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2023-01-30 19:34:14 +00:00
Alan Donovan 5c176b1de4 internal/robustio: skip os.Link test on android
https://pkg.go.dev/internal/testenv#HasLink says:

	// From Android release M (Marshmallow), hard linking files is blocked
	// and an attempt to call link() on a file will return EACCES.
	// - https://code.google.com/p/android-developer-preview/issues/detail?id=3150
	return runtime.GOOS != "plan9" && runtime.GOOS != "android"

Fixes golang/go#57844

Change-Id: I92594daf99d3a0e74507f7f3ab806e3ed5af533f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/462415
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-17 17:44:17 +00:00
Alan Donovan 3856a5d80c internal/robustio: add Plan9 support to FileID
Fixes golang/go#57642

Change-Id: I269162017b78e9009d60aeca87255a57611fcd4b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/460855
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-01-06 16:49:32 +00:00
Tim King 33071fbe1a internal/robustio: move robustio
Moves gopls/internal/robustio to internal/robustio.
Allows usage by packages in x/tools outside of gopls.

Change-Id: I71743c3a91458b77f12606b743b5de7e23cc5051
Reviewed-on: https://go-review.googlesource.com/c/tools/+/460116
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Tim King <taking@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2023-01-02 23:56:08 +00:00