drop bits of code to support Go 1.19

pull/680/head
Daniel Martí 1 year ago
parent b322876efe
commit 658060851d

@ -354,7 +354,7 @@ func mainErr(args []string) error {
// Until https://github.com/golang/go/issues/50603 is implemented, // Until https://github.com/golang/go/issues/50603 is implemented,
// manually construct something like a pseudo-version. // manually construct something like a pseudo-version.
// TODO: remove when this code is dead, hopefully in Go 1.20. // TODO: remove when this code is dead, hopefully in Go 1.21.
if mod.Version == "(devel)" { if mod.Version == "(devel)" {
var vcsTime time.Time var vcsTime time.Time
var vcsRevision string var vcsRevision string
@ -794,15 +794,8 @@ func replaceAsmNames(buf *bytes.Buffer, remaining []byte) {
// If the name was qualified, fetch the package, and write the // If the name was qualified, fetch the package, and write the
// obfuscated import path if needed. // obfuscated import path if needed.
// Note that we don't obfuscate the package path "main". // Note that we don't obfuscate the package path "main".
//
// Note that runtime/internal/startlinetest refers to runtime_test in
// one of its assembly files, and we currently do not always collect
// test packages in appendListedPackages for the sake of performance.
// We don't care about testing the runtime just yet, so work around it.
// TODO(mvdan): this runtime_test reference was removed in Go 1.20 per
// https://github.com/golang/go/issues/57334; remove at a later time.
lpkg := curPkg lpkg := curPkg
if asmPkgPath != "" && asmPkgPath != "main" && asmPkgPath != "runtime_test" { if asmPkgPath != "" && asmPkgPath != "main" {
if asmPkgPath != curPkg.Name { if asmPkgPath != curPkg.Name {
goPkgPath := asmPkgPath goPkgPath := asmPkgPath
goPkgPath = strings.ReplaceAll(goPkgPath, string(asmPeriod), string(goPeriod)) goPkgPath = strings.ReplaceAll(goPkgPath, string(asmPeriod), string(goPeriod))

@ -315,8 +315,6 @@ func grepfiles(ts *testscript.TestScript, neg bool, args []string) {
anyFound := false anyFound := false
path, pattern := args[0], args[1] path, pattern := args[0], args[1]
rx := regexp.MustCompile(pattern) rx := regexp.MustCompile(pattern)
// TODO: use fs.SkipAll in Go 1.20 and later.
errSkipAll := fmt.Errorf("sentinel error: stop walking")
if err := filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error { if err := filepath.WalkDir(path, func(path string, d fs.DirEntry, err error) error {
if err != nil { if err != nil {
return err return err
@ -326,11 +324,11 @@ func grepfiles(ts *testscript.TestScript, neg bool, args []string) {
return fmt.Errorf("%q matches %q", path, pattern) return fmt.Errorf("%q matches %q", path, pattern)
} else { } else {
anyFound = true anyFound = true
return errSkipAll return fs.SkipAll
} }
} }
return nil return nil
}); err != nil && err != errSkipAll { }); err != nil {
ts.Fatalf("%s", err) ts.Fatalf("%s", err)
} }
if !neg && !anyFound { if !neg && !anyFound {

@ -278,22 +278,6 @@ func appendListedPackages(packages []string, withDeps bool) error {
pkg.GarbleActionID = addGarbleToHash(actionID) pkg.GarbleActionID = addGarbleToHash(actionID)
} }
// Work around https://go.dev/issue/28749:
// cmd/go puts assembly, C, and C++ files in CompiledGoFiles.
//
// TODO: Fixed in Go 1.20; remove once we drop support for Go 1.19.
out := pkg.CompiledGoFiles[:0]
for _, path := range pkg.CompiledGoFiles {
switch filepath.Ext(path) {
case "": // e.g. a generated Go file inside the build cache
case ".go":
default: // e.g. an assembly file
continue
}
out = append(out, path)
}
pkg.CompiledGoFiles = out
cache.ListedPackages[pkg.ImportPath] = &pkg cache.ListedPackages[pkg.ImportPath] = &pkg
} }

@ -28,8 +28,7 @@ cp stderr build-error.stderr
stdin build-error.stderr stdin build-error.stderr
garble reverse ./build-error garble reverse ./build-error
[!go1.20] cmp stdout build-error-reverse.stdout-go1.19 cmp stdout build-error-reverse.stdout
[go1.20] cmp stdout build-error-reverse.stdout-go1.20
[short] stop # no need to verify this with -short [short] stop # no need to verify this with -short
@ -157,12 +156,7 @@ main.main(...)
test/main/long_main.go:11 +0x?? test/main/long_main.go:11 +0x??
main filename: test/main/long_main.go main filename: test/main/long_main.go
-- build-error-reverse.stdout-go1.19 -- -- build-error-reverse.stdout --
# test/main/build-error
test/main/build-error/error.go:18: cannot convert UnobfuscatedStruct{} (value of type UnobfuscatedStruct) to type struct{SomeField int}
exit status 2
exit status 2
-- build-error-reverse.stdout-go1.20 --
# test/main/build-error # test/main/build-error
test/main/build-error/error.go:18: cannot convert UnobfuscatedStruct{} (value of type UnobfuscatedStruct) to type struct{SomeField int} test/main/build-error/error.go:18: cannot convert UnobfuscatedStruct{} (value of type UnobfuscatedStruct) to type struct{SomeField int}
exit status 2 exit status 2

Loading…
Cancel
Save