Skip to content

Commit ce69652

Browse files
alexandearchavacava
authored andcommitted
fix: cli tests on Windows; add tests-on-windows workflow
1 parent 74e2417 commit ce69652

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

.github/workflows/test.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
types: [opened, edited, synchronize, reopened]
66

77
jobs:
8-
test:
9-
name: Test
8+
tests-on-unix:
9+
name: Tests on Unix
1010
runs-on: ubuntu-latest
1111
strategy:
1212
fail-fast: false
@@ -23,3 +23,16 @@ jobs:
2323
go-version: ${{ matrix.go-version }}
2424
- name: Run tests
2525
run: go test -race -shuffle=on ./...
26+
27+
tests-on-windows:
28+
name: Tests on Windows
29+
runs-on: windows-latest
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
- name: Set up Go
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: stable
37+
- name: Run tests
38+
run: go test -race -shuffle=on ./...

cli/main_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"os"
5+
"path/filepath"
56
"testing"
67

78
"github.com/mitchellh/go-homedir"
@@ -22,19 +23,19 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
2223
AppFs = afero.NewMemMapFs()
2324
})
2425

25-
xdgDirPath := "/tmp-iofs/xdg/config"
26-
homeDirPath := "/tmp-iofs/home/tester"
26+
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
27+
homeDirPath := filepath.FromSlash("/tmp-iofs/home/tester")
2728
AppFs.MkdirAll(xdgDirPath, 0755)
2829
AppFs.MkdirAll(homeDirPath, 0755)
2930

30-
afero.WriteFile(AppFs, xdgDirPath+"/revive.toml", []byte("\n"), 0644)
31+
afero.WriteFile(AppFs, filepath.Join(xdgDirPath, "revive.toml"), []byte("\n"), 0644)
3132
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
3233

33-
afero.WriteFile(AppFs, homeDirPath+"/revive.toml", []byte("\n"), 0644)
34+
afero.WriteFile(AppFs, filepath.Join(homeDirPath, "revive.toml"), []byte("\n"), 0644)
3435
t.Setenv("HOME", homeDirPath)
3536

3637
got := buildDefaultConfigPath()
37-
want := xdgDirPath + "/revive.toml"
38+
want := filepath.Join(xdgDirPath, "revive.toml")
3839

3940
if got != want {
4041
t.Errorf("got %q, wanted %q", got, want)
@@ -43,14 +44,14 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
4344

4445
func TestHomeConfigDir(t *testing.T) {
4546
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
46-
homeDirPath := "/tmp-iofs/home/tester"
47+
homeDirPath := filepath.FromSlash("/tmp-iofs/home/tester")
4748
AppFs.MkdirAll(homeDirPath, 0755)
4849

49-
afero.WriteFile(AppFs, homeDirPath+"/revive.toml", []byte("\n"), 0644)
50+
afero.WriteFile(AppFs, filepath.Join(homeDirPath, "revive.toml"), []byte("\n"), 0644)
5051
t.Setenv("HOME", homeDirPath)
5152

5253
got := buildDefaultConfigPath()
53-
want := homeDirPath + "/revive.toml"
54+
want := filepath.Join(homeDirPath, "revive.toml")
5455

5556
if got != want {
5657
t.Errorf("got %q, wanted %q", got, want)
@@ -59,14 +60,14 @@ func TestHomeConfigDir(t *testing.T) {
5960

6061
func TestXDGConfigDir(t *testing.T) {
6162
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
62-
xdgDirPath := "/tmp-iofs/xdg/config"
63+
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
6364
AppFs.MkdirAll(xdgDirPath, 0755)
6465

65-
afero.WriteFile(AppFs, xdgDirPath+"/revive.toml", []byte("\n"), 0644)
66+
afero.WriteFile(AppFs, filepath.Join(xdgDirPath, "revive.toml"), []byte("\n"), 0644)
6667
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
6768

6869
got := buildDefaultConfigPath()
69-
want := xdgDirPath + "/revive.toml"
70+
want := filepath.Join(xdgDirPath, "revive.toml")
7071

7172
if got != want {
7273
t.Errorf("got %q, wanted %q", got, want)
@@ -75,7 +76,7 @@ func TestXDGConfigDir(t *testing.T) {
7576

7677
func TestXDGConfigDirNoFile(t *testing.T) {
7778
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
78-
xdgDirPath := "/tmp-iofs/xdg/config"
79+
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
7980
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
8081

8182
got := buildDefaultConfigPath()

0 commit comments

Comments
 (0)