Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add some dummy HUnit tests.

  • Loading branch information...
commit 20ca460294d943b3ea6fd495b08e0d964609928f 1 parent 4780a8a
@23Skidoo authored
Showing with 33 additions and 11 deletions.
  1. +4 −1 ghc-parmake.cabal
  2. +29 −10 tests/{Properties.hs → Tests.hs}
View
5 ghc-parmake.cabal
@@ -42,10 +42,13 @@ Test-suite tests
Main-is: Properties.hs
Build-depends: base >= 4.0 && < 5,
filepath >= 1 && < 2,
+ directory >= 1.1 && < 2,
ghc-parmake == 0.1.*,
test-framework >= 0.4.1 && < 0.5,
test-framework-quickcheck2 >= 0.2.10 && < 0.3,
- QuickCheck >= 2.4.1.1
+ test-framework-hunit >= 0.2.6 && < 0.3,
+ QuickCheck >= 2.4.1.1,
+ HUnit >= 1.2.2.0
Ghc-Options: -Wall -threaded -rtsopts
Source-repository head
View
39 tests/Properties.hs → tests/Tests.hs
@@ -4,14 +4,21 @@ module Main
import Data.Char
import Data.List
import System.FilePath
+import System.Directory
+
import Test.QuickCheck
-import Test.Framework (Test, defaultMain)
+import Test.HUnit hiding (Test)
+import Test.Framework (Test, defaultMain, testGroup)
import Test.Framework.Providers.QuickCheck2 (testProperty)
+import Test.Framework.Providers.HUnit (testCase)
import qualified GHC.ParMake.BuildPlan as BuildPlan
import GHC.ParMake.BuildPlan (TargetId)
import GHC.ParMake.Common (appendMap, uniq)
+------------------------------------------------------------------------
+-- Input data generation for QuickCheck.
+
data DepsList = DepsList [(TargetId, TargetId)]
deriving Show
@@ -50,6 +57,9 @@ arbitraryName = (listOf . elements $ ['A'..'Z'] ++ ['a'..'z'] ++ ['0'..'9'])
&& (length l >= 4)
&& (isUpper . head $ l))
+------------------------------------------------------------------------
+-- Properties.
+
pMarkCompleted :: DepsList -> Bool
pMarkCompleted (DepsList []) = True
pMarkCompleted (DepsList l) =
@@ -75,6 +85,14 @@ pAppendMap :: [Int] -> [Int] -> Bool
pAppendMap l1 l2 = appendMap id l1 l2 == l1 ++ l2
------------------------------------------------------------------------
+-- Unit tests.
+
+mkTestCase :: FilePath -> Assertion
+mkTestCase dirName = do let p = "tests" </> "data" </> dirName
+ b <- doesFileExist f
+ assertBool ("File '" ++ f ++ "' doesn't exist!") b
+
+------------------------------------------------------------------------
-- Test harness
main :: IO ()
@@ -82,13 +100,14 @@ main = defaultMain tests
tests :: [Test]
tests =
- [ testProperty "appendMap" pAppendMap
- , testProperty "markCompleted" pMarkCompleted
- , testProperty "compile" pCompile
- -- , testGroup "text"
- -- [ testProperty "text/strict" pText
- -- , testProperty "text/lazy" pTextLazy
- -- , testProperty "rechunk" pRechunk
- -- , testProperty "text/rechunked" pLazyRechunked
- -- ]
+ [ testGroup "properties"
+ [ testProperty "appendMap" pAppendMap
+ , testProperty "markCompleted" pMarkCompleted
+ , testProperty "compile" pCompile
+ ]
+ , testGroup "tests"
+ [ testCase dirName (mkTestCase dirName)
+ | dirName <- [ "executable", "executable-lhs"
+ , "executable-mutrec", "executable-lhs-mutrec"]
+ ]
]
Please sign in to comment.
Something went wrong with that request. Please try again.