Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
Runner: Guess Targets after setting dynflags
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthi-chaud committed Jul 22, 2023
1 parent 448a704 commit 1b748bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Seminal/Compiler/Runner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ runCompiler filePaths action = do
Right r -> Right r
where
session = runGhc (Just libdir) $ do
targets <- guessTargets filePaths
setTargets targets
flags <- getSessionDynFlags
setSessionDynFlags (flags {
mainFunIs = Just "undefined",
Expand All @@ -37,6 +35,8 @@ runCompiler filePaths action = do
maxErrors = Just 0,
extensionFlags = insert PartialTypeSignatures (extensionFlags flags)
})
targets <- guessTargets filePaths
setTargets targets
_ <- load LoadAllTargets
modGraph <- depanal [] True
parseResults <- mapM (\f -> (f,) <$> getModule modGraph f) filePaths
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ packages:
# extra-package-dbs: []

# Control whether we use the GHC we find on the path
system-ghc: true
system-ghc: false
#
# Require a specific version of Stack, using version ranges
# require-stack-version: -any # Default
Expand Down
3 changes: 2 additions & 1 deletion test/TestCompiler/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Test.Framework.Providers.HUnit (testCase)
import GHC (moduleNameString, moduleName, ms_mod, pm_mod_summary, ParsedModule)
import System.Directory (getPermissions, setOwnerReadable, setPermissions)
import Data.List (isPrefixOf, isSuffixOf, isInfixOf)
import GHC.SysTools.Tasks(isContainedIn)

runParser :: [FilePath] -> IO (Either String [(FilePath, ParsedModule)])
runParser files = runCompiler files return
Expand All @@ -26,7 +27,7 @@ testSuite = testGroup "Compiler's Parser" [
buildTest $ do
res <- runParser ["test/assets/invalid/syntax-error.hs"]
return $ testCase "Invalid Parsing (Syntax Error)" $ case res of
Left errMsg -> assertBool "" $ "parse error" `isPrefixOf` errMsg
Left errMsg -> assertBool errMsg $ "parse error" `isContainedIn` errMsg
_ -> assertFailure "Parsing should have failed",
buildTest $ do
res <- runParser ["idonotexist"]
Expand Down

0 comments on commit 1b748bb

Please sign in to comment.