mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
testing: avoid Goexit without unwind support
Goexit cannot run deferred functions on architectures without panic unwinding. Query runtime.supportsRecover before calling it so unsupported targets report an error instead of leaving the test runner blocked forever.
This commit is contained in:
committed by
Damian Gryski
parent
9e7d89d4d5
commit
9e9be09e9a
+12
-2
@@ -25,6 +25,7 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
// Testing flags.
|
||||
@@ -215,7 +216,10 @@ func (c *common) Failed() bool {
|
||||
func (c *common) FailNow() {
|
||||
c.Fail()
|
||||
c.finished = true
|
||||
runtime.Goexit()
|
||||
if supportsRecover() {
|
||||
runtime.Goexit()
|
||||
}
|
||||
c.Error("FailNow is incomplete, requires runtime.Goexit()")
|
||||
}
|
||||
|
||||
// log generates the output.
|
||||
@@ -287,13 +291,19 @@ func (c *common) Skipf(format string, args ...any) {
|
||||
func (c *common) SkipNow() {
|
||||
c.skip()
|
||||
c.finished = true
|
||||
runtime.Goexit()
|
||||
if supportsRecover() {
|
||||
runtime.Goexit()
|
||||
}
|
||||
c.Error("SkipNow is incomplete, requires runtime.Goexit()")
|
||||
}
|
||||
|
||||
func (c *common) skip() {
|
||||
c.skipped = true
|
||||
}
|
||||
|
||||
//go:linkname supportsRecover runtime.supportsRecover
|
||||
func supportsRecover() bool
|
||||
|
||||
// Skipped reports whether the test was skipped.
|
||||
func (c *common) Skipped() bool {
|
||||
return c.skipped
|
||||
|
||||
Reference in New Issue
Block a user