mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
fix: cli tests on Windows; add tests-on-windows workflow
This commit is contained in:
committed by
chavacava
parent
74e2417f7d
commit
ce6965265a
17
.github/workflows/test.yaml
vendored
17
.github/workflows/test.yaml
vendored
@@ -5,8 +5,8 @@ on:
|
||||
types: [opened, edited, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test
|
||||
tests-on-unix:
|
||||
name: Tests on Unix
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -23,3 +23,16 @@ jobs:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Run tests
|
||||
run: go test -race -shuffle=on ./...
|
||||
|
||||
tests-on-windows:
|
||||
name: Tests on Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
- name: Run tests
|
||||
run: go test -race -shuffle=on ./...
|
||||
|
||||
@@ -2,6 +2,7 @@ package cli
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/go-homedir"
|
||||
@@ -22,19 +23,19 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
|
||||
AppFs = afero.NewMemMapFs()
|
||||
})
|
||||
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
homeDirPath := "/tmp-iofs/home/tester"
|
||||
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
|
||||
homeDirPath := filepath.FromSlash("/tmp-iofs/home/tester")
|
||||
AppFs.MkdirAll(xdgDirPath, 0755)
|
||||
AppFs.MkdirAll(homeDirPath, 0755)
|
||||
|
||||
afero.WriteFile(AppFs, xdgDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(xdgDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
|
||||
|
||||
afero.WriteFile(AppFs, homeDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(homeDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("HOME", homeDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
want := xdgDirPath + "/revive.toml"
|
||||
want := filepath.Join(xdgDirPath, "revive.toml")
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
@@ -43,14 +44,14 @@ func TestXDGConfigDirIsPreferredFirst(t *testing.T) {
|
||||
|
||||
func TestHomeConfigDir(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
homeDirPath := "/tmp-iofs/home/tester"
|
||||
homeDirPath := filepath.FromSlash("/tmp-iofs/home/tester")
|
||||
AppFs.MkdirAll(homeDirPath, 0755)
|
||||
|
||||
afero.WriteFile(AppFs, homeDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(homeDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("HOME", homeDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
want := homeDirPath + "/revive.toml"
|
||||
want := filepath.Join(homeDirPath, "revive.toml")
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
@@ -59,14 +60,14 @@ func TestHomeConfigDir(t *testing.T) {
|
||||
|
||||
func TestXDGConfigDir(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
|
||||
AppFs.MkdirAll(xdgDirPath, 0755)
|
||||
|
||||
afero.WriteFile(AppFs, xdgDirPath+"/revive.toml", []byte("\n"), 0644)
|
||||
afero.WriteFile(AppFs, filepath.Join(xdgDirPath, "revive.toml"), []byte("\n"), 0644)
|
||||
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
want := xdgDirPath + "/revive.toml"
|
||||
want := filepath.Join(xdgDirPath, "revive.toml")
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q, wanted %q", got, want)
|
||||
@@ -75,7 +76,7 @@ func TestXDGConfigDir(t *testing.T) {
|
||||
|
||||
func TestXDGConfigDirNoFile(t *testing.T) {
|
||||
t.Cleanup(func() { AppFs = afero.NewMemMapFs() })
|
||||
xdgDirPath := "/tmp-iofs/xdg/config"
|
||||
xdgDirPath := filepath.FromSlash("/tmp-iofs/xdg/config")
|
||||
t.Setenv("XDG_CONFIG_HOME", xdgDirPath)
|
||||
|
||||
got := buildDefaultConfigPath()
|
||||
|
||||
Reference in New Issue
Block a user