fix: use golang.org/x/sys/execabs (#224)

Closes https://github.com/ooni/probe-engine/issues/1195
This commit is contained in:
Simone Basso 2021-02-10 07:40:48 +01:00 committed by GitHub
commit 18ca6d5f35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 20 deletions

View file

@ -7,12 +7,13 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"os/exec"
"runtime"
"strings"
"testing"
"time"
"golang.org/x/sys/execabs"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/resolver"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
@ -295,7 +296,7 @@ func TestHijackHTTP(t *testing.T) {
if err == nil {
t.Fatal("expected an error here")
}
var exitErr *exec.ExitError
var exitErr *execabs.ExitError
if !errors.As(err, &exitErr) {
t.Fatal("not the error type we expected")
}
@ -335,7 +336,7 @@ func TestHijackHTTPS(t *testing.T) {
t.Fatal("expected an error here")
}
t.Log(err)
var exitErr *exec.ExitError
var exitErr *execabs.ExitError
if !errors.As(err, &exitErr) {
t.Fatal("not the error type we expected")
}

View file

@ -10,11 +10,12 @@ import (
"net"
"net/http"
"os"
"os/exec"
"os/signal"
"strings"
"syscall"
"golang.org/x/sys/execabs"
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
"github.com/miekg/dns"
@ -243,7 +244,7 @@ func mustx(err error, message string, osExit func(int)) {
if err != nil {
var (
exitcode = 1
exiterr *exec.ExitError
exiterr *execabs.ExitError
)
if errors.As(err, &exiterr) {
exitcode = exiterr.ExitCode()