]> git.wincent.com - docvim.git/commitdiff
Start refactoring golden tests to support end-to-end testing
authorGreg Hurrell <greg@hurrell.net>
Fri, 10 Jun 2016 14:26:21 +0000 (07:26 -0700)
committerGreg Hurrell <greg@hurrell.net>
Fri, 10 Jun 2016 14:26:21 +0000 (07:26 -0700)
lib/Text/Docvim/Util.hs
tests/tasty.hs

index 9c4c151626354642090c01ab167dec36951ff7e0..0535a2252f3b59b13768eae01a5af02ef0518081 100644 (file)
@@ -1,6 +1,7 @@
 -- | Functions to facilitate automated and manual testing.
 module Text.Docvim.Util ( compileUnit
                         , p
+                        , parseUnit
                         , pm
                         , pp
                         , ppm
@@ -16,10 +17,14 @@ import Text.Docvim.Printer.Vim
 import Text.Parsec
 import Text.Show.Pretty
 
+-- | Parse a string containing a translation unit.
+parseUnit :: String -> Either ParseError Node
+parseUnit input = runParser unit () "(eval)" input
+
 -- | Parse and compile a string containing a translation unit.
 compileUnit :: String -> Either ParseError Node
 compileUnit input = do
-  parsed <- runParser unit () "(eval)" input
+  parsed <- parseUnit input
   return $ compile [parsed]
 
 -- | Convenience function: Parse and compile a string containing a translation
index b074901b028bed11b5ad005219dd47661e44f015..e1f958ff74d6346723060e69854b333071fb4576 100644 (file)
@@ -89,9 +89,10 @@ unitTests = testGroup "Unit tests"
       in symbols
   ]
 
-goldenTests :: String -> [FilePath] -> (String -> String) -> TestTree
+goldenTests :: String -> [[FilePath]] -> (String -> String) -> TestTree
 goldenTests description sources transform = testGroup groupName $ do
-  file <- sources -- list monad
+  files <- sources -- list monad
+  file <- files
   let
     run = do
       input <- readFile file
@@ -161,7 +162,7 @@ main = do
   vimHelpSources <- getFixtures "tests/fixtures/vim"
   defaultMain $ testGroup "Test suite"
     [ unitTests
-    , goldenTests "parser" parserSources p
-    , goldenTests "Markdown printer" markdownSources pm
-    , goldenTests "Vim help printer" vimHelpSources pv
+    , goldenTests "parser" [parserSources] p
+    , goldenTests "Markdown printer" [markdownSources] pm
+    , goldenTests "Vim help printer" [vimHelpSources] pv
     ]