name: haeredes
-version: 0.3.0
+version: 0.4.0
cabal-version: >= 1.8
author: Michael Orlitzky
maintainer: Michael Orlitzky <michael@orlitzky.com>
MissingH == 1.2.*,
parallel-io == 0.3.*,
-- Test deps
- HUnit == 1.2.*,
- QuickCheck == 2.*,
- test-framework == 0.8.*,
- test-framework-hunit == 0.3.*,
- test-framework-quickcheck2 == 0.3.*
+ tasty == 0.8.*,
+ tasty-hunit == 0.8.*,
+ tasty-quickcheck == 0.8.*
main-is:
Main.hs
MissingH == 1.2.*,
parallel-io == 0.3.*,
-- Test deps
- HUnit == 1.2.*,
- QuickCheck == 2.*,
- test-framework == 0.8.*,
- test-framework-hunit == 0.3.*,
- test-framework-quickcheck2 == 0.3.*
+ tasty == 0.8.*,
+ tasty-hunit == 0.8.*,
+ tasty-quickcheck == 0.8.*
-- It's not entirely clear to me why I have to reproduce all of this.
ghc-options:
-BIN = dist/build/haeredes/haeredes
-TESTSUITE_BIN = dist/build/testsuite/testsuite
-DOCTESTS_BIN = dist/build/doctests/doctests
+PN = haeredes
+BIN = dist/build/$(PN)/$(PN)
+SRCS = $(shell find src/ -type f -name '*.hs')
-.PHONY : dist doc test
+.PHONY : dist hlint
-$(BIN): src/*.hs
- runghc Setup.hs clean
+$(BIN): $(PN).cabal $(SRCS)
runghc Setup.hs configure --user
runghc Setup.hs build
-$(TESTSUITE_BIN): src/*.hs test/TestSuite.hs
- runghc Setup.hs configure --user --enable-tests
+doc: $(PN).cabal $(SRCS)
+ runghc Setup.hs hscolour --all
+ runghc Setup.hs haddock --all \
+ --hyperlink-source \
+ --haddock-options="--ignore-all-exports"
+
+
+#
+# Tests
+#
+TESTSUITE_BIN = dist/build/testsuite/testsuite
+DOCTESTS_BIN = dist/build/doctests/doctests
+TEST_SRCS := $(shell find test/ -type f -name '*.hs')
+
+$(TESTSUITE_BIN): $(PN).cabal $(SRCS) $(TEST_SRCS)
+ runghc Setup.hs configure --user --enable-tests --prefix=/
runghc Setup.hs build
-$(DOCTESTS_BIN): src/*.hs test/Doctests.hs
+
+$(DOCTESTS_BIN): $(PN).cabal $(SRCS) $(TEST_SRCS)
runghc Setup.hs configure --user --enable-tests
runghc Setup.hs build
-clean:
- runghc Setup.hs clean
- rm -f src/*.hi
- rm -f src/*.o
-
test: $(BIN) $(TESTSUITE_BIN) $(DOCTESTS_BIN)
runghc Setup.hs test
-doc:
- runghc Setup.hs hscolour --executables
- runghc Setup.hs haddock --internal \
- --executables \
- --hyperlink-source
+
+#
+# Misc
+#
+
+dist:
+ runghc Setup.hs configure
+ TAR_OPTIONS="--format=ustar" runghc Setup.hs sdist
hlint:
hlint --ignore="Use camelCase" \
--color \
src
-dist:
- runghc Setup.hs configure
- runghc Setup.hs sdist
+clean:
+ runghc Setup.hs clean
+ find ./ -name '*.prof' -delete
+ find ./ -name '*.o' -delete
+ find ./ -name '*.hi' -delete
lookupNSAuth,
makeResolvSeed,
withResolver )
-import Test.Framework (Test, testGroup)
-import Test.Framework.Providers.HUnit (testCase)
-import Test.Framework.Providers.QuickCheck2 (testProperty)
-import Test.HUnit (assertEqual)
+import Test.Tasty ( TestTree, testGroup )
+import Test.Tasty.HUnit ( (@?=), testCase )
+import Test.Tasty.QuickCheck ( testProperty )
import Text.Read (readMaybe)
type LookupResult = (Domain, Either DNSError [Domain])
-- | Normalize the given name by appending a trailing dot (the DNS
-- root) if necessary.
+--
normalize_root :: Domain -> Domain
normalize_root d
| BS.null d = BS.pack "."
-- | Normalize the given name by lowercasing it.
+--
normalize_case :: Domain -> Domain
normalize_case = BS.map toLower
-test_normalize_case :: Test
+
+-- * Tests
+
+test_normalize_case :: TestTree
test_normalize_case =
- testCase desc $
- assertEqual desc expected actual
+ testCase desc $ actual @?= expected
where
desc = "normalize_case lowercases DNS names"
expected = BS.pack "example.com"
actual = normalize_case $ BS.pack "ExAmPlE.COM"
-prop_normalize_case_idempotent :: String -> Bool
-prop_normalize_case_idempotent s =
- (normalize_case . normalize_case) bs == normalize_case bs
+prop_normalize_case_idempotent :: TestTree
+prop_normalize_case_idempotent =
+ testProperty desc $ prop
where
- bs = BS.pack s
+ desc = "normalize_case is idempotent"
+
+ prop :: String -> Bool
+ prop s = (normalize_case . normalize_case) bs == normalize_case bs
+ where
+ bs = BS.pack s
-test_normalize_root_adds_dot :: Test
+test_normalize_root_adds_dot :: TestTree
test_normalize_root_adds_dot =
- testCase desc $
- assertEqual desc expected actual
+ testCase desc $ actual @?= expected
where
desc = "normalize_root adds a trailing dot"
expected = BS.pack "example.com."
actual = normalize_root $ BS.pack "example.com"
-prop_normalize_root_idempotent :: String -> Bool
-prop_normalize_root_idempotent s =
- (normalize_root . normalize_root) bs == normalize_root bs
+prop_normalize_root_idempotent :: TestTree
+prop_normalize_root_idempotent =
+ testProperty desc prop
where
- bs = BS.pack s
+ desc = "normalize_root is idempotent"
+
+ prop :: String -> Bool
+ prop s = (normalize_root . normalize_root) bs == normalize_root bs
+ where
+ bs = BS.pack s
-dns_tests :: Test
+dns_tests :: TestTree
dns_tests =
testGroup "DNS Tests" [
test_normalize_case,
test_normalize_root_adds_dot ]
-dns_properties :: Test
+dns_properties :: TestTree
dns_properties =
testGroup "DNS Properties" [
- testProperty
- "normalize_case is idempotent"
- prop_normalize_case_idempotent,
- testProperty
- "normalize_root is idempotent"
- prop_normalize_root_idempotent ]
+ prop_normalize_case_idempotent,
+ prop_normalize_root_idempotent ]
module Main
where
-import Data.Monoid (mempty)
-import Test.Framework (
- Test,
- defaultMainWithOpts )
-import Test.Framework.Runners.Options ( RunnerOptions )
+import Test.Tasty ( TestTree, defaultMain, testGroup )
-import DNS (dns_properties, dns_tests)
+import DNS ( dns_properties, dns_tests )
-main :: IO ()
-main = do
- let empty_options = mempty :: RunnerOptions
- defaultMainWithOpts tests empty_options
+tests :: TestTree
+tests = testGroup "All tests" [ dns_properties, dns_tests ]
-tests :: [Test]
-tests = [ dns_properties, dns_tests ]
+main :: IO ()
+main = defaultMain tests