Skip to content

Commit 0b8e40b

Browse files
committed
more tests and docs
1 parent 1b56575 commit 0b8e40b

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/CabalAdd.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ addDependencySuggestCodeAction plId verTxtDocId suggestions haskellFilePath caba
156156
-- | Gives the build targets that are used in the `CabalAdd`.
157157
-- Note the unorthodox usage of `readBuildTargets`:
158158
-- If the relative path to the haskell file is provided,
159-
-- the `readBuildTargets` will return a main build target.
160-
-- This behaviour is acceptable for now, but changing to a way of getting
161-
-- all build targets in a file is advised.
159+
-- the `readBuildTargets` will return build targets, where this
160+
-- module is mentioned (in exposed-modules or other-modules).
162161
getBuildTargets :: GenericPackageDescription -> FilePath -> FilePath -> IO [BuildTarget]
163162
getBuildTargets gpd cabalFilePath haskellFilePath = do
164163
let haskellFileRelativePath = makeRelative (dropFileName cabalFilePath) haskellFilePath

plugins/hls-cabal-plugin/test/CabalAdd.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ cabalAddTests =
3939
, runHaskellTestCaseSession "Code Actions - Can add hidden package to an executable, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
4040
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("src" </> "Main.hs") "split" [269])
4141
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a library, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
42-
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("lib" </> "MyLib.hs") "split" [376])
42+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("lib" </> "MyLib.hs") "split" [413])
43+
, runHaskellTestCaseSession "Code Actions - Can add hidden package to an internal library, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
44+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("lib" </> "InternalLib.hs") "split" [413])
4345
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a test, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
44-
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("test" </> "Main.hs") "split" [618])
46+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("test" </> "Main.hs") "split" [655])
4547
, runHaskellTestCaseSession "Code Actions - Can add hidden package to a benchmark, multiple targets" ("cabal-add-testdata" </> "cabal-add-multitarget")
46-
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("bench" </> "Main.hs") "split" [739])
48+
(generateAddDependencyTestSession "cabal-add-multitarget.cabal" ("bench" </> "Main.hs") "split" [776])
4749

4850

4951
, runHaskellTestCaseSession "Code Actions - Guard against HPack" ("cabal-add-testdata" </> "cabal-add-packageYaml")

plugins/hls-cabal-plugin/test/testdata/cabal-add-testdata/cabal-add-multitarget/cabal-add-multitarget.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ executable cabal-add-exe
1212

1313
library
1414
exposed-modules: MyLib
15+
other-modules: InternalLib
1516
build-depends: base >= 4 && < 5
1617
hs-source-dirs: lib
1718
ghc-options: -Wall
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module InternalLib (internalFunc) where
2+
3+
import Data.List.Split
4+
5+
internalFunc :: IO ()
6+
internalFunc = putStrLn "internalFunc"

0 commit comments

Comments
 (0)