Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Add unit-tests for Cabal-Helper cradles #1552

Merged
merged 1 commit into from
Jan 8, 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
2 changes: 2 additions & 0 deletions haskell-ide-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ test-suite unit-test
hs-source-dirs: test/unit
main-is: Main.hs
other-modules: ApplyRefactPluginSpec
CabalHelperSpec
CodeActionsSpec
ContextSpec
DiffSpec
Expand All @@ -193,6 +194,7 @@ test-suite unit-test
build-tool-depends: cabal-helper:cabal-helper-main, hspec-discover:hspec-discover
build-depends: QuickCheck
, aeson
, cabal-helper
, ghc
, base
, bytestring
Expand Down
3 changes: 2 additions & 1 deletion hie-plugin-api/Haskell/Ide/Engine/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ isStackCradle = (`elem` ["stack", "Cabal-Helper-Stack", "Cabal-Helper-Stack-None
isCabalCradle :: Cradle -> Bool
isCabalCradle =
(`elem`
["cabal"
[ "cabal"
, "Cabal-Helper-Cabal-V1"
, "Cabal-Helper-Cabal-V2"
, "Cabal-Helper-Cabal-V1-Dir"
, "Cabal-Helper-Cabal-V2-Dir"
, "Cabal-Helper-Cabal-V2-None"
, "Cabal-Helper-Cabal-None"
]
)
Expand Down
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/implicit-exe/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
1 change: 1 addition & 0 deletions test/testdata/cabal-helper/implicit-exe/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: ./
17 changes: 17 additions & 0 deletions test/testdata/cabal-helper/implicit-exe/implicit-exe.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cabal-version: >=1.10
name: implicit-exe
version: 0.1.0.0
license-file: LICENSE
build-type: Simple

library
exposed-modules: Lib
hs-source-dirs: src
build-depends: base >=4.8 && <4.13
default-language: Haskell2010


executable implicit-exe
main-is: src/Exe.hs
build-depends: base >=4.8 && <4.13, implicit-exe
default-language: Haskell2010
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/implicit-exe/src/Exe.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

import Lib (someFunc)

main = someFunc
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/implicit-exe/src/Lib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Lib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
15 changes: 15 additions & 0 deletions test/testdata/cabal-helper/mono-repo/A/A.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cabal-version: >=2.0
name: A
version: 0.1.0.0
build-type: Simple

library
exposed-modules: MyLib
build-depends: base >=4.9 && < 5
default-language: Haskell2010

executable A
main-is: Main.hs
other-modules: MyLib
build-depends: base >= 4.9 && < 5, A
default-language: Haskell2010
8 changes: 8 additions & 0 deletions test/testdata/cabal-helper/mono-repo/A/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Main where

import qualified MyLib (someFunc)

main :: IO ()
main = do
putStrLn "Hello, Haskell!"
MyLib.someFunc
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/mono-repo/A/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/mono-repo/A/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
15 changes: 15 additions & 0 deletions test/testdata/cabal-helper/mono-repo/B/B.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cabal-version: >=2.0
name: B
version: 0.1.0.0
build-type: Simple

library
exposed-modules: MyLib
build-depends: base >= 4.9 && < 5
default-language: Haskell2010

executable B
main-is: Main.hs
other-modules: MyLib
build-depends: base >= 4.9 && < 5, B
default-language: Haskell2010
8 changes: 8 additions & 0 deletions test/testdata/cabal-helper/mono-repo/B/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Main where

import qualified MyLib (someFunc)

main :: IO ()
main = do
putStrLn "Hello, Haskell!"
MyLib.someFunc
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/mono-repo/B/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/mono-repo/B/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
9 changes: 9 additions & 0 deletions test/testdata/cabal-helper/mono-repo/C/C.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cabal-version: >=2.0
name: C
version: 0.1.0.0
build-type: Simple

library
exposed-modules: MyLib
build-depends: base>= 4.9 && < 5
default-language: Haskell2010
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/mono-repo/C/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/mono-repo/C/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/mono-repo/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages:
./A/
./B/
./C/
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/simple-cabal/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/simple-cabal/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
10 changes: 10 additions & 0 deletions test/testdata/cabal-helper/simple-cabal/simple-cabal-test.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: >=1.10
name: simple-cabal-test
version: 0.1.0.0
license-file: LICENSE
build-type: Simple

library
exposed-modules: MyLib
build-depends: base >=4.12 && <4.13
default-language: Haskell2010
4 changes: 4 additions & 0 deletions test/testdata/cabal-helper/simple-stack/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/simple-stack/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
10 changes: 10 additions & 0 deletions test/testdata/cabal-helper/simple-stack/simple-stack-test.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: >=1.10
name: simple-stack-test
version: 0.1.0.0
license-file: LICENSE
build-type: Simple

library
exposed-modules: MyLib
build-depends: base >=4.12 && <4.13
default-language: Haskell2010
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/sub-package/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
8 changes: 8 additions & 0 deletions test/testdata/cabal-helper/sub-package/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Main where

import qualified MyLib (someFunc)

main :: IO ()
main = do
putStrLn "Hello, Haskell!"
MyLib.someFunc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PluginLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
2 changes: 2 additions & 0 deletions test/testdata/cabal-helper/sub-package/plugins-api/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: >=1.10
name: plugins-api
version: 0.1.0.0
license-file: LICENSE
build-type: Simple

library
exposed-modules: PluginLib
build-depends: base >=4.12 && <4.13
default-language: Haskell2010
6 changes: 6 additions & 0 deletions test/testdata/cabal-helper/sub-package/src/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module MyLib (someFunc) where

import qualified PluginLib as L

someFunc :: IO ()
someFunc = L.someFunc
17 changes: 17 additions & 0 deletions test/testdata/cabal-helper/sub-package/sub-package.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cabal-version: >=1.10
name: sub-package
version: 0.1.0.0
license-file: LICENSE
build-type: Simple

library
exposed-modules: MyLib
build-depends: base >=4.12 && <4.13, plugins-api
hs-source-dirs: src
default-language: Haskell2010

executable sub-package
main-is: Main.hs
build-depends: base >=4.12 && <4.13, sub-package
hs-source-dirs: app
default-language: Haskell2010
Loading