Commits

Jasper Van der Jeugt  committed bd4185d

Cabal target for the IO coverage tests

  • Participants
  • Parent commits c5c8913

Comments (0)

Files changed (2)

File tests/tests/src/Data/Text/Tests/IO.hs

+-- | Program which exposes some haskell functions as an exutable. The results
+-- and coverage of this module is meant to be checked using a shell script.
+--
+module Main
+    (
+      main
+    ) where
+
+import System.Environment (getArgs)
+import System.Exit (exitFailure)
+import System.IO (hPutStrLn, stderr)
+import qualified Data.Text as T
+import qualified Data.Text.IO as T
+import qualified Data.Text.Lazy as TL
+import qualified Data.Text.Lazy.IO as TL
+
+main :: IO ()
+main = do
+  args <- getArgs
+  case args of
+    ["T.readFile", name] -> T.putStr =<< T.readFile name
+    ["T.writeFile", name, t] -> T.writeFile name (T.pack t)
+    ["T.appendFile", name, t] -> T.appendFile name (T.pack t)
+    ["T.interact"] -> T.interact id
+    ["T.getContents"] -> T.putStr =<< T.getContents
+    ["T.getLine"] -> T.putStrLn =<< T.getLine
+
+    ["TL.readFile", name] -> TL.putStr =<< TL.readFile name
+    ["TL.writeFile", name, t] -> TL.writeFile name (TL.pack t)
+    ["TL.appendFile", name, t] -> TL.appendFile name (TL.pack t)
+    ["TL.interact"] -> TL.interact id
+    ["TL.getContents"] -> TL.putStr =<< TL.getContents
+    ["TL.getLine"] -> TL.putStrLn =<< TL.getLine
+    _ -> hPutStrLn stderr "invalid directive!" >> exitFailure

File tests/tests/text-tests.cabal

-name:                text-tests
-version:             0.0.0.0
-synopsis:            Functional tests for the text package
-description:         Functional tests for the text package
-homepage:            https://bitbucket.org/bos/text
-license:             BSD3
-license-file:        ../../LICENSE
-author:              Jasper Van der Jeugt <jaspervdj@gmail.com>,
-                     Bryan O'Sullivan <bos@serpentine.com>,
-                     Tom Harper <rtomharper@googlemail.com>,
-                     Duncan Coutts <duncan@haskell.org>
-maintainer:          Bryan O'Sullivan <bos@serpentine.com>
-category:            Text
-build-type:          Simple
+name:          text-tests
+version:       0.0.0.0
+synopsis:      Functional tests for the text package
+description:   Functional tests for the text package
+homepage:      https://bitbucket.org/bos/text
+license:       BSD3
+license-file:  ../../LICENSE
+author:        Jasper Van der Jeugt <jaspervdj@gmail.com>,
+               Bryan O'Sullivan <bos@serpentine.com>,
+               Tom Harper <rtomharper@googlemail.com>,
+               Duncan Coutts <duncan@haskell.org>
+maintainer:    Bryan O'Sullivan <bos@serpentine.com>
+category:      Text
+build-type:    Simple
 
-cabal-version:       >=1.2
+cabal-version: >=1.2
 
 flag hpc
   description: Enable HPC to generate coverage reports
     random                     >= 1.0 && < 1.1,
     test-framework             >= 0.4 && < 0.5,
     test-framework-quickcheck2 >= 0.2 && < 0.3
+
+executable text-tests-stdio
+  hs-source-dirs: src ../..
+  main-is:        Data/Text/Tests/IO.hs
+
+  ghc-options:
+    -Wall
+    -threaded
+
+  -- Optional HPC support
+  if flag(hpc)
+    ghc-options:
+      -fhpc
+
+  build-depends:
+    base >= 4 && < 5