This repository was archived by the owner on Oct 18, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 11{-# LANGUAGE TemplateHaskell #-}
22module Amc.Explain.TH where
33
4+ import Control.Exception
5+
46import Language.Haskell.TH.Syntax
57import Language.Haskell.TH
68
79import System.FilePath
10+ import System.IO
811
912qReadFile :: FilePath -> Q String
1013qReadFile path = do
1114 qAddDependentFile path
12- str <- qRunIO (readFile path)
13- length str `seq` pure str
15+ qRunIO $
16+ withFile path ReadMode $ \ handle -> do
17+ hSetEncoding handle utf8
18+ s <- hGetContents handle
19+ _ <- evaluate (length s)
20+ pure s
1421
1522qReadFilesList :: FilePath -> Q [FilePath ]
1623qReadFilesList path = do
1724 qAddDependentFile path
18- contents <- qRunIO (readFile path)
25+ contents <- qRunIO $
26+ withFile path ReadMode $ \ handle -> do
27+ hSetEncoding handle utf8
28+ s <- hGetContents handle
29+ _ <- evaluate (length s)
30+ pure s
1931 let files = lines contents
2032 fileP = map (head . words ) files
2133 pure fileP
Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ import qualified Test.Types.Check as TypesC
1818import qualified Test.Core.Backend as Backend
1919import qualified Test.Lua.Parser as LParser
2020import qualified Test.Frontend.Amc as Amc
21- import qualified Test.Lsp as Lsp
21+ mport qualified Test. Lsp as Lsp
22+
23+ import GHC.IO.Encoding
2224
2325tests :: IO TestTree
2426tests = testGroup " Tests" <$> sequence
@@ -40,7 +42,9 @@ tests = testGroup "Tests" <$> sequence
4042 ]
4143
4244main :: IO ()
43- main = tests >>= defaultMainWithIngredients ingredients where
45+ main = locale *> test where
46+ locale = setLocaleEncoding utf8
47+ test = tests >>= defaultMainWithIngredients ingredients
4448 ingredients =
4549 [ rerunning
4650 [ listingTests
You can’t perform that action at this time.
0 commit comments