packages feed

doctest-extract 0.1.1.1 → 0.1.2

raw patch · 5 files changed

+51/−19 lines, 5 filesdep ~optparse-applicative

Dependency ranges changed: optparse-applicative

Files

ReadMe.md view
@@ -17,8 +17,8 @@   only `\\begin{code} ... \\end{code}` blocks are scanned,   but not bird style code blocks. -* `prop>` does not support multi-line code,-  because both original `doctest` and `haddock` do not support it.+* `prop>` supports multi-line code,+  but both original `doctest` and `haddock` do not support it.  * IO tests are not supported as `doctest` examples, so far.   We need a syntactic distinction for IO tests,@@ -26,3 +26,29 @@   We could mark IO tests   with a specific `id` function, as in `ioTest $ runMyTest`   or a type annotation, as in `runMyTest :: IO ()`.+++# Tipps and Tricks++## How to disable selected tests?++For focussing on certain tests it can be useful to disable other ones.+We have not implemented a mechanism to disable parts of the test suite+in `doctest-extract`,+because this would require to implement a way to identify tests.+You can still disable some of the tests+without explicit support by `doctest-extraxt`.++* If you want to disable whole modules,+  you may make a copy of the auto-generated `Test/Main.hs`+  and remove the modules that you want to skip.++* For disabling all tests on a function+  you may turn a Haddock comment into a plain comment+  by removing the bar after the opening of the comment.++* For disabling individual tests you may prefix `>>>` and `prop>`+  with an asterisk or the like.++These tricks work best in conjunction with a revision control systen,+such that it always reminds you that there are tests disabled temporarily.
doctest-extract.cabal view
@@ -1,6 +1,6 @@ Cabal-Version:  2.2 Name:           doctest-extract-Version:        0.1.1.1+Version:        0.1.2 License:        BSD-3-Clause License-File:   LICENSE Author:         Henning Thielemann <haskell@henning-thielemann.de>@@ -84,7 +84,7 @@   ReadMe.md  Source-Repository this-  Tag:         0.1.1.1+  Tag:         0.1.2   Type:        darcs   Location:    https://hub.darcs.net/thielema/doctest-extract/ 
src/Format.hs view
@@ -6,7 +6,6 @@ import Test.DocTest.Location (Located(Located))  import qualified Data.Monoid.HT as Mn-import qualified Data.List.Match as Match import qualified Data.List.HT as ListHT import Data.Semigroup ((<>)) import Data.Foldable (foldMap)@@ -79,10 +78,6 @@    createDirectoryIfMissing True $ Path.takeDirectory path    PathIO.writeFile path $ formatTestModule testPrefix flags m --- ToDo: move to List.HT-mapLast :: (a -> a) -> [a] -> [a]-mapLast f xs = zipWith id (drop 1 (Match.replicate xs id) ++ [f]) xs- formatTestModule ::    ModuleName.T -> Flags -> Module [Located Pos DocTest] -> String formatTestModule testPrefix (verbose,importTested) m =@@ -106,16 +101,14 @@                (if verbose                   then [printf " DocTest.printLine %s\n" (show code)] else []) ++                formatLinePragma loc :-               (' ':command) :+               (' ':command++"(") :                formatLinePragma loc :                (case lines code of                   (':':'{':firstLine) : remainingLines ->-                     (replicate (col + length mark) ' ' ++ '(':firstLine) :-                     map (replicate (max 2 col) ' ' ++)-                        (mapLast ((++")") . ListHT.dropRev 2)-                           remainingLines)-                  _ -> [replicate (col + length mark) ' ' ++ '(':code++")"]) ++-               []+                     (replicate (col + length mark + 3) ' ' ++ firstLine) :+                     ListHT.dropRev 1 remainingLines+                  _ -> [replicate (col + length mark) ' ' ++ code]) +++               ["  )"]          in (if verbose                then printf " DocTest.printLine ('\\n':%s++\":%d:1\")" escapedPath loc                else printf " DocTest.printPrefix \"%s:%d: \""
src/Main.hs view
@@ -42,10 +42,11 @@       OP.execParser $ Option.info Option.parser     modules <--      fmap (map Parse.parseModule) $       for moduleNames $ \moduleName -> do          let altPaths = liftA2 (</>) inDirs (ModuleName.filePaths moduleName)-         alternatives $ flip fmap altPaths $ \path -> do+         alternatives $ flip fmap altPaths $ \path ->+            Parse.parseModule .+            Parse.reindentModule .             Parse.moduleFromLines moduleName path .                   Parse.numberedLines . filter ('\r'/=)                <$> PathIO.readFile path
src/Parse.hs view
@@ -189,7 +189,19 @@ numberedLines = zipWith Located [1..] . lines  --- | Convert documentation to `Example`s.+reindentModule ::+   Module [Located (line,Column) String] ->+   Module [Located (line,Column) String]+reindentModule modu =+   modu {moduleContent =+            flip map (moduleContent modu) $+               zipWith ($)+                  (id :+                     repeat+                        (\(Located (line,col) str) ->+                              Located (line,0) $ replicate col ' ' ++ str))}++-- | Convert documentation to 'Example's. parseModule :: Module [Located pos String] -> Module [Located pos DocTest] parseModule modu =    modu {moduleContent =