Skip to content

Commit

Permalink
tweak script/reverse.txtar to pass on both Go 1.22 and 1.23
Browse files Browse the repository at this point in the history
Updates burrowers#859.
  • Loading branch information
mvdan committed Sep 4, 2024
1 parent 239f91d commit 3645741
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions testdata/script/reverse.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func unexportedMainFunc() {
package lib

import (
"bytes"
"io"
"regexp"
"runtime"
Expand Down Expand Up @@ -109,19 +110,22 @@ func printStackTrace(w io.Writer) error {
stack := debug.Stack()
stack = rxCallArgs.ReplaceAll(stack, []byte("(...)"))
stack = rxPointer.ReplaceAll(stack, []byte("+0x??"))
_, err := w.Write(stack)

// Drop the second and third lines, as they show a position in runtime/debug
// which can change between Go versions.
stackLines := bytes.Split(stack, []byte("\n"))
stackLines = append(stackLines[:1], stackLines[3:]...)
_, err := w.Write(bytes.Join(stackLines, []byte("\n")))
return err
}
-- reverse.stdout --
lib filename: test/main/lib/long_lib.go

goroutine 1 [running]:
runtime/debug.Stack(...)
runtime/debug/stack.go:24 +0x??
test/main/lib.printStackTrace(...)
test/main/lib/long_lib.go:32 +0x??
test/main/lib/long_lib.go:33 +0x??
test/main/lib.(*ExportedLibType).ExportedLibMethod(...)
test/main/lib/long_lib.go:19 +0x??
test/main/lib/long_lib.go:20 +0x??
main.unexportedMainFunc.func1(...)
test/main/long_main.go:21
main.unexportedMainFunc(...)
Expand Down

0 comments on commit 3645741

Please sign in to comment.