Commit new tests + refactor

This commit is contained in:
Avi Dessauer 2020-05-04 01:36:16 -04:00
parent 0026002cba
commit d5e8ab9fd3
4 changed files with 322 additions and 24 deletions

View File

@ -36,8 +36,8 @@ parsePackage =
<|> (skipToNextLine >> parsePackage)
<|> pure (Package "" [])
component :: Indent -> Text -> Parser Name
component i t = do
componentHeader :: Indent -> Text -> Parser Name
componentHeader i t = do
indent i
_ <- asciiCI t
skipMany tabOrSpace
@ -47,14 +47,20 @@ component i t = do
parseComponent :: Indent -> Parser Component
parseComponent i =
parseLib i
<|> parseExe i
<|> parseNamed i "test-suite" Test
parseExe i
<|> parseLib i
<|> parseTestSuite i
parseLib :: Indent -> Parser Component
parseLib i = do
n <- component i "library"
Lib n <$> extractPath (i + 1)
parseLib i = parseSec i "library" Lib
parseTestSuite :: Indent -> Parser Component
parseTestSuite i = parseSec i "test-suite" Test
parseExe :: Indent -> Parser Component
parseExe i = do
n <- componentHeader i "executable"
Exe n <$> pathMain (i + 1) "." ""
parseQuoted :: Parser Text
parseQuoted = do
@ -64,11 +70,6 @@ parseQuoted = do
parseString :: Parser Name
parseString = parseQuoted <|> takeWhile1 (not . (\c -> isSpace c || c == ','))
parseExe :: Indent -> Parser Component
parseExe i = do
n <- component i "executable"
Exe n <$> pathMain (i + 1) "." ""
pathMain :: Indent -> Text -> Text -> Parser Text
pathMain i p m =
(field i "hs-source-dirs" >>= (\p' -> pathMain i p' m))
@ -76,16 +77,10 @@ pathMain i p m =
<|> (skipBlockLine i >> pathMain i p m)
<|> pure (p <> "/" <> m)
parseNamed :: Indent -> Text -> (Name -> Path -> Component) -> Parser Component
parseNamed i compType compCon =
do
indent i
_ <- asciiCI compType <?> "asciiCI " <> T.unpack compType
skipMany tabOrSpace
n <- parseString <?> "N"
skipToNextLine
compCon n <$> extractPath (i + 1)
<?> T.unpack ("parseNamed " <> compType)
parseSec :: Indent -> Text -> (Name -> Path -> Component) -> Parser Component
parseSec i compType compCon = do
n <- componentHeader i compType
compCon n <$> extractPath (i + 1)
skipToNextLine :: Parser ()
skipToNextLine = skipWhile (not . isEndOfLine) >> endOfLine

View File

@ -20,7 +20,7 @@ spec = do
`shouldParse` Exe "implicit-hie-exe" "app/Main.hs"
describe "Should Succeed"
$ it "successfully parses test section"
$ testSection ~> parseNamed 0 "test-suite" Test
$ testSection ~> parseTestSuite 0
`shouldParse` Test "implicit-hie-test" "test"
describe "Should Succeed"
$ it "successfully parses library section"

View File

