b9a844ecee
* feat: run ~always netxlite integration tests This diff ensures that we check on windows, linux, macos that our fundamental networking library (netxlite) works. We combine unit and integration tests. This work is part of https://github.com/ooni/probe/issues/1733, where I want to have more strong guarantees about the foundations. * fix(filtering/tls_test.go): make portable on Windows The trick here is to use the wrapped error so to normalize the different errors messages we see on Windows. * fix(netxlite/quic_test.go): make portable on windows Rather than using the zero port, use the `x` port which fails when the stdlib is parsing the address. The zero port seems to work on Windows while it does not on Unix. * fix(serialresolver_test.go): make error more timeout than before This seems enough to convince Go on Windows about this error being really a timeout timeouty timeouted thingie.
25 lines
625 B
Go
25 lines
625 B
Go
// Package runtimex contains runtime extensions. This package is inspired to
|
|
// https://pkg.go.dev/github.com/m-lab/go/rtx, except that it's simpler.
|
|
package runtimex
|
|
|
|
import "fmt"
|
|
|
|
// PanicOnError calls panic() if err is not nil.
|
|
func PanicOnError(err error, message string) {
|
|
if err != nil {
|
|
panic(fmt.Errorf("%s: %w", message, err))
|
|
}
|
|
}
|
|
|
|
// PanicIfFalse calls panic if assertion is false.
|
|
func PanicIfFalse(assertion bool, message string) {
|
|
if !assertion {
|
|
panic(message)
|
|
}
|
|
}
|
|
|
|
// PanicIfTrue calls panic if assertion is true.
|
|
func PanicIfTrue(assertion bool, message string) {
|
|
PanicIfFalse(!assertion, message)
|
|
}
|