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

Make Filetargets absolute before continue using them #914

Merged
merged 2 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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