tests: fix tests on Go 1.23 (#3697)

* Adjust rtype.go script to handle constants moved to internal/abi from
  runtime
* Remove tests in service/dap/server_test that relied on knowledge of
  the internal layout of channels.
This commit is contained in:
Alessandro Arzilli
2024-04-11 18:40:57 +02:00
committed by GitHub
parent d7f104bf9c
commit 2e88b7ead3
5 changed files with 25 additions and 16 deletions

View File

@ -619,7 +619,7 @@ func check() {
for _, C := range Cs {
rules := checkConstValRules[C]
pos := fset.Position(rules[0].pos)
def := lookupPackage(pkgmap, "runtime").Types.Scope().Lookup(C)
def := findConst(pkgmap, C)
if def == nil {
fmt.Fprintf(os.Stderr, "%s:%d: could not find constant %s\n", pos.Filename, pos.Line, C)
allok = false
@ -655,6 +655,21 @@ func fieldTypeByName(typ *types.Struct, name string) types.Type {
return nil
}
func findConst(pkgmap map[string]*packages.Package, Cs string) types.Object {
for _, C := range strings.Split(Cs, "|") {
pkg := lookupPackage(pkgmap, "runtime")
if dot := strings.Index(C, "."); dot >= 0 {
pkg = lookupPackage(pkgmap, C[:dot])
C = C[dot+1:]
}
def := pkg.Types.Scope().Lookup(C)
if def != nil {
return def
}
}
return nil
}
func matchType(typ types.Type, T string) bool {
if T == "anytype" {
return true