Skip to content

Commit

Permalink
Fix windows ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed Jan 14, 2025
1 parent cfb0529 commit 30ded24
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
name: Unit tests upload
if: ${{ failure() && steps.unit.conclusion == 'failure' }}
with:
name: unit-tests-artifacts
name: unit-tests-artifacts-${{ matrix.os }}
path: |
test/unit/goldens
Expand All @@ -63,7 +63,7 @@ jobs:
name: Functional tests upload
if: ${{ failure() && steps.functional.conclusion == 'failure' }}
with:
name: functional-tests-artifacts
name: functional-tests-artifacts-${{ matrix.os }}
path: |
test/functional/goldens
Expand Down
7 changes: 7 additions & 0 deletions src/Pacer/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ module Pacer.Prelude
currentOsStr,
isPosix,
posixWindowsStr,
posixWindowsOsPath,

-- * Misc
pattern SetToSeqNE,
Expand Down Expand Up @@ -604,6 +605,12 @@ isPosix = case currentOs of
Windows -> False
_ -> True

posixWindowsOsPath :: OsPath
posixWindowsOsPath =
if isPosix
then [osp|posix|]
else [osp|windows|]

posixWindowsStr :: String
posixWindowsStr =
if isPosix
Expand Down
51 changes: 29 additions & 22 deletions test/unit/Unit/Pacer/Command/Chart/Params.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ successTests =

testEvolvePhaseCliPaths :: TestTree
testEvolvePhaseCliPaths =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Uses CLI paths",
testName = [osp|testEvolvePhaseCliPaths|],
Expand All @@ -79,7 +79,7 @@ testEvolvePhaseCliPaths =

testEvolvePhaseCliData :: TestTree
testEvolvePhaseCliData =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Uses CLI data",
testName = [osp|testEvolvePhaseCliData|],
Expand All @@ -105,7 +105,7 @@ testEvolvePhaseCliData =

testEvolvePhaseConfigPaths :: TestTree
testEvolvePhaseConfigPaths =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Uses config paths",
testName = [osp|testEvolvePhaseConfigPaths|],
Expand Down Expand Up @@ -133,7 +133,7 @@ testEvolvePhaseConfigPaths =

testEvolvePhaseConfigData :: TestTree
testEvolvePhaseConfigData =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Uses config data",
testName = [osp|testEvolvePhaseConfigData|],
Expand Down Expand Up @@ -161,7 +161,7 @@ testEvolvePhaseConfigData =

testEvolvePhaseXdgPaths :: TestTree
testEvolvePhaseXdgPaths =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Uses xdg paths",
testName = [osp|testEvolvePhaseXdgPaths|],
Expand Down Expand Up @@ -200,7 +200,7 @@ failureTests =

testEvolvePhaseCliPathsEx :: TestTree
testEvolvePhaseCliPathsEx =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Exception for unknown CLI paths",
testName = [osp|testEvolvePhaseCliPathsEx|],
Expand All @@ -225,7 +225,7 @@ testEvolvePhaseCliPathsEx =

testEvolvePhaseConfigPathsEx :: TestTree
testEvolvePhaseConfigPathsEx =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Exception for unknown config paths",
testName = [osp|testEvolvePhaseConfigPathsEx|],
Expand All @@ -250,7 +250,7 @@ testEvolvePhaseConfigPathsEx =

