Commits

Doug Burke  committed 7f24d6d

Use test-framework

  • Participants
  • Parent commits 235ce71

Comments (0)

Files changed (18)

+0.9.0.6:
+
+  Changed the test handling to use test-framework.
+
 0.9.0.5:
 
   Turtle/N3 output: more changes for string literals containing
 Name:               swish
-Version:            0.9.0.5
+Version:            0.9.0.6
 Stability:          experimental
 License:            LGPL
 License-file:       LICENSE 
   .
   * Complete, ready-to-run, command-line and script-driven programs.
   .
+  Changes in version @0.9.0.6@:
+  .
+  * Changed the test handling to use @test-framework@.
+  .
   Changes in version @0.9.0.5@:
   .
   * Turtle/N3 output: more changes for string literals containing
       base,
       containers,
       HUnit == 1.2.*,
-      swish
+      swish,
+      test-framework,
+      test-framework-hunit == 0.3.*
 
 Test-Suite test-graphpartition
    type:       exitcode-stdio-1.0
       containers,
       HUnit,
       semigroups,
-      swish
+      swish,
+      test-framework,
+      test-framework-hunit == 0.3.*
 
 Test-Suite test-graph
    type:       exitcode-stdio-1.0
       containers,
       hashable, 
       HUnit,
-      swish
+      swish,
+      test-framework,
+      test-framework-hunit == 0.3.*
 
 Test-Suite test-nt
    type:       exitcode-stdio-1.0
       containers,
       HUnit,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-turtle
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-n3parser
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-n3formatter
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-rdfdatatypexsdinteger
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-rdfgraph
       network,
       old-locale,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text,
       time
 
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-rdfproof
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-rdfquery
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-rdfruleset
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
 Test-Suite test-varbinding
       base,
       containers,
       HUnit,
-      swish
+      swish,
+      test-framework,
+      test-framework-hunit == 0.3.*
 
 Test-Suite test-qname
    type:       exitcode-stdio-1.0
       HUnit,
       network,
       swish,
+      test-framework,
+      test-framework-hunit == 0.3.*,
       text
 
  -- we do not have the data files to run this test

File tests/BuiltInMapTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  BuiltInMapTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
---
+-- 
 --  Maintainer  :  Douglas Burke
 --  Stability   :  experimental
 --  Portability :  OverloadedStrings
---
+-- 
 --  This module contains test cases for accessing built-in variable
 --  binding modifiers.
---
+-- 
 --------------------------------------------------------------------------------
 
 module Main where
 
+import qualified Test.Framework as TF
+
+import qualified Data.Map as M
+
 import Swish.Namespace (makeNSScopedName)
 import Swish.Ruleset (getMaybeContextAxiom, getMaybeContextRule)
 
     , namespaceXsdType
     )
 
-import qualified Data.Map as M
-
 import Test.HUnit
     ( Test(TestCase,TestList)
     , assertEqual
     )
 
