Skip to content

Commit 5233811

Browse files
committed
Require GHC 9.10.1
1 parent 1835022 commit 5233811

File tree

7 files changed

+55
-32
lines changed

7 files changed

+55
-32
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ jobs:
2020
runs-on: ${{ matrix.os }}
2121

2222
strategy:
23-
fail-fast: true
23+
fail-fast: false
2424
matrix:
2525
os:
2626
- ubuntu-latest
27+
- macos-latest
2728
ghc:
28-
- '9.6'
29-
- '9.8'
30-
- '9.10'
31-
include:
32-
- os: macos-latest
33-
ghc: '9.10'
29+
- 9.10.1
3430
steps:
3531
- uses: actions/checkout@v4
3632
- uses: hspec/setup-haskell@v1
@@ -40,6 +36,14 @@ jobs:
4036
with:
4137
caching: true
4238

39+
- shell: bash
40+
run: |
41+
for GHC in 9.4 9.6 9.8
42+
do
43+
ghcup install ghc $GHC --no-set
44+
SENSEI_GHC=ghc-$GHC $(cabal list-bin spec)
45+
done
46+
4347
- run: echo "name=sensei-$(uname -s)-$(uname -m).tar.gz" >> $GITHUB_OUTPUT
4448
id: archive
4549

@@ -52,7 +56,6 @@ jobs:
5256
name: ${{ steps.archive.outputs.name }}
5357
path: ${{ steps.archive.outputs.name }}
5458
compression-level: 0
55-
if: matrix.ghc == '9.10'
5659

5760
success:
5861
needs: build

cabal.project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
with-compiler: ghc-9.10.1
2+
13
packages: .
24

35
program-options

