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

Commit

Permalink
Make Filetargets absolute before continue using them (#914)
Browse files Browse the repository at this point in the history
* Add testcase for proving relative filetargets

* Normalise file targets after loading
  • Loading branch information
fendor authored Nov 21, 2020
1 parent 7d90848 commit b11d010
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ memoIO op = do
-- | Throws if package flags are unsatisfiable
setOptions :: GhcMonad m => ComponentOptions -> DynFlags -> m (DynFlags, [GHC.Target])
setOptions (ComponentOptions theOpts compRoot _) dflags = do
(dflags', targets) <- addCmdOpts theOpts dflags
(dflags', targets') <- addCmdOpts theOpts dflags
let targets = makeTargetsAbsolute compRoot targets'
let dflags'' =
disableWarningsAsErrors $
-- disabled, generated directly by ghcide instead
Expand Down
14 changes: 14 additions & 0 deletions test/data/cabal-exe/a/a.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cabal-version: 2.2

name: a
version: 0.1.0.0
author: Fendor
maintainer: [email protected]
build-type: Simple

executable a
main-is: Main.hs
hs-source-dirs: src
ghc-options: -Wall
build-depends: base
default-language: Haskell2010
3 changes: 3 additions & 0 deletions test/data/cabal-exe/a/src/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Main where

main = putStrLn "Hello, Haskell!"
1 change: 1 addition & 0 deletions test/data/cabal-exe/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: ./a
3 changes: 3 additions & 0 deletions test/data/cabal-exe/hie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cradle:
cabal:
component: "exe:a"
12 changes: 12 additions & 0 deletions test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,7 @@ cradleTests = testGroup "cradle"
,testGroup "ignore-fatal" [ignoreFatalWarning]
,testGroup "loading" [loadCradleOnlyonce]
,testGroup "multi" [simpleMultiTest, simpleMultiTest2]
,testGroup "sub-directory" [simpleSubDirectoryTest]
]

loadCradleOnlyonce :: TestTree
Expand Down Expand Up @@ -3268,6 +3269,17 @@ ignoreFatalWarning = testCase "ignore-fatal-warning" $ runWithExtraFiles "ignore
_ <- createDoc srcPath "haskell" src
expectNoMoreDiagnostics 5

simpleSubDirectoryTest :: TestTree
simpleSubDirectoryTest =
testCase "simple-subdirectory" $ runWithExtraFiles "cabal-exe" $ \dir -> do
let mainPath = dir </> "a/src/Main.hs"
mainSource <- liftIO $ readFileUtf8 mainPath
_mdoc <- createDoc mainPath "haskell" mainSource
expectDiagnosticsWithTags
[("a/src/Main.hs", [(DsWarning,(2,0), "Top-level binding", Nothing)]) -- So that we know P has been loaded
]
expectNoMoreDiagnostics 0.5

simpleMultiTest :: TestTree
simpleMultiTest = testCase "simple-multi-test" $ runWithExtraFiles "multi" $ \dir -> do
let aPath = dir </> "a/A.hs"
Expand Down

0 comments on commit b11d010

Please sign in to comment.