mirror of
https://github.com/Avi-D-coder/implicit-hie.git
synced 2024-09-11 09:05:25 +03:00
Fix tests
This commit is contained in:
parent
62e4f18708
commit
9a7711125d
15
app/Main.hs
15
app/Main.hs
@ -19,13 +19,11 @@ main = do
|
||||
pwd <- getCurrentDirectory
|
||||
files <- listDirectory pwd
|
||||
cfs <- cabalFiles pwd
|
||||
let cabal = (cabalComponent, "cabal")
|
||||
stack = (stackComponent, "stack")
|
||||
(fmt, name) =
|
||||
if | any (("dist-newstyle" ==) . takeFileName) files -> cabal
|
||||
| any ((".stack-work" ==) . takeFileName) files -> stack
|
||||
| any (("stack.yaml" ==) . takeFileName) files -> stack
|
||||
| otherwise -> cabal
|
||||
let name =
|
||||
if | any (("dist-newstyle" ==) . takeFileName) files -> "cabal"
|
||||
| any ((".stack-work" ==) . takeFileName) files -> "stack"
|
||||
| any (("stack.yaml" ==) . takeFileName) files -> "stack"
|
||||
| otherwise -> "cabal"
|
||||
gen f = do
|
||||
f' <- T.readFile f
|
||||
case parsePackage' f' of
|
||||
@ -49,8 +47,7 @@ main = do
|
||||
<> pwd
|
||||
<> "\n You may need to run stack build."
|
||||
pkgs <- catMaybes <$> mapM gen cfs
|
||||
putStr <$> hieYaml name $ unlines $
|
||||
concatMap (\(Package n cs) -> map ((<> "\n") . fmtComponent . fmt n) cs) pkgs
|
||||
putStr <$> hieYaml name $ fmtPkgs name pkgs
|
||||
|
||||
cabalFiles :: FilePath -> IO [FilePath]
|
||||
cabalFiles f = do
|
||||
|
@ -4,7 +4,7 @@ cabal-version: 1.12
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: ee9bceb3ed6e6ee053acc1dc9dde3033fed8e9f565a8c8bbdfa52f9be9c507aa
|
||||
-- hash: 19d5dbbfaaca0af267a9130152cdf8d4a25d59ddd71229a803bfa48283606994
|
||||
|
||||
name: implicit-hie
|
||||
version: 0.1.0.0
|
||||
@ -33,7 +33,7 @@ library
|
||||
Paths_implicit_hie
|
||||
hs-source-dirs:
|
||||
src
|
||||
ghc-options: -O2 -flate-specialise -fexpose-all-unfoldings -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints
|
||||
ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints
|
||||
build-depends:
|
||||
attoparsec
|
||||
, base >=4.7 && <5
|
||||
@ -47,7 +47,7 @@ executable gen-hie
|
||||
Paths_implicit_hie
|
||||
hs-source-dirs:
|
||||
app
|
||||
ghc-options: -O2 -flate-specialise -fexpose-all-unfoldings -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
attoparsec
|
||||
, base >=4.7 && <5
|
||||
@ -65,7 +65,7 @@ test-suite implicit-hie-test
|
||||
Paths_implicit_hie
|
||||
hs-source-dirs:
|
||||
test
|
||||
ghc-options: -O2 -flate-specialise -fexpose-all-unfoldings -fspecialize-aggressively -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fno-warn-unused-imports -fno-warn-unused-binds -fno-warn-name-shadowing -fwarn-redundant-constraints -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
attoparsec
|
||||
, base >=4.7 && <5
|
||||
|
@ -26,10 +26,10 @@ dependencies:
|
||||
- yaml
|
||||
|
||||
ghc-options:
|
||||
- -O2
|
||||
- -flate-specialise
|
||||
- -fexpose-all-unfoldings
|
||||
- -fspecialize-aggressively
|
||||
# - -O2
|
||||
# - -flate-specialise
|
||||
# - -fexpose-all-unfoldings
|
||||
# - -fspecialize-aggressively
|
||||
- -Wall
|
||||
- -Wincomplete-record-updates
|
||||
- -Wincomplete-uni-patterns
|
||||
|
@ -3,6 +3,7 @@
|
||||
module Hie.Yaml
|
||||
( hieYaml,
|
||||
fmtComponent,
|
||||
fmtPkgs,
|
||||
cabalComponent,
|
||||
stackComponent,
|
||||
)
|
||||
@ -49,5 +50,15 @@ fmtComponent (p, c) =
|
||||
<> "component: "
|
||||
<> dQuote c
|
||||
|
||||
dropLast :: [a] -> [a]
|
||||
dropLast l = take (length l - 1) l
|
||||
|
||||
fmtPkgs :: String -> [Package] -> String
|
||||
fmtPkgs sOrC pkgs = dropLast $ unlines l
|
||||
where
|
||||
comp = if sOrC == "cabal" then cabalComponent else stackComponent
|
||||
f (Package n cs) = map ((<> "\n") . fmtComponent . comp n) cs
|
||||
l = concatMap f pkgs
|
||||
|
||||
dQuote :: String -> String
|
||||
dQuote t = '"' : t <> "\""
|
||||
|
26
test/Spec.hs
26
test/Spec.hs
@ -17,27 +17,27 @@ spec = do
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses executable section"
|
||||
$ exeSection ~> parseExe 0
|
||||
`shouldParse` Exe "implicit-hie-exe" "app/Main.hs"
|
||||
`shouldParse` Comp Exe "implicit-hie-exe" "app/Main.hs"
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses test section"
|
||||
$ testSection ~> parseTestSuite 0
|
||||
`shouldParse` Test "implicit-hie-test" "test"
|
||||
`shouldParse` Comp Test "implicit-hie-test" "test"
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses library section"
|
||||
$ libSection ~> parseLib 0
|
||||
`shouldParse` Lib "" "src"
|
||||
`shouldParse` Comp Lib "" "src"
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses bench section"
|
||||
$ benchSection ~> parseBench 0
|
||||
`shouldParse` Bench "folds" "benchmarks/folds.hs"
|
||||
`shouldParse` Comp Bench "folds" "benchmarks/folds.hs"
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses package"
|
||||
$ fullFile ~> parsePackage
|
||||
`shouldParse` Package
|
||||
"implicit-hie"
|
||||
[ Lib "" "src",
|
||||
Exe "implicit-hie-exe" "app/Main.hs",
|
||||
Test "implicit-hie-test" "test"
|
||||
[ Comp Lib "" "src",
|
||||
Comp Exe "implicit-hie-exe" "app/Main.hs",
|
||||
Comp Test "implicit-hie-test" "test"
|
||||
]
|
||||
describe "Should Succeed"
|
||||
$ it
|
||||
@ -47,13 +47,15 @@ spec = do
|
||||
`leavesUnconsumed` r
|
||||
describe "Should Succeed"
|
||||
$ it "successfully generates stack hie.yaml"
|
||||
$ (stackHieYaml <$> parseOnly parsePackage fullFile) `shouldBe` Right stackHie
|
||||
$ (hieYaml "stack" . fmtPkgs "stack" . (: []) <$> parseOnly parsePackage fullFile)
|
||||
`shouldBe` Right stackHie
|
||||
describe "Should Succeed"
|
||||
$ it "successfully generates stack hie.yaml"
|
||||
$ do
|
||||
f <- T.readFile "test/haskell-language-server-cabal"
|
||||
o <- T.readFile "test/hie.yaml.cbl"
|
||||
(cabalHieYaml <$> parseOnly parsePackage f) `shouldBe` Right o
|
||||
o <- readFile "test/hie.yaml.cbl"
|
||||
(hieYaml "cabal" . fmtPkgs "cabal" . (: []) <$> parseOnly parsePackage f)
|
||||
`shouldBe` Right o
|
||||
|
||||
fullFile :: Text
|
||||
fullFile = "name: implicit-hie\n" <> libSection <> exeSection <> testSection
|
||||
@ -113,14 +115,16 @@ benchSection =
|
||||
\ type: exitcode-stdio-1.0\n\
|
||||
\ main-is: folds.hs\n"
|
||||
|
||||
stackHie :: Text
|
||||
stackHie :: String
|
||||
stackHie =
|
||||
"cradle:\n\
|
||||
\ stack:\n\
|
||||
\ - path: \"src\"\n\
|
||||
\ component: \"implicit-hie:lib\"\n\
|
||||
\\n\
|
||||
\ - path: \"app/Main.hs\"\n\
|
||||
\ component: \"implicit-hie:exe:implicit-hie-exe\"\n\
|
||||
\\n\
|
||||
\ - path: \"test\"\n\
|
||||
\ component: \"implicit-hie:test:implicit-hie-test\"\n\
|
||||
\"
|
||||
|
@ -2,11 +2,15 @@ cradle:
|
||||
cabal:
|
||||
- path: "src"
|
||||
component: "lib:haskell-language-server"
|
||||
|
||||
- path: "exe/Main.hs"
|
||||
component: "haskell-language-server:exe:haskell-language-server"
|
||||
|
||||
- path: "exe/Wrapper.hs"
|
||||
component: "haskell-language-server:exe:haskell-language-server-wrapper"
|
||||
|
||||
- path: "test/functional"
|
||||
component: "haskell-language-server:test:func-test"
|
||||
|
||||
- path: "test/utils"
|
||||
component: "lib:haskell-language-server:hls-test-utils"
|
||||
|
Loading…
Reference in New Issue
Block a user