packages feed

DocTest 0.0.2 → 0.0.3

raw patch · 3 files changed

+8/−25 lines, 3 files

Files

DocTest.cabal view
@@ -1,5 +1,5 @@ name:                DocTest-version:             0.0.2+version:             0.0.3 stability:           experimental synopsis:            Test interactive Haskell examples description:         DocTest checks examples in source code comments.@@ -18,7 +18,7 @@                      , haskell-src                      , directory                      , filepath-					 , process+                     , process build-type:          Simple  extra-source-files:
Main.hs view
@@ -1,28 +1,12 @@ module Main where -import System.Directory import System.Environment-import System.FilePath-import Control.Exception(finally) import Test.DocTest import Test.DocTest.Parser import Test.HUnit - main = do-	withTempDir "DocTestSandbox" run--run tmpdir = do 	args <- getArgs 	docTests <- mapM parseModule args-	tests <- mapM (doTest tmpdir) (concat docTests)+	tests <- mapM docTestToTestCase (concat docTests) 	runTestTT (TestList tests)--withTempDir :: FilePath -> (FilePath -> IO a) -> IO a-withTempDir name action = do-	tmpdir <- catch getTemporaryDirectory (\_ -> return ".")-	let path = combine tmpdir name-	--createDirectory path-	--finally (action path) (removeDirectoryRecursive path)-	createDirectoryIfMissing False path-	action path
Test/DocTest.hs view
@@ -23,16 +23,15 @@ 	"main = do\n" ++ 	"    putStr (show (" ++ expression ++ "))\n" -runDocTest test baseDir = do+docTestToTestCase :: DocTest -> IO Test+docTestToTestCase test = do+	canonicalModulePath <- canonicalizePath $ source test+	let baseDir = packageBaseDir canonicalModulePath (_module test)+ 	ret <- readProcess "runhaskell" ["-i" ++ baseDir] (_testModule test) 	return (TestCase (assertEqual (source test) (result test) ret))  -doTest :: FilePath -> DocTest -> IO Test-doTest directory test = do-	canonicalModulePath <- canonicalizePath $ source test-	let baseDir = packageBaseDir canonicalModulePath (_module test)-	runDocTest test baseDir  -- Maps a given source file and a corresponding module name to the base -- directory of the package.