Skip to content

Commit b6a9d8b

Browse files
committed
all: add Go 1.21, drop Go 1.19
And fix up the tests and code to adapt accordingly. While here, update the checkout action as well.
1 parent 3fbe0b6 commit b6a9d8b

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
go-version:
15-
- '1.19.x'
1615
- '1.20.x'
16+
- '1.21.x'
1717
os:
1818
- ubuntu-latest
1919
- macos-latest
2020
- windows-latest
2121
runs-on: ${{ matrix.os }}
2222
steps:
2323
- name: Checkout code
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525
- name: Install Go
2626
uses: actions/setup-go@v4
2727
with:
@@ -33,7 +33,7 @@ jobs:
3333
go test -race ./...
3434
3535
- name: Tidy
36-
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.20.x' # no need to do this everywhere
36+
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.21.x' # no need to do this everywhere
3737
run: |
3838
go mod tidy
3939

cmd/testscript/testdata/noproxy.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# With no .gomodproxy supporting files, we use the GOPROXY from
22
# the environment.
3+
# Note that Go 1.21 started quoting with single quotes in "go env",
4+
# where older versions used double quotes.
35
env GOPROXY=0.1.2.3
46
unquote file.txt
57
testscript -v file.txt
68

79
-- file.txt --
810
>go env
9-
>[!windows] stdout '^GOPROXY="0.1.2.3"$'
11+
>[!windows] stdout '^GOPROXY=[''"]0.1.2.3[''"]$'
1012
>[windows] stdout '^set GOPROXY=0.1.2.3$'

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/rogpeppe/go-internal
22

3-
go 1.19
3+
go 1.20
44

55
require (
66
golang.org/x/mod v0.9.0

gotooltest/testdata/cover.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ stdout 'PASS'
1313
# Then, a 'go test' run with -coverprofile.
1414
# The total coverage after merging profiles should end up being 100%.
1515
# Marking all printlns as covered requires all edge cases to work well.
16-
# Go 1.20 learned to produce and merge multiple coverage profiles,
17-
# so versions before then report a shallow 0% coverage.
1816
go test -vet=off -coverprofile=cover.out -v
1917
stdout 'PASS'
20-
[go1.20] stdout 'coverage: 100\.0%'
21-
[!go1.20] stdout 'coverage: 0\.0%'
18+
stdout 'coverage: 100\.0%'
2219
! stdout 'malformed coverage' # written by "go test" if cover.out is invalid
2320
exists cover.out
2421

testscript/testdata/pty.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[!linux] [!darwin] skip
2-
[darwin] [go1.20] skip # https://go.dev/issue/61779
2+
[darwin] skip # https://go.dev/issue/61779
33

44
ttyin secretwords.txt
55
terminalprompt

testscript/testscript.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"go/build"
1717
"io"
1818
"io/fs"
19-
"io/ioutil"
2019
"os"
2120
"os/exec"
2221
"path/filepath"
@@ -262,14 +261,14 @@ func RunT(t T, p Params) {
262261
}
263262
testTempDir := p.WorkdirRoot
264263
if testTempDir == "" {
265-
testTempDir, err = ioutil.TempDir(os.Getenv("GOTMPDIR"), "go-test-script")
264+
testTempDir, err = os.MkdirTemp(os.Getenv("GOTMPDIR"), "go-test-script")
266265
if err != nil {
267266
t.Fatal(err)
268267
}
269268
} else {
270269
p.TestWork = true
271270
}
272-
// The temp dir returned by ioutil.TempDir might be a sym linked dir (default
271+
// The temp dir returned by os.MkdirTemp might be a sym linked dir (default
273272
// behaviour in macOS). That could mess up matching that includes $WORK if,
274273
// for example, an external program outputs resolved paths. Evaluating the
275274
// dir here will ensure consistency.
@@ -780,7 +779,7 @@ func (ts *TestScript) applyScriptUpdates() {
780779
panic("script update file not found")
781780
}
782781
}
783-
if err := ioutil.WriteFile(ts.file, txtar.Format(ts.archive), 0o666); err != nil {
782+
if err := os.WriteFile(ts.file, txtar.Format(ts.archive), 0o666); err != nil {
784783
ts.t.Fatal("cannot update script: ", err)
785784
}
786785
ts.Logf("%s updated", ts.file)
@@ -1174,7 +1173,7 @@ func (ts *TestScript) ReadFile(file string) string {
11741173
return ts.ttyout
11751174
default:
11761175
file = ts.MkAbs(file)
1177-
data, err := ioutil.ReadFile(file)
1176+
data, err := os.ReadFile(file)
11781177
ts.Check(err)
11791178
return string(data)
11801179
}

0 commit comments

Comments
 (0)