-import TestHelpers (runTestSuite, testJust)
+import TestHelpers (conv, testJust)
 
 ------------------------------------------------------------
 --  Test finding built-in variable binding modifiers
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-    [ testVarModSuite
-    , testDatatypeSuite
-    , testRulesetSuite
-    , testFindAxiomSuite
-    , testFindRuleSuite
-    ]
+allTests :: [TF.Test]
+allTests =
+  [ conv "VarMod" testVarModSuite
+  , conv "Datatype" testDatatypeSuite
+  , conv "Ruleset" testRulesetSuite
+  , conv "FindAxiom" testFindAxiomSuite
+  , conv "FindRule" testFindRuleSuite
+  ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile :: Test -> IO ()
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    _ <- runTestText (putTextToHandle h False) t
-    hClose h
-    
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/GraphPartitionTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  GraphPartitionTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Test.Framework as TF
+
 import Swish.GraphPartition
     ( PartitionedGraph(..), getArcs
     , GraphPartition(..), node
 
 import Test.HUnit (Test(TestList))
 
-import TestHelpers (runTestSuite
-                    , testEq, testNe
+import TestHelpers (conv, testEq, testNe
                    , testEqv, testNotEqv
-                    )
+                   )
 
 ------------------------------------------------------------
 --  Basic GraphPartition tests
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-    [ testBasicSuite
-    , testPartitionSuite
-    , testCompareSuite
-    ]
+allTests :: [TF.Test]
+allTests =
+  [ conv "basic" testBasicSuite
+  , conv "partiton" testPartitionSuite
+  , conv "compare" testCompareSuite
+  ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/GraphTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  GraphTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 module Main where
 
 import qualified Data.Foldable as F
+import qualified Data.Map as M
+import qualified Data.Set as S
 
-import Test.HUnit
-      ( Test(TestCase,TestList,TestLabel),
-        assertEqual, assertBool )
+import qualified Test.Framework as TF
+import qualified Test.Framework.Providers.HUnit as TF
 
 import Swish.GraphClass (Arc(..), ArcSet, LDGraph(..), Label(..))
 import Swish.GraphClass (arc, arcFromTriple, arcToTriple)
 
 -- import Swish.Utils.ListHelpers (subset)
 
-import TestHelpers (runTestSuite, testEq, testNe)
-
 import Data.Function (on)
 import Data.Hashable (hashWithSalt)
 import Data.List (sort, sortBy, elemIndex)
 import Data.Ord (comparing)
 import Data.Word (Word32)
 
-import qualified Data.Map as M
-import qualified Data.Set as S
+import Test.HUnit
+      ( Test(TestCase,TestList,TestLabel)
+        , (@=?)
+        , assertEqual, assertBool )
+
+import TestHelpers (conv, testEq, testNe)
 
 default ( Int )
 
 -- All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
+allTests :: [TF.Test]
+allTests = 
   [ -- testSelectSuite
     -- testSubsetSuite
-    testLabSuite
-  , testGraphSuite
-  , testLabelEqSuite
-  , testLabelOrdSuite
-  , TestCase (assertBool "arc neq" (Arc True True True /= Arc True True False)) -- silly test of Eq instance
-  , testStmtEqSuite
-  , testLabelMapSuite
-  , testGraphMatchSupportSuite
-  , testGraphMatchStepSuite
-  , testGraphEqSuitePart
-  , testGraphEqSuite
-  , testGraphEqSuiteMore
+    conv "Lab" testLabSuite
+  , conv "Graph" testGraphSuite
+  , conv "LabelEq" testLabelEqSuite
+  , conv "LabelOrd" testLabelOrdSuite
+    -- silly test of Eq instance
+  , TF.testCase "arc neq"
+    (assertBool "arc neq" (Arc True True True /= Arc True True False))
+  , conv "StmtEq" testStmtEqSuite
+  , conv "LabelMap" testLabelMapSuite
+  , conv "GraphMatchSupport" testGraphMatchSupportSuite
+  , conv "GraphMatchStep" testGraphMatchStepSuite
+  , conv "GraphEq Part" testGraphEqSuitePart
+  , conv "GraphEq" testGraphEqSuite
+  , conv "GraphEq More" testGraphEqSuiteMore
     -- test of Foldable instance of Arc
-  , TestCase (assertEqual "fold Arc" [1::Int,2,4] (F.fold (Arc [1::Int] [2] [4])))
+  , TF.testCase "foldArc" ([1::Int,2,4] @=? F.fold (Arc [1::Int] [2] [4]))
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
-
-geq    = testGraphEqSuite
-geq1   = testGraphEqSuiteMore
-ttmore = tt testGraphEqSuiteMore    -- this test may take a long time
-tfmore = tf testGraphEqSuiteMore
-ttstep = tt testGraphMatchStepSuite
-tfstep = tf testGraphMatchStepSuite
-
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/N3FormatterTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  N3FormatterTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Map as M
+import qualified Data.Set as S
+import qualified Data.Text as T
+import qualified Data.Text.Lazy as L
+import qualified Data.Text.Lazy.Builder as B
+
+import qualified Test.Framework as TF
+
 import Swish.GraphClass (Arc, arc)
 import Swish.Namespace (Namespace, makeNamespace, getNamespaceTuple, makeNSScopedName, namespaceToBuilder)
 import Swish.QName (LName)
 
 import Data.String (IsString(..))
 
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.Text as T
-import qualified Data.Text.Lazy as L
-import qualified Data.Text.Lazy.Builder as B
-
 import Test.HUnit
     ( Test(TestCase,TestList)
     , assertEqual )
 
-import TestHelpers (runTestSuite, testCompareEq)
+import TestHelpers (conv, testCompareEq)
 
 -- Specialized equality comparisons
 
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-  [ trivialTestSuite
-  , parseTestSuite
-  , roundTripTestSuite
-  , simpleTestSuite
-  , exoticTestSuite
+allTests :: [TF.Test]
+allTests = 
+  [ conv "trivial" trivialTestSuite
+  , conv "parse" parseTestSuite
+  , conv "roundtrip" roundTripTestSuite
+  , conv "simple" simpleTestSuite
+  , conv "exotic" exoticTestSuite
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/N3ParserTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  N3ParserTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Map as M
+import qualified Data.Set as S
+import qualified Data.Text as T
+import qualified Data.Text.Lazy as L
+import qualified Data.Text.Lazy.Builder as B
+
+import qualified Test.Framework as TF
+
 import Swish.GraphClass (Arc, arc) 
 import Swish.Namespace (
   Namespace, makeNamespace, getNamespaceURI, getNamespaceTuple
 import Data.Maybe (fromJust, fromMaybe)
 import Data.List (intercalate)
 
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.Text as T
-import qualified Data.Text.Lazy as L
-import qualified Data.Text.Lazy.Builder as B
-
-import TestHelpers (runTestSuite, testCompareEq)
+import TestHelpers (conv, testCompareEq)
 
 -- Specialized equality comparisons
 
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-  [ charTestSuite
-  , nameTestSuite
+allTests :: [TF.Test]
+allTests = 
+  [ conv "char" charTestSuite
+  , conv "name" nameTestSuite
   -- , prefixTestSuite
-  , absUriRefTestSuite
-  , uriRef2TestSuite
-  , simpleTestSuite
-  , litTestSuite
-  , exoticTestSuite
-  , keywordTestSuite
-  , failTestSuite
+  , conv "absUriRef" absUriRefTestSuite
+  , conv "uriRef2" uriRef2TestSuite
+  , conv "simple" simpleTestSuite
+  , conv "lit" litTestSuite
+  , conv "exotic" exoticTestSuite
+  , conv "keyword" keywordTestSuite
+  , conv "fail" failTestSuite
   ]
 
 main :: IO ()
-main = runTestSuite allTests
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/NTTest.hs

 
 module Main where
 
+import qualified Data.Set as S
+import qualified Data.Text.Lazy as T
+
+import qualified Test.Framework as TF
+import qualified Test.Framework.Providers.HUnit as TF
+
 import Swish.GraphClass (arc)
 
 import Swish.RDF.Parser.NTriples (parseNT)
 
 import Test.HUnit
     ( Test(TestCase,TestList)
+    , (@=?)
     , assertEqual )
 
 import Data.Maybe (fromJust)
-import TestHelpers (runTestSuite)
 
-import qualified Data.Set as S
-import qualified Data.Text.Lazy as T
+import TestHelpers (conv)
 
 ------------------------------------------------------------
 --  Parser tests
     , TestCase (assertEqual ("roundTrip-graph:"++lbl)    pGr1    pGr2)
     ]
 
+roundTripTF :: String -> T.Text -> TF.Test
+roundTripTF lbl inp = 
+  let (pErr1, pGr1) = case parseNT inp of
+        Right g -> (noError, g)
+        Left  s -> (s, emptyRDFGraph)
+        
+      inp2 = formatGraphAsLazyText pGr1
+      
+      (pErr2, pGr2) = case parseNT inp2 of
+        Right g -> (noError, g)
+        Left  s -> (s, emptyRDFGraph)
+        
+  in TF.testGroup ("roundTrip:" ++ lbl)
+     [ TF.testCase "parsing1" (noError @=? pErr1)
+     , TF.testCase "parsing2" (noError @=? pErr2)
+     , TF.testCase "graph"    (pGr1    @=? pGr2)
+     ]
+
 
 ------------------------------------------------------------
 --  Rather than bother with locating an external file,
          , checkGraph "graphm1r" graphm1r gm1
          ]
 
-oTests :: Test
-oTests =
-  TestList
-  [ roundTrip "langtag" "<urn:a> <urn:b> \"Foo .\"@en-UK."
-  ]
-  
-allTests :: Test              
+allTests :: [TF.Test]
 allTests = 
-  TestList
-  [ rTests
-  , eTests
-  , gTests
-  , oTests
+  [ conv "r" rTests
+  , conv "e" eTests
+  , conv "g" gTests
+  , roundTripTF "langtag" "<urn:a> <urn:b> \"Foo .\"@en-UK."
   ]
   
 main :: IO ()  
-main = runTestSuite allTests
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --

File tests/QNameTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  QNameTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Text as T
+
+import qualified Test.Framework as TF
+
 import Swish.Namespace (makeQNameScopedName, getQName, getScopedNameURI)
 import Swish.QName
     ( QName
     , getLName
     )
 
+import Data.Maybe (fromJust)
+
+import Network.URI (URI, parseURIReference)
+
 import Test.HUnit (Test(TestList))
 
-import Network.URI (URI, parseURIReference)
-import Data.Maybe (fromJust)
-
-import qualified Data.Text as T
-
-import TestHelpers (runTestSuite
-                    , testCompare
-                    , testCompareEq
-                   )
+import TestHelpers (conv, testCompare, testCompareEq)
 
 ------------------------------------------------------------
 --  Define some common values
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-  [ testQNameEqSuite
-  , testMakeQNameSuite
-  , testPartQNameSuite
-  , testMaybeQNameEqSuite
-  , testQNameLeSuite
-  , testShowQNameSuite
-  , testSplitURISuite
-  , testSNameTTSuite
+allTests :: [TF.Test]
+allTests = 
+  [ conv "QNameEq" testQNameEqSuite
+  , conv "MakeQName" testMakeQNameSuite
+  , conv "PartQName" testPartQNameSuite
+  , conv "MaybeQNameEq" testMaybeQNameEqSuite
+  , conv "QNameLe" testQNameLeSuite
+  , conv "ShowQName" testShowQNameSuite
+  , conv "SplitURI" testSplitURISuite
+  , conv "SNameTT" testSNameTTSuite
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
---  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
+--  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
+--      2011, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/RDFDatatypeXsdIntegerTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  RDFDatatypeXsdIntegerTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Map as M
+import qualified Data.Text as T
+import qualified Data.Text.Lazy.Builder as B
+
+import qualified Test.Framework as TF
+
 import Swish.Datatype
     ( typeName, typeRules, typeMkRules
     , getTypeAxiom, getTypeRule
 
 import Network.URI (URI, parseURI)
 
-import qualified Data.Map as M
-import qualified Data.Text as T
-import qualified Data.Text.Lazy.Builder as B
-
 import Test.HUnit
     ( Test(TestCase,TestList)
       , assertFailure
     )
-import TestHelpers (runTestSuite
-                   , testEq, testElem, testEqv, testEqv2)
+import TestHelpers (conv, testEq, testElem, testEqv, testEqv2)
 
 ------------------------------------------------------------
 --  Misc values
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-    [ testDatatypeSuite
-    , testDatatypeValSuite
-    , testVarModifySuite
-    , testDatatypeRuleSuite
-    ]
+allTests :: [TF.Test]
+allTests = 
+  [ conv "Datatype" testDatatypeSuite
+  , conv "DatatypeVal" testDatatypeValSuite
+  , conv "VarModify" testVarModifySuite
+  , conv "DatatypeRule" testDatatypeRuleSuite
+  ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-trules = runTestTT testDatatypeRuleSuite
-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/RDFGraphTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  RDFGraphTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Map as M
+import qualified Data.Set as S
+import qualified Data.Text as T
+
+-- import qualified Data.Traversable as Traversable
+import qualified Data.Foldable as Foldable
+
+import qualified Test.Framework as TF
+
 import Swish.Namespace (Namespace, makeNamespace, getNamespaceURI, getNamespaceTuple, ScopedName, makeNSScopedName, nullScopedName)
 import Swish.QName (QName, qnameFromURI)
 
 
 import System.Locale (defaultTimeLocale)
 
-import qualified Data.Map as M
-import qualified Data.Set as S
-import qualified Data.Text as T
-
--- import qualified Data.Traversable as Traversable
-import qualified Data.Foldable as Foldable
-
 import Test.HUnit
     ( Test(TestCase,TestList,TestLabel)
     , Assertion
     , assertBool, assertEqual )
 
-import TestHelpers ( runTestSuite
-                   , testEq
+import TestHelpers ( conv, testEq
                    , testEqv
                    , testCompare
                    , testCompareEq)
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-  [ testLangEqSuite
-  , testConversionSuite
-  , testNodeEqSuite
-  , testNodeClassSuite
-  , testNodeLocalSuite
-  , testNewNodeSuite
-  , testNodeOrdSuite
-  , testLabelOtherSuite
-  , testStmtEqSuite
-  , testGraphEqSuite
-  , testGraphEqSelSuite
-  , testGraphFoldSuite
-  , testGraphFormulaSuite
-  , testGraphTranslateSuite
-  , testMergeSuite
+allTests :: [TF.Test]
+allTests = 
+  [ conv "LangEq" testLangEqSuite
+  , conv "Conversion" testConversionSuite
+  , conv "NodeEq" testNodeEqSuite
+  , conv "NodeClass" testNodeClassSuite
+  , conv "NodeLocal" testNodeLocalSuite
+  , conv "NewNode" testNewNodeSuite
+  , conv "NodeOrd" testNodeOrdSuite
+  , conv "LabelOther" testLabelOtherSuite
+  , conv "StmtEq" testStmtEqSuite
+  , conv "GraphEq" testGraphEqSuite
+  , conv "GraphEqSel" testGraphEqSelSuite
+  , conv "GraphFold" testGraphFoldSuite
+  , conv "GraphFormula" testGraphFormulaSuite
+  , conv "GraphTranslate" testGraphTranslateSuite
+  , conv "Merge" testMergeSuite
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
-
-geq  = testGraphEqSuite
-nord = testNodeOrdSuite
-gtr  = testGraphTranslateSuite
-
-gmm g1 g2 = grMatchMap g1 g2
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke  
+--    2011, 2012, 2013 Douglas Burke  
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/RDFProofContextTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  RDFProofContextTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Map as M
+import qualified Data.Text as T
+import qualified Data.Text.Lazy.Builder as B
+
+import qualified Test.Framework as TF
+
 import Swish.Namespace (Namespace, makeNamespace, ScopedName, makeNSScopedName, namespaceToBuilder)
 import Swish.QName (LName, newLName)
 import Swish.Proof (Step(..), checkProof, checkStep, explainProof)
 
 import Network.URI (URI, parseURI)
 
-import qualified Data.Map as M
-import qualified Data.Text as T
-import qualified Data.Text.Lazy.Builder as B
-
 import Test.HUnit
     ( Test(TestCase,TestList)
     , assertBool, assertEqual )
-import TestHelpers ( runTestSuite
-                     , test
+import TestHelpers ( conv, test
                      , testEq
                      , testElem
                      )
 --  and useful expressions for interactive use
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-  [ testRules
-  , testRdf
+allTests :: [TF.Test]
+allTests =
+  [ conv "rules" testRules
+  , conv "rdf" testRdf
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
-
-p10 = runTestTT $ TestList
-    [ rdfAxiom10
-    , rdfRule10
-    , testProof     "rdfProof10" True  rdfProof10
-    ]
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/RDFProofTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  RDFProofTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Set as S
+import qualified Data.Text as T
+import qualified Data.Text.Lazy.Builder as B
+
+import qualified Test.Framework as TF
+
 import Swish.Namespace (Namespace, makeNamespace, ScopedName, makeNSScopedName)
 import Swish.Rule (Rule(..))
 import Swish.VarBinding (VarBinding(..), VarBindingModify(..))
     ( Label(..), RDFLabel(..), RDFGraph
     , addGraphs, allLabels, allNodes )
 
-import Test.HUnit ( Test(TestList) )
+import Data.Monoid (Monoid(..))
+import Data.Maybe (fromJust)
 
 import Network.URI (URI, parseURI)
 
-import Data.Monoid (Monoid(..))
-import Data.Maybe (fromJust)
+import Test.HUnit ( Test(TestList) )
 
-import qualified Data.Set as S
-import qualified Data.Text as T
-import qualified Data.Text.Lazy.Builder as B
-
-import TestHelpers ( runTestSuite
-                     , test
-                     , testEq, testElem
-                     , testNo
+import TestHelpers ( conv, test
+                   , testEq, testElem
+                   , testNo
                    )
 
 --  misc helpers
 
 --  Full test suite, main program, and useful expressions for interactive use
 
-allTests :: Test
-allTests = TestList
-  [ test1
-  , test2
-  , test3
-  , test4
-  , test5
-  , test6
-  , test7
+allTests :: [TF.Test]
+allTests =
+  [ conv "1" test1
+  , conv "2" test2
+  , conv "3" test3
+  , conv "4" test4
+  , conv "5" test5
+  , conv "6" test6
+  , conv "7" test7
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
---  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke  
+--  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
+--     2011, 2013 Douglas Burke  
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/RDFQueryTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  RDFQueryTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Set as S
+import qualified Data.Text.Lazy.Builder as B
+
+import qualified Test.Framework as TF
+
 import Swish.Namespace (getNamespaceURI, ScopedName, makeScopedName)
 import Swish.VarBinding
     ( VarBinding(..)
 
 import Network.URI (URI, parseURI)
 
-import qualified Data.Set as S
-import qualified Data.Text.Lazy.Builder as B
-
 import Test.HUnit ( Test(TestList) )
-import TestHelpers (runTestSuite
-                   , test
+import TestHelpers ( conv, test
                    , testEq
                    , testElem
                    , testEqv
 --  and useful expressions for interactive use
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-  [ test1
-  , test2
-  , test3
-  , test4
-  , test6
-  , test7
+allTests :: [TF.Test]
+allTests = 
+  [ conv "1" test1
+  , conv "2" test2
+  , conv "3" test3
+  , conv "4" test4
+  , conv "6" test6
+  , conv "7" test7
 --  , test8
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
-
-shres32 = TestCase $ assertString (show res32)
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke  
+--    2011, 2012, 2013 Douglas Burke  
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/RDFRulesetTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  RDFRulesetTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Set as S
+import qualified Data.Text.Lazy.Builder as B
+
+import qualified Test.Framework as TF
+
+import qualified TestHelpers as TH
+
 import Swish.Namespace (Namespace, makeNamespace, getNamespaceTuple, getNamespaceURI, ScopedName, makeScopedName, makeNSScopedName, namespaceToBuilder)
 import Swish.QName (LName)
 import Swish.Rule (Formula(..), Rule(..), fwdCheckInference )
     
 import Swish.RDF.Vocabulary (namespaceRDF, namespaceRDFS, namespaceOWL, scopeRDF)
 
+import Data.Monoid (Monoid(..))
+import Data.List (sort)
+import Data.Maybe (isJust, fromJust)
+import Data.Text (Text)
+
 import Test.HUnit
     ( Test(TestCase,TestList)
     , assertBool
 
 import Network.URI (URI, parseURI)
 
-import Data.Monoid (Monoid(..))
-import Data.List (sort)
-import Data.Maybe (isJust, fromJust)
-import Data.Text (Text)
-
-import qualified Data.Set as S
-import qualified Data.Text.Lazy.Builder as B
-
-import TestHelpers (runTestSuite
-                   , test
+import TestHelpers ( conv, test
                    , testLe
                    , testCompare
                    , testCompareEq
                    , testMaker
                    )
 
-import qualified TestHelpers as TH
-
 ------------------------------------------------------------
 --  Test case helpers
 ------------------------------------------------------------
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-  [ testFormulaSuite
-  , testRuleSuite
-  , testRulesetSuite
-  , testRDFSuite
+allTests :: [TF.Test]
+allTests = 
+  [ conv "Formula" testFormulaSuite
+  , conv "Rule" testRuleSuite
+  , conv "Ruleset" testRulesetSuite
+  , conv "RDF" testRDFSuite
   ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
---    2011, 2012 Douglas Burke
+--    2011, 2012, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.

File tests/TestHelpers.hs

 --
 --------------------------------------------------------------------------------
 
+-- TODO: move to using test-framework
+
 module TestHelpers
        ( 
-         runTestSuite
+         conv
          , test
          , testCompare, testCompareEq
          , testEq, testNe, testLe, testGe
          )
        where
 
-import System.Exit (exitSuccess, exitFailure)
+import qualified Data.Set as S
 
-import Test.HUnit (Test(TestCase, TestList)
-                   , runTestTT
-                   , Assertion
-                   , assertBool, assertEqual, assertFailure
-                   )
-import Test.HUnit.Base (Counts(..))
+import qualified Test.Framework as TF
+import qualified Test.Framework.Providers.HUnit as TF
 
 import Control.Monad (unless)
 
 import Data.Maybe (isJust, isNothing, fromJust)
 
-import qualified Data.Set as S
+import Test.HUnit (Test(TestCase, TestList)
+                   , Assertion
+                   , assertBool, assertEqual, assertFailure
+                   )
 
--- | Run the test suite and exit the process with either 
--- @exitSuccess@ or @exitFailure@.
-runTestSuite :: Test -> IO ()
-runTestSuite tests = do
-  Counts ncases ntried nerrors nfailures <- runTestTT tests
-  -- It's not clear whether all these checks are needed but leave in
-  if ntried == ncases && nerrors == nfailures && nerrors == 0
-    then exitSuccess
-    else exitFailure
+-- quick conversion from a set of HUnit tests to
+-- a labelled test-framework group.
+--
+conv :: String -> Test -> TF.Test
+conv lbl = TF.testGroup lbl . TF.hUnitTestToTests
 
 ------------------------------------------------------------
 --  Test case helpers
     TestCase ( assertEqual (typ++lab) eq (a1==a2) )
 
 testMaker :: (Show b, Eq b) => (a -> b) -> String -> String -> a -> a -> Test
-testMaker conv l1 l2 x y =
-  TestCase (assertEqual (l1 ++ ":" ++ l2) (conv x) (conv y))
+testMaker f l1 l2 x y =
+  TestCase (assertEqual (l1 ++ ":" ++ l2) (f x) (f y))
 
 testEq :: (Eq a, Show a) => String -> a -> a -> Test
 testEq = testCompare "testEq:"
     ]
 -}
 
-------------------------------------------------------------
---  All tests
-------------------------------------------------------------
-
-{-
-allSuccessTests = TestList
-    [ testSuccessSuite
-    ]
-
-allFailureTests = TestList
-    [ testFailureSuite
-    ]
-
-mainS = runTestTT allSuccessTests
-mainF = runTestTT allFailureTests
--}
-
 --------------------------------------------------------------------------------
 --
 --  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke

File tests/TurtleTest.hs

 import qualified Data.Text as T
 import qualified Data.Text.Lazy as L
 
+import qualified Test.Framework as TF
+
 import Data.Char (chr)
 import Data.Maybe (fromMaybe)
 
 
 import Test.HUnit (Test(TestCase,TestList), (~=?), (~:), assertFailure)
 
-import TestHelpers (runTestSuite)
+import TestHelpers (conv)
 
 triple :: (ToRDFLabel s, ToRDFLabel p, ToRDFLabel o)
           => s -> p -> o -> RDFTriple
 
 --
 
-allTests :: Test
-allTests = TestList
-  [ initialTestSuite
-  , coverageCases
-  , w3cCases
+allTests :: [TF.Test]
+allTests = 
+  [ conv "initial" initialTestSuite
+  , conv "coverage" coverageCases
+  , conv "w3c" w3cCases
   ]
 
 main :: IO ()
-main = runTestSuite allTests
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --

File tests/VarBindingTest.hs

 --------------------------------------------------------------------------------
 -- |
 --  Module      :  VarBindingTest
---  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
+--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2013 Douglas Burke
 --  License     :  GPL V2
 --
 --  Maintainer  :  Douglas Burke
 
 module Main where
 
+import qualified Data.Set as S
+
+import qualified Test.Framework as TF
+
 import Swish.VarBinding
     ( VarBinding(..)
     , subBinding, nullVarBinding, makeVarBinding
 import Data.List (union, intersect)
 import Data.Maybe (isJust, isNothing, fromJust)
 
-import qualified Data.Set as S
-
 import Test.HUnit (Test(TestList))
-import TestHelpers (runTestSuite
-                    , test
+import TestHelpers ( conv, test
                     , testEq 
                     , testEqv, testEqv2, testHasEqv, testMaybeEqv
                     , testJust, testNothing  
 --  All tests
 ------------------------------------------------------------
 
-allTests :: Test
-allTests = TestList
-    [ testVarBindingSuite
-    , testVarModifySuite
-    , testVarComposeSuite
-    , testFindCompSuite
-    , testFilterSuite
-    ]
+allTests :: [TF.Test]
+allTests = 
+  [ conv "VarBinding" testVarBindingSuite
+  , conv "VarModify" testVarModifySuite
+  , conv "VarCompose" testVarComposeSuite
+  , conv "FindComp" testFindCompSuite
+  , conv "Filter" testFilterSuite
+  ]
 
 main :: IO ()
-main = runTestSuite allTests
-
-{-
-runTestFile t = do
-    h <- openFile "a.tmp" WriteMode
-    runTestText (putTextToHandle h False) t
-    hClose h
-tf = runTestFile
-tt = runTestTT
--}
+main = TF.defaultMain allTests
 
 --------------------------------------------------------------------------------
 --
---  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
+--  Copyright (c) 2003, Graham Klyne, 2009 Vasili I Galchin,
+--      2011, 2013 Douglas Burke
 --  All rights reserved.
 --
 --  This file is part of Swish.