| 12 | ) |
| 13 | |
| 14 | func TestExecuteScriptCLI(t *testing.T) { |
| 15 | if _, err := os.Stat("internal/testcli/testcli"); err != nil { |
| 16 | t.Skip("internal/testcli/testcli has not been compiled, run `cd internal/testcli/ && go build`") |
| 17 | } |
| 18 | |
| 19 | cmd := exec.Command("internal/testcli/testcli", "testdata/command.php", "foo", "bar") |
| 20 | stdoutStderr, err := cmd.CombinedOutput() |
| 21 | assert.Error(t, err) |
| 22 | |
| 23 | var exitError *exec.ExitError |
| 24 | if errors.As(err, &exitError) { |
| 25 | assert.Equal(t, 3, exitError.ExitCode()) |
| 26 | } |
| 27 | |
| 28 | stdoutStderrStr := string(stdoutStderr) |
| 29 | |
| 30 | assert.Contains(t, stdoutStderrStr, `"foo"`) |
| 31 | assert.Contains(t, stdoutStderrStr, `"bar"`) |
| 32 | assert.Contains(t, stdoutStderrStr, "From the CLI") |
| 33 | } |
| 34 | |
| 35 | func TestExecuteCLICode(t *testing.T) { |
| 36 | if _, err := os.Stat("internal/testcli/testcli"); err != nil { |