Skip to content

Commit 03c2dcd

Browse files
committed
More maintainable version of stack test
1 parent 5e02f33 commit 03c2dcd

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

plugins/hls-alternate-number-format-plugin/src/Ide/Plugin/Conversion.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ toBase conv header n
160160
| otherwise = header <> upper (conv n "")
161161

162162
#if MIN_VERSION_base(4,17,0)
163-
toOctal, toDecimal, toBinary, toHex :: Integral a => a -> String
163+
toOctal, toBinary, toHex :: Integral a => a -> String
164164
#else
165-
toOctal, toDecimal, toBinary, toHex:: (Integral a, Show a) => a -> String
165+
toOctal, toBinary, toHex:: (Integral a, Show a) => a -> String
166166
#endif
167167

168168
toBinary = toBase showBin_ "0b"
@@ -172,10 +172,11 @@ toBinary = toBase showBin_ "0b"
172172

173173
toOctal = toBase showOct "0o"
174174

175-
toDecimal = toBase showInt ""
176-
177175
toHex = toBase showHex "0x"
178176

177+
toDecimal :: Integral a => a -> String
178+
toDecimal = toBase showInt ""
179+
179180
toFloatDecimal :: RealFloat a => a -> String
180181
toFloatDecimal val = showFFloat Nothing val ""
181182

test/wrapper/Main.hs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,24 @@ main = defaultTestRunner $ testGroup "haskell-language-server-wrapper" [projectG
99

1010
projectGhcVersionTests :: TestTree
1111
projectGhcVersionTests = testGroup "--project-ghc-version"
12-
[ let ghcVer = case ghcVersion of
13-
GHC92 -> "9.2.8"
14-
GHC94 -> "9.4.8"
15-
GHC96 -> "9.6.4"
16-
GHC98 -> "9.8.1"
17-
writeStackYaml = writeFile "stack.yaml"
12+
[ testCase "stack with global ghc" $ do
13+
ghcVer <- ghcNumericVersion
14+
let writeStackYaml = writeFile "stack.yaml" $
1815
-- Use system-ghc and install-ghc to avoid stack downloading ghc in CI
1916
-- (and use ghcup-managed ghc instead)
20-
("{resolver: ghc-"++ ghcVer ++", system-ghc: true, install-ghc: false}")
21-
in testCase ("stack with ghc " ++ ghcVer) $
22-
testDir writeStackYaml "test/wrapper/testdata/stack-specific-ghc" ghcVer
17+
"{resolver: ghc-" ++ ghcVer ++ ", system-ghc: true, install-ghc: false}"
18+
testDir writeStackYaml "test/wrapper/testdata/stack-specific-ghc" ghcVer
2319
, testCase "cabal with global ghc" $ do
24-
ghcVer <- trimEnd <$> readProcess "ghc" ["--numeric-version"] ""
20+
ghcVer <- ghcNumericVersion
2521
testDir (pure ()) "test/wrapper/testdata/cabal-cur-ver" ghcVer
2622
, testCase "stack with existing cabal build artifact" $ do
2723
-- Should report cabal as existing build artifacts are more important than
2824
-- the existence of 'stack.yaml'
2925
testProjectType "test/wrapper/testdata/stack-with-dist-newstyle"
3026
("cradleOptsProg = CradleAction: Cabal" `isInfixOf`)
3127
]
28+
where
29+
ghcNumericVersion = trimEnd <$> readProcess "ghc" ["--numeric-version"] ""
3230

3331
testDir :: IO () -> FilePath -> String -> Assertion
3432
testDir extraSetup dir expectedVer =

0 commit comments

Comments
 (0)