aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/script
AgeCommit message (Collapse)Author
9 dayscmd/go/internal/script: add fuzz test for quoteArgsAbhinav Gupta
Adds a fuzz test for quoteArgs and fixes the bugs it found: handling of empty strings and strings containing "&" or "$". This is a copy of a similar change submitted to rsc.io/script: https://github.com/rsc/script/pull/10 Change-Id: I76e7fc89475e1c4e415f45f2c7ac4a87a7a659e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/566316 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2026-03-31cmd/go/internal/doc: use internal go command logic to load packagesmatloob
We've been using go/build to load packages, and that doesn't always do the right thing, because it doesn't have the same context and settings that the go command uses to load packages. Use the go command's loader to load packages. This CL doesn't remove the logic for searching for matching packages in dirs.go. A next step would be to remove that so all the matching is also done with the go command's logic. Fixes #75976 Change-Id: I3c76d9a54dc88648bb7c76a17afad8cb6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/733200 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
2026-03-09cmd/internal/test2json: generate and validate test artifactsEthan Reesor
Adds a mechanism for generating test2json test artifacts from and validating them against a real test. If a .test file has a corresponding .src file, TestGolden will now treat the .src file as a script test, executing it and verifying that the output matches the contents of the .test file. Running TestGolden with the -update flag will also regenerate .test files if they have a corresponding .src file. Capturing the output of the script test in this way required making minor changes to cmd/internal/script/scripttest. This was motivated by CL 601535 (golang/go#62728). Specifically, testing that CL required adding src/cmd/internal/test2json/testdata/frameescape.test which has a multitude of non-printing characters and thus must be generated by executing `go test`. Using a script test to generate the test file is more reliable than doing it by hand. Change-Id: I60456700e37e21a42d0514be2ce86dc6df2bccb0 Reviewed-on: https://go-review.googlesource.com/c/go/+/628615 Reviewed-by: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com>
2026-01-30cmd/go,crypto/mlkem,crypto/x509,encoding/ascii85: clean up ↵Neal Patel
tautological/impossible nil conditions Change-Id: I3cdc599ebc93f5c9be5645e7ef7ce167242d9c1b Reviewed-on: https://go-review.googlesource.com/c/go/+/739800 Reviewed-by: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-12-04cmd/internal/fuzztest: move fuzz tests out of cmd/go test suiteMichael Matloob
They are very slow: taking them out of the cmd/go test suite makes the go command tests go from about 80 seconds to run on my system, to about 50 seconds to run. Change-Id: I19b5c252bd2b6e6d64821cada961ddaa6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/726960 Auto-Submit: Michael Matloob <matloob@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-02cmd/go: skip git sha256 tests if git < 2.29David Finkel
Fix test building on older Ubuntu LTS releases (that are still supported). Git SHA256 support was only included in 2.29, which came out in 2021. Check the output of `git version` and skip these tests if the version is older than that introduction. Thanks to @ianlancetaylor for flagging this. Updates: #73704 Change-Id: I9d413a63fa43f34f94c274bba7f7b883c80433b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/698835 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> Auto-Submit: Michael Matloob <matloob@google.com> Reviewed-by: Ian Alexander <jitsu@google.com>
2025-10-13all: replace calls to errors.As with errors.AsTypeJulien Cretel
This change replaces most occurrences (in code as well as in comments) of errors.As with errors.AsType. It leaves the errors package and vendored code untouched. Change-Id: I3bde73f318a0b408bdb8f5a251494af15a13118a GitHub-Last-Rev: 8aaaa36a5a12d2a6a90c6d51680464e1a3115139 GitHub-Pull-Request: golang/go#75698 Reviewed-on: https://go-review.googlesource.com/c/go/+/708495 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-15all: replace strings.Split with strings.SplitSeq1911860538
In Go 1.25+, strings.SplitSeq offers better performance. Here are the benchmark results comparing strings.Split and strings.SplitSeq in a for-loop, with the benchmark code located in src/strings/iter_test.go: goos: darwin goarch: amd64 pkg: cmd/go/internal/auth cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ ParseGitAuth/standard-8 281.4n ± 1% 218.0n ± 11% -22.54% (p=0.000 n=10) ParseGitAuth/with_url-8 549.1n ± 1% 480.5n ± 13% -12.48% (p=0.002 n=10) ParseGitAuth/minimal-8 235.4n ± 1% 197.3n ± 7% -16.20% (p=0.000 n=10) ParseGitAuth/complex-8 797.6n ± 2% 805.2n ± 4% ~ (p=0.481 n=10) ParseGitAuth/empty-8 87.48n ± 3% 63.25n ± 6% -27.71% (p=0.000 n=10) ParseGitAuth/malformed-8 228.8n ± 1% 171.2n ± 3% -25.17% (p=0.000 n=10) geomean 288.9n 237.7n -17.72% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ ParseGitAuth/standard-8 192.00 ± 0% 96.00 ± 0% -50.00% (p=0.000 n=10) ParseGitAuth/with_url-8 400.0 ± 0% 288.0 ± 0% -28.00% (p=0.000 n=10) ParseGitAuth/minimal-8 144.00 ± 0% 80.00 ± 0% -44.44% (p=0.000 n=10) ParseGitAuth/complex-8 528.0 ± 0% 400.0 ± 0% -24.24% (p=0.000 n=10) ParseGitAuth/empty-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=10) ParseGitAuth/malformed-8 176.00 ± 0% 80.00 ± 0% -54.55% (p=0.000 n=10) geomean 179.0 102.1 -42.96% │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ ParseGitAuth/standard-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) ParseGitAuth/with_url-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10) ParseGitAuth/minimal-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) ParseGitAuth/complex-8 4.000 ± 0% 3.000 ± 0% -25.00% (p=0.000 n=10) ParseGitAuth/empty-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) ParseGitAuth/malformed-8 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10) geomean 3.086 2.040 -33.91% Updates #69315. Change-Id: Id0219edea45d9658d527b863162ebe917e7821d9 GitHub-Last-Rev: 392b315e122f2c9ef8703ca2dbce8f82ec198556 GitHub-Pull-Request: golang/go#75259 Reviewed-on: https://go-review.googlesource.com/c/go/+/701015 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2025-08-05cmd: remove dead codeqiulaidongfeng
Fixes #74076 Change-Id: Icc67b3d4e342f329584433bd1250c56ae8f5a73d Reviewed-on: https://go-review.googlesource.com/c/go/+/690635 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-05-14cmd/internal/script: fix copying directory when symlink failsIan Alexander
The change fixes `linkOrCopy` to work on systems wihtout symlinks, when copying directories. This was originally noticed on Windows systems when the user did not have admin privs. Fixes #73692 Change-Id: I8ca66d65e99433ad38e70314abfabafd43794b79 Reviewed-on: https://go-review.googlesource.com/c/go/+/672275 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-11cmd/internal/script/scripttest: use GOHOSTARCH to find tool directoryIan Lance Taylor
Fixes #72800 Change-Id: Idde7eae13d1c0098e5314935cf8ca823cbc7a7cc Reviewed-on: https://go-review.googlesource.com/c/go/+/656855 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-21all: fix some function names and typos in commentcuishuang
Change-Id: I07e7c8eaa5bd4bac0d576b2f2f4cd3f81b0b77a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/630055 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-09-06cmd/internal/script: use sync.OnceValueKir Kolyshkin
Change-Id: I384a7391a26f24402c055aec98b37927305e2a39 Reviewed-on: https://go-review.googlesource.com/c/go/+/611042 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-07-31cmd: add README generation for compiler + linker script testsThan McIntosh
Add in automatic README generation and README consistency checking for the cmd/compile and cmd/link script tests. This code is adapted from the similar facility in cmd/go (e.g. scriptreadme_test.go); the README helps folks writing new tests understand the mechanics. Updates #68606. Change-Id: I8ff7ff8e814abd4385bd670440511b2c60a4cef6 Reviewed-on: https://go-review.googlesource.com/c/go/+/601756 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-31cmd/internal/script: new hook for adding in toolchain script conditionsThan McIntosh
Introduce a new function AddToolChainScriptConditions that augments a default "script.Cond" set with a collection of useful conditions, including godebug/goexperiment, cgo, race support, buildmode, asan, msan, and so on. Having these conditions available makes it easier to write script tests that deal with specific build-flavor corner cases. The functions backing the new conditions are helper functions migrated over from the Go command's script test setup. Updates #68606. Change-Id: I14def1115b54dc47529c983abcd2c5ea9326b9de Reviewed-on: https://go-review.googlesource.com/c/go/+/601715 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-07-29cmd/internal/script/scriptest: add new apis for tool test useThan McIntosh
Add top level apis to provide a general-purpose "script test" runner for clients within cmd, e.g. tools such as compile, link, nm, and so on. This patch doesn't add any uses of the new apis, this will happen in follow-on CLs. Updates #68606. Change-Id: Ib7200a75d4dc7dc50897628f1a6269937be15a76 Reviewed-on: https://go-review.googlesource.com/c/go/+/601359 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-07-29cmd: relocate cmd/go/internal/script to cmd/internal/scriptThan McIntosh
Relocate cmd/go's internal/script package up a level into cmd/internal/script, so as to enable the use of script tests in other cmd packages. No change in functionality. Updates #68606. Change-Id: I3974b0bf59c76e0f459184c9f3090d6077dd5d91 Reviewed-on: https://go-review.googlesource.com/c/go/+/601358 Reviewed-by: Michael Matloob <matloob@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>