testEvolvePhaseMissingEx :: TestTree
testEvolvePhaseMissingEx =
testGoldenParams
testGoldenParamsOs
$ MkGoldenParams
{ testDesc = "Exception for missing paths",
testName = [osp|testEvolvePhaseMissingEx|],
Expand Down Expand Up @@ -287,17 +287,18 @@ runEvolvePhase xdg params mToml = do
env =
MkMockEnv
{ knownFiles =
Set.fromList
[ [osp|/root/cli-cr.toml|],
[osp|/root/cli-runs.toml|],
[osp|/root/cli-data/chart-requests.toml|],
[osp|/root/cli-data/runs.toml|],
[osp|/root/config-cr.toml|],
[osp|/root/config-runs.toml|],
[osp|/root/config-data/chart-requests.toml|],
[osp|/root/config-data/runs.toml|],
[osp|/root/xdg/config/pacer/chart-requests.toml|],
[osp|/root/xdg/config/pacer/runs.toml|]
Set.fromList $
(root </>) <$>
[ [ospPathSep|cli-cr.toml|],
[ospPathSep|cli-runs.toml|],
[ospPathSep|cli-data/chart-requests.toml|],
[ospPathSep|cli-data/runs.toml|],
[ospPathSep|config-cr.toml|],
[ospPathSep|config-runs.toml|],
[ospPathSep|config-data/chart-requests.toml|],
[ospPathSep|config-data/runs.toml|],
[ospPathSep|xdg/config/pacer/chart-requests.toml|],
[ospPathSep|xdg/config/pacer/runs.toml|]
],
xdg
}
Expand All @@ -318,7 +319,7 @@ runPathReaderMock ::
Eff (PathReader : es) a ->
Eff es a
runPathReaderMock = interpret_ $ \case
CanonicalizePath p -> pure $ [osp|/root|] </> p
CanonicalizePath p -> pure $ root </> p
DoesFileExist p -> do
knownFiles <- asks @MockEnv (.knownFiles)
pure $ p `Set.member` knownFiles
Expand All @@ -328,8 +329,8 @@ runPathReaderMock = interpret_ $ \case
xdg <- asks @MockEnv (.xdg)
pure
$ if xdg
then [osp|/root/xdg/config|] </> p
else [osp|/root/bad_xdg/config|] </> p
then root </> [ospPathSep|xdg/config|] </> p
else root </> [ospPathSep|bad_xdg/config|] </> p
_ -> error $ "runPathReaderMock: unexpected xdg type: " <> show d
_ -> error $ "runPathReaderMock: unimplemented"

Expand All @@ -343,3 +344,9 @@ goldenRunnerXdg xdg params toml = do
-- displayInner over displayException since we do not want unstable
-- callstacks in output.
Left ex -> encodeUtf8 $ packText $ Ann.displayInner ex

root :: OsPath
root =
if isPosix
then [osp|/root|]
else [osp|c:\\root|]
9 changes: 9 additions & 0 deletions test/unit/Unit/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Unit.Prelude
-- * Golden
GoldenParams (..),
testGoldenParams,
testGoldenParamsOs,

-- * Parsing
parseOrDie,
Expand Down Expand Up @@ -181,6 +182,14 @@ data GoldenParams = MkGoldenParams
runner :: IO ByteString
}

testGoldenParamsOs :: GoldenParams -> TestTree
testGoldenParamsOs goldenParams = testGoldenParams goldenParams'
where
goldenParams' =
goldenParams
{ testName = goldenParams.testName <> ([osp|_|] <> posixWindowsOsPath)
}

testGoldenParams :: GoldenParams -> TestTree
testGoldenParams goldenParams =
goldenVsFile goldenParams.testDesc goldenPath actualPath $ do
Expand Down
7 changes: 7 additions & 0 deletions test/unit/goldens/testEvolvePhaseCliData_windows.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MkChartParams
{ cleanInstall = False
, chartRequestsPath = "c:\\root\cli-data\chart-requests.toml"
, dataDir = ()
, json = False
, runsPath = "c:\\root\cli-data\runs.toml"
}
1 change: 1 addition & 0 deletions test/unit/goldens/testEvolvePhaseCliPathsEx_windows.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File not found: c:\\root\bad_cr.toml
7 changes: 7 additions & 0 deletions test/unit/goldens/testEvolvePhaseCliPaths_windows.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MkChartParams
{ cleanInstall = False
, chartRequestsPath = "c:\\root\cli-cr.toml"
, dataDir = ()
, json = False
, runsPath = "c:\\root\cli-runs.toml"
}
7 changes: 7 additions & 0 deletions test/unit/goldens/testEvolvePhaseConfigData_windows.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MkChartParams
{ cleanInstall = False
, chartRequestsPath = "c:\\root\config-data\chart-requests.toml"
, dataDir = ()
, json = False
, runsPath = "c:\\root\config-data\runs.toml"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File not found: c:\\root\bad-cr.toml
7 changes: 7 additions & 0 deletions test/unit/goldens/testEvolvePhaseConfigPaths_windows.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MkChartParams
{ cleanInstall = False
, chartRequestsPath = "c:\\root\config-cr.toml"
, dataDir = ()
, json = False
, runsPath = "c:\\root\config-runs.toml"
}
4 changes: 4 additions & 0 deletions test/unit/goldens/testEvolvePhaseMissingEx_windows.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Required chart file not found. Searched for paths(s) [chart-requests.toml] in directories:
- some-dir
- some-config-data
- c:\\root\bad_xdg\config\pacer\
7 changes: 7 additions & 0 deletions test/unit/goldens/testEvolvePhaseXdgPaths_windows.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MkChartParams
{ cleanInstall = False
, chartRequestsPath = "c:\\root\xdg\config\pacer\chart-requests.toml"
, dataDir = ()
, json = False
, runsPath = "c:\\root\xdg\config\pacer\runs.toml"
}

0 comments on commit 30ded24

Please sign in to comment.