src/Language/Haskell/GhciWrapper.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Language.Haskell.GhciWrapper (
1313
, reload
1414

1515
#ifdef TEST
16+
, sensei_ghc
1617
, sensei_ghc_version
1718
, lookupGhc
1819
, lookupGhcVersion
@@ -41,8 +42,11 @@ import qualified GHC.Diagnostic as Diagnostic
4142
sensei_ghc_version :: String
4243
sensei_ghc_version = "SENSEI_GHC_VERSION"
4344

45+
sensei_ghc :: String
46+
sensei_ghc = "SENSEI_GHC"
47+
4448
lookupGhc :: [(String, String)] -> FilePath
45-
lookupGhc = fromMaybe "ghc" . lookup "SENSEI_GHC"
49+
lookupGhc = fromMaybe "ghc" . lookup sensei_ghc
4650

4751
lookupGhcVersion :: [(String, String)] -> Maybe String
4852
lookupGhcVersion = lookup sensei_ghc_version

test/Helper.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ module Helper (
3030
, to_json
3131

3232
, requireGhc
33+
, ifGhc
34+
3335
, ensureFile
3436
) where
3537

@@ -150,10 +152,18 @@ to_json :: ToJSON a => a -> ByteString
150152
to_json = toStrict . encode
151153

152154
requireGhc :: [Int] -> IO ()
153-
requireGhc (makeVersion -> required) = do
155+
requireGhc = ifGhc >=> (`unless` pending)
156+
157+
ifGhc :: [Int] -> IO Bool
158+
ifGhc (makeVersion -> required) = do
159+
ghcVersion <- getGhcVersion
160+
return (ghcVersion >= required)
161+
162+
getGhcVersion :: IO Version
163+
getGhcVersion = do
154164
env <- getEnvironment
155165
let Just ghcVersion = lookupGhcVersion env >>= parseVersion
156-
when (ghcVersion < required) pending
166+
return ghcVersion
157167

158168
ensureFile :: FilePath -> ByteString -> IO ()
159169
ensureFile name new = do

test/Language/Haskell/GhciWrapperSpec.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,16 @@ spec = do
155155
withModule \ file -> do
156156
withInterpreter [file] \ ghci -> do
157157
failingModule file
158-
snd <$> Interpreter.reload ghci `shouldReturn` (Failed, [
159-
#if __GLASGOW_HASKELL__ >= 910
160-
Annotated diagnostic {
161-
span = Just $ Span file (Location 2 7) (Location 2 10)
162-
, code = Just 88464
163-
, message = ["Variable not in scope: bar"]
164-
} (Just $ NotInScope "bar") []
165-
#endif
166-
])
158+
diagnostics <- ifGhc [9,10] <&> \ case
159+
True -> [
160+
Annotated diagnostic {
161+
span = Just $ Span file (Location 2 7) (Location 2 10)
162+
, code = Just 88464
163+
, message = ["Variable not in scope: bar"]
164+
} (Just $ NotInScope "bar") []
165+
]
166+
False -> []
167+
snd <$> Interpreter.reload ghci `shouldReturn` (Failed, diagnostics)
167168

168169
context "with -fno-diagnostics-as-json" $ do
169170
it "does not extract diagnostics" do

test/SpecHook.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ getGhcVersion ghc = do
2222

2323
setPackageEnvironment :: IO ()
2424
setPackageEnvironment = do
25+
lookupEnv ("SENSEI_GHC_TEST") >>= maybe pass (setEnv Interpreter.sensei_ghc)
2526
dir <- getCurrentDirectory
2627
env <- getEnvironment
2728
let ghc = Interpreter.lookupGhc env

test/TriggerSpec.hs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module TriggerSpec (spec) where
33

44
import Helper
55

6+
import qualified Data.Text as Text
7+
68
import qualified Session
79
import Session (Session)
810
import Language.Haskell.GhciWrapper (Config(..))
@@ -11,7 +13,7 @@ import Trigger hiding (trigger, triggerAll)
1113
import qualified Trigger
1214

1315
normalize :: String -> [String]
14-
normalize = normalizeTiming . lines
16+
normalize = normalizeTiming . lines . forGhc9dot4
1517
where
1618
normalizeTiming :: [String] -> [String]
1719
normalizeTiming = normalizeLine "Finished in "
@@ -23,6 +25,11 @@ normalize = normalizeTiming . lines
2325
| message `isPrefixOf` line = message ++ "..."
2426
| otherwise = line
2527

28+
forGhc9dot4 :: String -> String
29+
forGhc9dot4 = Text.unpack
30+
. Text.replace " error: Variable not in scope: " " error: [GHC-88464] Variable not in scope: "
31+
. Text.pack
32+
2633
withSession :: FilePath -> [String] -> (Session -> IO a) -> IO a
2734
withSession specPath args = do
2835
Session.withSession ghciConfig {configWorkingDirectory = Just dir} $
@@ -155,19 +162,14 @@ spec = do
155162
it "stops after reloading" $ \ name -> do
156163
withSession name [] $ \ session -> do
157164
writeFile name (passingSpec ++ "foo = bar")
158-
(trigger session >> trigger session) `shouldReturn` (Failure, [
165+
166+
let
167+
fitterNotNull :: [String] -> [String]
168+
fitterNotNull = filter (not . null)
169+
170+
(fmap fitterNotNull <$> (trigger session >> trigger session)) `shouldReturn` (Failure, [
159171
"[1 of 1] Compiling Spec"
160-
#if __GLASGOW_HASKELL__ < 910
161-
, ""
162-
#endif
163-
#if __GLASGOW_HASKELL__ >= 906
164172
, "Spec.hs:9:7: error: [GHC-88464] Variable not in scope: bar"
165-
#else
166-
, "Spec.hs:9:7: error: Variable not in scope: bar"
167-
#endif
168-
#if __GLASGOW_HASKELL__ >= 910
169-
, ""
170-
#endif
171173
, withColor Red "RELOADING FAILED"
172174
])
173175

0 commit comments

Comments
 (0)