-
-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract tests into a standalone testsuite
- Loading branch information
1 parent
63c7d9c
commit 4c2011a
Showing
12 changed files
with
112 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module Main(main) where | ||
|
||
import Control.Monad.IO.Class | ||
import Data.Aeson | ||
import qualified Data.ByteString.Lazy as BS | ||
import qualified Data.Text.Encoding as T | ||
import qualified Data.Text.IO as T | ||
import Language.LSP.Test | ||
import Language.LSP.Types | ||
import Test.Tasty | ||
import Test.Tasty.Golden | ||
import Test.Tasty.HUnit | ||
import Test.Tasty.Runners ( | ||
consoleTestReporter, | ||
listingTests, | ||
) | ||
import Test.Tasty.Ingredients.Rerun | ||
import Test.Tasty.Runners.AntXML | ||
|
||
main :: IO () | ||
main = defaultMainWithIngredients | ||
[antXMLRunner, rerunningTests [listingTests, consoleTestReporter]] | ||
tests | ||
|
||
testCommand = "test-server" | ||
|
||
tests :: TestTree | ||
tests = testGroup "brittany" [ | ||
goldenVsStringDiff "formats a document with LF endings" goldenGitDiff "test/testdata/BrittanyLF.formatted_document.hs" $ runSession testCommand fullCaps "test/testdata" $ do | ||
doc <- openDoc "BrittanyLF.hs" "haskell" | ||
formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) | ||
BS.fromStrict . T.encodeUtf8 <$> documentContents doc | ||
|
||
, goldenVsStringDiff "formats a document with CRLF endings" goldenGitDiff "test/testdata/BrittanyCRLF.formatted_document.hs" $ runSession testCommand fullCaps "test/testdata" $ do | ||
doc <- openDoc "BrittanyCRLF.hs" "haskell" | ||
formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing) | ||
BS.fromStrict . T.encodeUtf8 <$> documentContents doc | ||
|
||
, goldenVsStringDiff "formats a range with LF endings" goldenGitDiff "test/testdata/BrittanyLF.formatted_range.hs" $ runSession testCommand fullCaps "test/testdata" $ do | ||
doc <- openDoc "BrittanyLF.hs" "haskell" | ||
let range = Range (Position 1 0) (Position 2 22) | ||
formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range | ||
BS.fromStrict . T.encodeUtf8 <$> documentContents doc | ||
|
||
, goldenVsStringDiff "formats a range with CRLF endings" goldenGitDiff "test/testdata/BrittanyCRLF.formatted_range.hs" $ runSession testCommand fullCaps "test/testdata" $ do | ||
doc <- openDoc "BrittanyCRLF.hs" "haskell" | ||
let range = Range (Position 1 0) (Position 2 22) | ||
formatRange doc (FormattingOptions 4 True Nothing Nothing Nothing) range | ||
BS.fromStrict . T.encodeUtf8 <$> documentContents doc | ||
] | ||
|
||
goldenGitDiff :: FilePath -> FilePath -> [String] | ||
goldenGitDiff fRef fNew = ["git", "diff", "--no-index", "--text", "--exit-code", fRef, fNew] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{-# LANGUAGE ViewPatterns #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module Main(main) where | ||
|
||
import Data.Default | ||
import Development.IDE.Main | ||
import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide | ||
import Ide.Plugin.Config | ||
import Ide.Plugin.Brittany as B | ||
import Ide.PluginUtils | ||
|
||
main :: IO () | ||
main = defaultMain def | ||
{ argsHlsPlugins = pluginDescToIdePlugins $ | ||
[ B.descriptor "brittany" | ||
] <> | ||
Ghcide.descriptors | ||
, argsDefaultHlsConfig = def { formattingProvider = "brittany" } | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
test/testdata/format/Format.brittany_post_floskell.formatted.hs
This file was deleted.
Oops, something went wrong.
4c2011a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marvelous. Thanks so much!