mirror of
https://github.com/Avi-D-coder/implicit-hie.git
synced 2024-11-22 17:55:51 +03:00
fix up
This commit is contained in:
parent
a3c3360bbc
commit
93cd9c7d93
@ -21,6 +21,6 @@ main = do
|
||||
| otherwise -> stackHieYaml
|
||||
when (null path) $ error "No .cabal file found!\n You may need to run stack build."
|
||||
file <- T.readFile $ head path
|
||||
case parseOnly parseSec file of
|
||||
case parseOnly parsePackage file of
|
||||
Right r -> T.writeFile "hie.yaml" $ sOrC r
|
||||
_ -> error "Could not parse *.cabal file"
|
||||
|
@ -24,19 +24,19 @@ data Component = Lib Path | Exe Name Path | Test Name Path
|
||||
parseName :: Parser Text
|
||||
parseName = "name" >> skipSpace >> char ':' >> parseString
|
||||
|
||||
parseSec :: Parser Package
|
||||
parseSec =
|
||||
parsePackage :: Parser Package
|
||||
parsePackage =
|
||||
( do
|
||||
n <- parseName
|
||||
(Package _ t) <- parseSec
|
||||
(Package _ t) <- parsePackage
|
||||
pure $ Package n t
|
||||
)
|
||||
<|> ( do
|
||||
h <- parseComponent 0
|
||||
(Package n t) <- parseSec
|
||||
(Package n t) <- parsePackage
|
||||
pure $ Package n (h : t)
|
||||
)
|
||||
<|> (skipToNextLine >> parseSec)
|
||||
<|> (skipToNextLine >> parsePackage)
|
||||
<|> pure (Package "" [])
|
||||
|
||||
parseComponent :: Indent -> Parser Component
|
||||
|
22
test/Spec.hs
22
test/Spec.hs
@ -26,23 +26,23 @@ spec = do
|
||||
$ libSection ~> parseLib 0
|
||||
`shouldParse` Lib "src"
|
||||
describe "Should Succeed"
|
||||
$ it "successfully parses library section"
|
||||
$ fullFile ~> parseSec
|
||||
`shouldParse` Package
|
||||
"implicit-hie"
|
||||
[ Lib "src",
|
||||
$ it "successfully parses package"
|
||||
$ fullFile ~> parsePackage
|
||||
`shouldParse` Package
|
||||
"implicit-hie"
|
||||
[ Lib "src",
|
||||
Exe "implicit-hie-exe" "app",
|
||||
Test "implicit-hie-test" "test"
|
||||
]
|
||||
describe "Should Succeed"
|
||||
$ it
|
||||
"successfully parses library section"
|
||||
$ let r = "test\n"
|
||||
]
|
||||
describe "Should Succeed"
|
||||
$ it
|
||||
"skips to end of block section"
|
||||
$ let r = "test\n"
|
||||
in (libSection <> r) ~?> parseLib 0
|
||||
`leavesUnconsumed` r
|
||||
describe "Should Succeed"
|
||||
$ it "successfully generates stack hie.yaml"
|
||||
$ (stackHieYaml <$> parseOnly parseSec fullFile) `shouldBe` Right stackHie
|
||||
$ (stackHieYaml <$> parseOnly parsePackage fullFile) `shouldBe` Right stackHie
|
||||
|
||||
fullFile :: Text
|
||||
fullFile = "name: implicit-hie\n" <> libSection <> exeSection <> testSection
|
||||
|
Loading…
Reference in New Issue
Block a user