Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Oct 5, 2023
1 parent 14903c6 commit ebf1585
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
env:
GOEXPERIMENT: cgocheck2

- name: Build testcli binary
working-directory: internal/testcli/
run: go build

- name: Run library tests
run: go test -race -v ./...

Expand Down
15 changes: 8 additions & 7 deletions frankenphp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"net/url"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -554,21 +553,23 @@ func testFiberNoCgo(t *testing.T, opts *testOptions) {
}

func TestExecuteScriptCLI(t *testing.T) {
path, err := exec.LookPath("go")
assert.NoError(t, err)
t.Logf("Go path: %s\n", path)
t.Logf("Go arch: %s\n", runtime.GOARCH)
if _, err := os.Stat("internal/testcli/testcli"); err != nil {
t.Skip("internal/testcli/testcli has not been compiled, run `cd internal/testcli/ && go build`")
}

cmd := exec.Command("go", "run", "internal/testcli/main.go", "testdata/command.php", "foo", "bar")
cmd := exec.Command("internal/testcli/testcli", "testdata/command.php", "foo", "bar")
stdoutStderr, err := cmd.CombinedOutput()
assert.Error(t, err)

if exitError, ok := err.(*exec.ExitError); ok {
assert.Equal(t, 3, exitError.ExitCode())
}

stdoutStderrStr := string(stdoutStderr)

assert.Contains(t, stdoutStderrStr, `"foo"`)
assert.Contains(t, stdoutStderrStr, `"bar"`)
assert.Contains(t, stdoutStderrStr, "From the CLI")
assert.Contains(t, stdoutStderrStr, "exit status 3")
}

func ExampleServeHTTP() {
Expand Down

0 comments on commit ebf1585

Please sign in to comment.