Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
177 additions
and
24 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1,2 @@ | |||
dist | dist | ||
.hpc |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
module Main where | |||
|
|||
main :: IO () | |||
main = do | |||
return () |
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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,55 @@ | |||
#!/usr/bin/env runhaskell | #!/usr/bin/env runhaskell | ||
> import Distribution.Simple | \begin{code} | ||
> main = defaultMainWithHooks simpleUserHooks | {-# LANGUAGE CPP #-} | ||
|
|||
import System.Exit (ExitCode(..)) | |||
import Control.Monad (unless, mplus) | |||
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) ) | |||
import Distribution.Simple.Program (programFindLocation, lookupKnownProgram ) | |||
import Distribution.Verbosity (normal) | |||
import Distribution.Simple (defaultMainWithHooks, UserHooks(..), simpleUserHooks) | |||
import System.IO (openFile, IOMode (..)) | |||
import System.FilePath ( (</>), splitDirectories, isAbsolute ) | |||
import System.Process | |||
import System.Directory (getCurrentDirectory, createDirectoryIfMissing, setCurrentDirectory, findExecutable, canonicalizePath) | |||
|
|||
main = defaultMainWithHooks simpleUserHooks { runTests = testHook } | |||
|
|||
findHPC :: LocalBuildInfo -> IO FilePath | |||
findHPC lbi = do | |||
Just hpcProgram <- return $ lookupKnownProgram "hpc" $ withPrograms lbi | |||
Just hpc <- programFindLocation hpcProgram normal | |||
return hpc | |||
`catch` \e -> do | |||
Just hpc <- findExecutable "hpc" | |||
return hpc | |||
|
|||
testHook args0 _ _ lbi = do | |||
let args = if null args0 then [] else "-t" : args0 | |||
-- dir <- getWorkingDirectory | |||
let testDir = buildDir lbi </> "test-speculation" | |||
baseDir <- getCurrentDirectory | |||
canonicalBuildDir <- canonicalizePath (buildDir lbi) | |||
setCurrentDirectory testDir | |||
exitcode <- system $ unwords $ "test-speculation" : args | |||
unless (exitcode == ExitSuccess) $ | |||
fail "test failed" | |||
hpc <- findHPC lbi | |||
exitcode <- system $ unwords $ hpc | |||
: "report" | |||
: "test-speculation" | |||
: "--srcdir=../../.." | |||
: [] | |||
let markupDir base = base </> "doc" </> "html" </> "test-speculation" | |||
createDirectoryIfMissing True (markupDir canonicalBuildDir) | |||
exitcode <- system $ unwords $ hpc | |||
: "markup" | |||
: "test-speculation" | |||
: "--srcdir=../../.." | |||
: ("--destdir=" ++ markupDir canonicalBuildDir) | |||
: "--exclude=Main" | |||
: [] | |||
unless (exitcode == ExitSuccess) $ | |||
fail "hpc report failed" | |||
putStrLn $ "Code coverage created: " ++ (markupDir (buildDir lbi) </> "hpc_index.html") | |||
\end{code} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
module Main where | |||
|
|||
import Prelude hiding ((||),(&&)) | |||
import Test.Framework (Test) | |||
import Test.Framework (defaultMain, testGroup) | |||
import Test.Framework.Providers.HUnit | |||
import Test.Framework.Providers.QuickCheck (testProperty) | |||
import Test.QuickCheck hiding ((==>)) | |||
-- import Test.HUnit hiding (Test) | |||
import Control.Concurrent.Speculation | |||
|
|||
main :: IO () | |||
main = defaultMain tests | |||
|
|||
ignore :: Functor f => f a -> f () | |||
ignore = fmap (const ()) | |||
|
|||
tests :: [Test] | |||
tests = | |||
[ testGroup "cases" $ zipWith (testCase . show) [1 :: Int ..] $ | |||
[] | |||
, testGroup "properties" $ zipWith (testProperty . show) [1 :: Int ..] $ | |||
[ property $ \ a -> spec a (*2) a == ((*2) $! a :: Int) ] | |||
] |
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