Test / Create distribution (push) Successful in 59s
Test / Sandbox (push) Successful in 3m0s
Test / Hakurei (push) Successful in 4m48s
Test / Sandbox (race detector) (push) Successful in 6m6s
Test / Hakurei (race detector) (push) Successful in 7m32s
Test / ShareFS (push) Successful in 7m54s
Test / Flake checks (push) Successful in 1m19s
There is generally no use case where any setup is required before init, and requiring the explicit function call is error-prone and unnecessary. It also causes trouble with packages using a similar trick. This change moves argv0 check early and makes it an import side effect. The stub will be removed in v0.5. Signed-off-by: Ophestra <cat@gensokyo.uk>
43 lines
925 B
Go
43 lines
925 B
Go
package ldd_test
|
|
|
|
import (
|
|
"errors"
|
|
"os/exec"
|
|
"testing"
|
|
|
|
"hakurei.app/check"
|
|
"hakurei.app/ldd"
|
|
"hakurei.app/message"
|
|
)
|
|
|
|
func TestExec(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t.Run("failure", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, err := ldd.Resolve(t.Context(), nil, check.MustAbs("/proc/nonexistent"))
|
|
|
|
exitError, ok := errors.AsType[*exec.ExitError](err)
|
|
if !ok {
|
|
t.Fatalf("Exec: error has incorrect concrete type: %#v", err)
|
|
}
|
|
|
|
const want = 1
|
|
if got := exitError.ExitCode(); got != want {
|
|
t.Fatalf("Exec: ExitCode = %d, want %d", got, want)
|
|
}
|
|
})
|
|
|
|
t.Run("success", func(t *testing.T) {
|
|
msg := message.New(nil)
|
|
msg.GetLogger().SetPrefix("check: ")
|
|
if entries, err := ldd.Resolve(t.Context(), nil, nil); err != nil {
|
|
t.Fatalf("Exec: error = %v", err)
|
|
} else if testing.Verbose() {
|
|
// result cannot be measured here as build information is not known
|
|
t.Logf("Exec: %q", entries)
|
|
}
|
|
})
|
|
}
|