Skip to content

Commit

Permalink
ci: run on mac and windows (#24)
Browse files Browse the repository at this point in the history
* ci: run on mac and windows

* ci: forgot windows

* windows: fix some tests
  • Loading branch information
shoenig authored Feb 19, 2023
1 parent 4d17c5f commit 9ecee7f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ name: Run CI Tests
on: [push]
jobs:
run-tests:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- macos-12
- windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: hashicorp/setup-golang@v1
with:
version-file: go.mod
Expand Down
18 changes: 17 additions & 1 deletion internal/commands/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"os"
"runtime"
"testing"

"github.com/google/subcommands"
Expand All @@ -15,6 +16,13 @@ import (
"github.com/shoenig/test/must"
)

func skipOS(t *testing.T) {
switch runtime.GOOS {
case "windows":
t.Skip("skipping on windows")
}
}

func TestExecCmd_Ops(t *testing.T) {
db := newDBFile(t)
defer cleanupFile(t, db)
Expand All @@ -28,6 +36,8 @@ func TestExecCmd_Ops(t *testing.T) {
}

func TestExecCmd_Execute(t *testing.T) {
skipOS(t)

box := safe.NewBoxMock(t)
defer box.MinimockFinish()

Expand Down Expand Up @@ -134,7 +144,13 @@ func TestExecCmd_Execute_badCommand(t *testing.T) {

must.Eq(t, subcommands.ExitFailure, rc)
must.Eq(t, "", a.String())
must.Eq(t, "envy: failed to exec: fork/exec /does/not/exist: no such file or directory\n", b.String())
must.Eq(t, "", c.String())
must.Eq(t, "", d.String())

switch runtime.GOOS {
case "windows":
must.Eq(t, "envy: failed to exec: exec: \"/does/not/exist\": file does not exist\n", b.String())
default:
must.Eq(t, "envy: failed to exec: fork/exec /does/not/exist: no such file or directory\n", b.String())
}
}
10 changes: 8 additions & 2 deletions internal/safe/safe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package safe

import (
"io/ioutil"
"strings"
"runtime"
"testing"

"github.com/shoenig/ignore"
Expand All @@ -15,7 +15,13 @@ func TestSafe_Path(t *testing.T) {
t.Run("default", func(t *testing.T) {
p, err := Path("")
must.NoError(t, err)
must.True(t, strings.HasSuffix(p, "/envy/envy.safe"))

switch runtime.GOOS {
case "windows":
must.StrHasSuffix(t, `\envy\envy.safe`, p)
default:
must.StrHasSuffix(t, "/envy/envy.safe", p)
}
})

t.Run("non-default", func(t *testing.T) {
Expand Down

0 comments on commit 9ecee7f

Please sign in to comment.