Skip to content

Commit

Permalink
all: add Go 1.21, drop Go 1.19
Browse files Browse the repository at this point in the history
And fix up the tests and code to adapt accordingly.
While here, update the checkout action as well.
  • Loading branch information
mvdan committed Sep 26, 2023
1 parent 3fbe0b6 commit b6a9d8b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Expand Up @@ -12,16 +12,16 @@ jobs:
fail-fast: false
matrix:
go-version:
- '1.19.x'
- '1.20.x'
- '1.21.x'
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v4
with:
Expand All @@ -33,7 +33,7 @@ jobs:
go test -race ./...
- name: Tidy
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.20.x' # no need to do this everywhere
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.21.x' # no need to do this everywhere
run: |
go mod tidy
Expand Down
4 changes: 3 additions & 1 deletion cmd/testscript/testdata/noproxy.txt
@@ -1,10 +1,12 @@
# With no .gomodproxy supporting files, we use the GOPROXY from
# the environment.
# Note that Go 1.21 started quoting with single quotes in "go env",
# where older versions used double quotes.
env GOPROXY=0.1.2.3
unquote file.txt
testscript -v file.txt

-- file.txt --
>go env
>[!windows] stdout '^GOPROXY="0.1.2.3"$'
>[!windows] stdout '^GOPROXY=[''"]0.1.2.3[''"]$'
>[windows] stdout '^set GOPROXY=0.1.2.3$'
2 changes: 1 addition & 1 deletion go.mod
@@ -1,6 +1,6 @@
module github.com/rogpeppe/go-internal

go 1.19
go 1.20

require (
golang.org/x/mod v0.9.0
Expand Down
5 changes: 1 addition & 4 deletions gotooltest/testdata/cover.txt
Expand Up @@ -13,12 +13,9 @@ stdout 'PASS'
# Then, a 'go test' run with -coverprofile.
# The total coverage after merging profiles should end up being 100%.
# Marking all printlns as covered requires all edge cases to work well.
# Go 1.20 learned to produce and merge multiple coverage profiles,
# so versions before then report a shallow 0% coverage.
go test -vet=off -coverprofile=cover.out -v
stdout 'PASS'
[go1.20] stdout 'coverage: 100\.0%'
[!go1.20] stdout 'coverage: 0\.0%'
stdout 'coverage: 100\.0%'
! stdout 'malformed coverage' # written by "go test" if cover.out is invalid
exists cover.out

Expand Down
2 changes: 1 addition & 1 deletion testscript/testdata/pty.txt
@@ -1,5 +1,5 @@
[!linux] [!darwin] skip
[darwin] [go1.20] skip # https://go.dev/issue/61779
[darwin] skip # https://go.dev/issue/61779

ttyin secretwords.txt
terminalprompt
Expand Down
9 changes: 4 additions & 5 deletions testscript/testscript.go
Expand Up @@ -16,7 +16,6 @@ import (
"go/build"
"io"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -262,14 +261,14 @@ func RunT(t T, p Params) {
}
testTempDir := p.WorkdirRoot
if testTempDir == "" {
testTempDir, err = ioutil.TempDir(os.Getenv("GOTMPDIR"), "go-test-script")
testTempDir, err = os.MkdirTemp(os.Getenv("GOTMPDIR"), "go-test-script")
if err != nil {
t.Fatal(err)
}
} else {
p.TestWork = true
}
// The temp dir returned by ioutil.TempDir might be a sym linked dir (default
// The temp dir returned by os.MkdirTemp might be a sym linked dir (default
// behaviour in macOS). That could mess up matching that includes $WORK if,
// for example, an external program outputs resolved paths. Evaluating the
// dir here will ensure consistency.
Expand Down Expand Up @@ -780,7 +779,7 @@ func (ts *TestScript) applyScriptUpdates() {
panic("script update file not found")
}
}
if err := ioutil.WriteFile(ts.file, txtar.Format(ts.archive), 0o666); err != nil {
if err := os.WriteFile(ts.file, txtar.Format(ts.archive), 0o666); err != nil {
ts.t.Fatal("cannot update script: ", err)
}
ts.Logf("%s updated", ts.file)
Expand Down Expand Up @@ -1174,7 +1173,7 @@ func (ts *TestScript) ReadFile(file string) string {
return ts.ttyout
default:
file = ts.MkAbs(file)
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
ts.Check(err)
return string(data)
}
Expand Down

0 comments on commit b6a9d8b

Please sign in to comment.