@ -0,0 +1,291 @@
cabal-version: 2.2
category: Development
name: haskell-language-server
version: 0.1.0.0
synopsis: LSP server for GHC
description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
homepage: https://github.com/haskell/haskell-language-server#readme
bug-reports: https://github.com/haskell/haskell-language-server/issues
author: Alan Zimmerman
maintainer: alan.zimm@gmail.com
copyright: Alan Zimmerman
license: Apache-2.0
license-file: LICENSE
build-type: Simple
extra-source-files:
README.md
ChangeLog.md
flag agpl
Description: Enable AGPL dependencies
Default: True
Manual: False
flag pedantic
Description: Enable -Werror
Default: False
Manual: True
source-repository head
type: git
location: https://github.com/haskell/haskell-language-server
common agpl
if flag(agpl)
cpp-options:
-DAGPL
library
import: agpl
exposed-modules:
Ide.Cradle
Ide.Logger
Ide.Plugin
Ide.Plugin.Config
Ide.Plugin.Example
Ide.Plugin.Example2
Ide.Plugin.GhcIde
Ide.Plugin.Ormolu
Ide.Plugin.Pragmas
Ide.Plugin.Floskell
Ide.Plugin.Formatter
Ide.PluginUtils
Ide.Types
Ide.Version
other-modules:
Paths_haskell_language_server
hs-source-dirs:
src
build-depends:
base >=4.12 && <5
, aeson
, binary
, bytestring
, Cabal
, cabal-helper >= 1.1
, containers
, data-default
, deepseq
, Diff
, directory
, extra
, filepath
, floskell == 0.10.*
, ghc
, ghcide >= 0.1
, gitrev
, hashable
, haskell-lsp == 0.21.*
, hie-bios >= 0.4
, hslogger
, lens
, ormolu ^>= 0.0.5.0
, optparse-simple
, process
, regex-tdfa >= 1.3.1.0
, shake >= 0.17.5
, text
, transformers
, unordered-containers
if os(windows)
build-depends: Win32
else
build-depends: unix
if flag(agpl)
build-depends:
brittany
exposed-modules:
Ide.Plugin.Brittany
ghc-options:
-Wall
-Wredundant-constraints
-Wno-name-shadowing
if flag(pedantic)
ghc-options: -Werror
default-language: Haskell2010
executable haskell-language-server
import: agpl
main-is: Main.hs
hs-source-dirs:
exe
other-modules:
Arguments
Paths_haskell_language_server
autogen-modules:
Paths_haskell_language_server
ghc-options:
-threaded
-Wall
-Wno-name-shadowing
-Wredundant-constraints
-- allow user RTS overrides
-rtsopts
-- disable idle GC
-- disable parallel GC
-- increase nursery size
"-with-rtsopts=-I0 -qg -A128M"
if flag(pedantic)
ghc-options: -Werror
build-depends:
base >=4.7 && <5
, aeson
, async
, base16-bytestring
, binary
, bytestring
, cryptohash-sha1
, containers
, data-default
, deepseq
, directory
, extra
, filepath
--------------------------------------------------------------
-- The MIN_GHC_API_VERSION macro relies on MIN_VERSION pragmas
-- which require depending on ghc. So the tests need to depend
-- on ghc if they need to use MIN_GHC_API_VERSION. Maybe a
-- better solution can be found, but this is a quick solution
-- which works for now.
, ghc
--------------------------------------------------------------
, ghc-check ^>= 0.1
, ghc-paths
, ghcide
, gitrev
, hashable
, haskell-lsp
, hie-bios >= 0.4
, haskell-language-server
, hslogger
, optparse-applicative
, shake >= 0.17.5
, text
, time
, unordered-containers
default-language: Haskell2010
executable haskell-language-server-wrapper
import: agpl
main-is: Wrapper.hs
hs-source-dirs:
exe
other-modules:
Arguments
Paths_haskell_language_server
autogen-modules:
Paths_haskell_language_server
ghc-options:
-threaded
-Wall
-Wno-name-shadowing
-Wredundant-constraints
-- allow user RTS overrides
-rtsopts
-- disable idle GC
-- disable parallel GC
-- increase nursery size
"-with-rtsopts=-I0 -qg -A128M"
if flag(pedantic)
ghc-options: -Werror
build-depends:
base
, directory
, extra
, filepath
, gitrev
, ghc
, ghc-paths
, hie-bios
, haskell-language-server
, optparse-applicative
, process
default-language: Haskell2010
test-suite func-test
import: agpl
type: exitcode-stdio-1.0
default-language: Haskell2010
build-tool-depends: hspec-discover:hspec-discover
, haskell-language-server:haskell-language-server
, cabal-helper:cabal-helper-main
, ghcide:ghcide-test-preprocessor
build-depends:
base >=4.7 && <5
, aeson
, data-default
, haskell-lsp-types
, hls-test-utils
, hspec
, lens
, lsp-test >= 0.10.0.0
, text
, unordered-containers
other-modules:
-- CompletionSpec
-- , CommandSpec
-- , DeferredSpec
-- , DefinitionSpec
-- , DiagnosticsSpec
FormatSpec
-- , FunctionalBadProjectSpec
-- , FunctionalCodeActionsSpec
-- , FunctionalLiquidSpec
, FunctionalSpec
-- , HaReSpec
-- , HieBiosSpec
-- , HighlightSpec
-- , HoverSpec
, PluginSpec
-- , ProgressSpec
-- , ReferencesSpec
-- , RenameSpec
-- , SymbolsSpec
-- , TypeDefinitionSpec
, Utils
, Paths_haskell_language_server
hs-source-dirs:
test/functional
ghc-options:
-Wall
-Wredundant-constraints
-Wno-name-shadowing
-threaded -rtsopts -with-rtsopts=-N
if flag(pedantic)
ghc-options: -Werror
main-is: Main.hs
-- other-modules:
-- Development.IDE.Test
-- Development.IDE.Test.Runfiles
library hls-test-utils
import: agpl
hs-source-dirs: test/utils
exposed-modules: TestUtils
build-depends: base
, haskell-language-server
, haskell-lsp
, hie-bios
, aeson
, blaze-markup
, containers
, data-default
, directory
, filepath
, hslogger
, hspec
, hspec-core
, stm
, text
, unordered-containers
, yaml
ghc-options: -Wall -Wredundant-constraints
if flag(pedantic)
ghc-options: -Werror
default-language: Haskell2010

12
test/hie.yaml.cbl Normal file
View File

@ -0,0 +1,12 @@
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"