Skip to content

Commit ac439ee

Browse files
committed
PackageTestMain: comments, cosmetical changes
1 parent 7095333 commit ac439ee

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

tests/PackageTestMain.hs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- | Test that Hackage accepts or refuses certain packages.
2+
13
module Main
24
( main
35
) where
@@ -22,7 +24,11 @@ main = defaultMain allTests
2224
allTests :: TestTree
2325
allTests = testGroup "PackageTests"
2426
[ testGroup "Tar file permissions" tarPermissions
25-
, testGroup "Cabal package integrity tests" cabalPackageCheckTests]
27+
, testGroup "Cabal package integrity tests" cabalPackageCheckTests
28+
]
29+
30+
---------------------------------------------------------------------------
31+
-- * File permission tests
2632

2733
tarPermissions :: [TestTree]
2834
tarPermissions =
@@ -34,7 +40,8 @@ tarPermissions =
3440
(testPermissions "tests/permissions-tarballs/bad-file-perms.tar.gz" badFileMangler)
3541
, testCase
3642
"Bad Dir Permissions"
37-
(testPermissions "tests/permissions-tarballs/bad-dir-perms.tar.gz" badDirMangler)]
43+
(testPermissions "tests/permissions-tarballs/bad-dir-perms.tar.gz" badDirMangler)
44+
]
3845

3946
goodMangler :: (Tar.Entry -> Maybe CombinedTarErrs)
4047
goodMangler = const Nothing
@@ -51,45 +58,62 @@ badDirMangler entry =
5158
Tar.Directory -> Just $ PermissionsError (Tar.entryPath entry) 0o700
5259
_ -> Nothing
5360

61+
---------------------------------------------------------------------------
62+
-- * Package integry tests
63+
5464
cabalPackageCheckTests :: [TestTree]
5565
cabalPackageCheckTests =
5666
[ testCase "Missing ./configure script" missingConfigureScriptTest
5767
, testCase "Missing directories in tar file" missingDirsInTarFileTest
5868
, testCase "Bad spec-version" badSpecVer
5969
]
6070

71+
---------------------------------------------------------------------------
72+
-- ** Tests that must fail
73+
74+
-- | If @build-type: Configure@, then there must be a @./configure@ script.
75+
6176
missingConfigureScriptTest :: Assertion
6277
missingConfigureScriptTest =
6378
do tar <- tarGzFile "missing-configure-0.1.0.0"
6479
now <- getCurrentTime
6580
case unpackPackage now "missing-configure-0.1.0.0.tar.gz" tar of
66-
Right _ -> HUnit.assertFailure "expected error"
81+
Right _ -> HUnit.assertFailure "error: unexpected success"
6782
Left err ->
6883
HUnit.assertBool
6984
("Error found, but not about missing ./configure: " ++ err)
7085
("The 'build-type' is 'Configure'" `isInfixOf` err)
7186

87+
-- | The @cabal-version@ must be valid.
88+
7289
badSpecVer :: Assertion
7390
badSpecVer =
7491
do tar <- tarGzFile "bad-specver-package-0"
7592
now <- getCurrentTime
7693
case unpackPackage now "bad-specver-package-0.tar.gz" tar of
77-
Right _ -> HUnit.assertFailure "expected error"
94+
Right _ -> HUnit.assertFailure "error: unexpected success"
7895
Left err ->
7996
HUnit.assertBool
8097
("Error found, but not about invalid spec version: " ++ err)
8198
("cabal spec version" `isInfixOf` err)
8299

100+
---------------------------------------------------------------------------
101+
-- ** Tests that must succeed
102+
83103
-- | Some tar files in hackage are missing directory entries.
84104
-- Ensure that they can be verified even without the directory entries.
105+
85106
missingDirsInTarFileTest :: Assertion
86107
missingDirsInTarFileTest =
87108
do tar <- fmap keepOnlyFiles (tarGzFile "correct-package-0.1.0.0")
88109
now <- getCurrentTime
89110
case unpackPackage now "correct-package-0.1.0.0.tar.gz" tar of
90111
Right _ -> return ()
91112
Left err ->
92-
HUnit.assertFailure ("Excpected success but got: " ++ show err)
113+
HUnit.assertFailure ("Expected success but got: " ++ show err)
114+
115+
---------------------------------------------------------------------------
116+
-- * Auxiliary functions
93117

94118
tarGzFile :: String -> IO ByteString
95119
tarGzFile name = do

0 commit comments

Comments
 (0)