From: Nathaniel Wesley Filardo Date: Wed, 12 Jun 2013 17:34:21 +0000 (-0400) Subject: Wire test/repl into Backend.Python.Selftest X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=25ff563a7823776da640fdccddf7f0793a9b6158;p=dyna2 Wire test/repl into Backend.Python.Selftest While here, some related cleanups --- diff --git a/.gitignore b/.gitignore index 26624b4..6629aa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.hi *.o *.pyc +*.swp dist/ examples/*.d @@ -10,3 +11,7 @@ examples/*.plan.py examples/*.out docs/sphinx/_build + +test/*/*.out + +libpeerconnection.log diff --git a/Makefile b/Makefile index 398eb8c..def8f9f 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ clean: rm -rf examples/*.dyna.*.plan \ examples/*.dyna.*.out \ examples/*.dyna.d + rm -rf test/*/*.out rm -f tags TAGS veryclean: clean rm -rf dist diff --git a/dyna.cabal b/dyna.cabal index 704e399..25dd11f 100644 --- a/dyna.cabal +++ b/dyna.cabal @@ -14,9 +14,10 @@ Homepage: http://www.dyna.org/ Category: Compilers/Interpreters Synopsis: Interpreter for the Dyna language Description: A weighted logic programming language for dynamic - programming and natural language processing. Features - include memoization, both forward- and backward-chaining, - and namespace modularity. + programming and natural language processing. + + -- Features include memoization, both forward- and + -- backward-chaining, and namespace modularity. source-repository head type: git @@ -156,10 +157,11 @@ Test-suite dyna-selftests tagged >= 0.4.4, template-haskell, test-framework >=0.6, + test-framework-golden >= 1.1, test-framework-hunit >=0.2, + test-framework-program >= 1.1, test-framework-quickcheck2 >=0.3, test-framework-th >=0.2, - test-framework-golden >= 1.1, transformers >= 0.3, trifecta >= 1.0, unordered-containers>=0.2, diff --git a/src/Dyna/Backend/Python/Selftest.hs b/src/Dyna/Backend/Python/Selftest.hs index 0581db0..1f59c81 100644 --- a/src/Dyna/Backend/Python/Selftest.hs +++ b/src/Dyna/Backend/Python/Selftest.hs @@ -4,6 +4,7 @@ -- Header material {{{ {-# LANGUAGE ImplicitParams #-} +{-# LANGUAGE TemplateHaskell #-} module Dyna.Backend.Python.Selftest where import Control.Exception (throw) @@ -14,7 +15,9 @@ import System.Exit (ExitCode(..)) import System.IO import System.IO.Error import System.Process -import qualified Test.Framework as TF +import Test.Framework as TF +import Test.Framework.Providers.Program +import Test.Framework.TH import Test.Golden ------------------------------------------------------------------------}}} @@ -68,22 +71,24 @@ mkExample name = , "examples/" ++ name ++ ".dyna.py.out" , "examples/expected/" ++ name ++ ".py.out") -goldens :: TF.Test -goldens = TF.testGroup "Python Backend End-To-End" - -- Sorted roughly by likelihood that all subsequent examples - -- will be broken. ;) - $ map mkExample [ "simple", "fib-limit", "dijkstra" - , "papa2", "matrixops" - ] +-- Sorted roughly by likelihood that all subsequent examples +-- will be broken. ;) +test_End_To_End :: [Test] +test_End_To_End = map mkExample + [ "simple", "fib-limit", "dijkstra", "papa2", "matrixops" ] + +test_REPL :: [Test] +test_REPL = map (\n -> testProgramRuns n ("./test/repl/"++n) []) + [ "aggregator-conflict", "retract-rule" ] ------------------------------------------------------------------------}}} -- Harness toplevel {{{ selftest :: TF.Test -selftest = goldens +selftest = $(testGroupGenerator) main :: IO () -main = TF.defaultMain [selftest] +main = $(defaultMainGenerator) -- If you're running from within GHCi and just want to do something quickly, -- try diff --git a/test/repl/aggregator-conflict b/test/repl/aggregator-conflict index 3fd4ee5..6b9b95a 100755 --- a/test/repl/aggregator-conflict +++ b/test/repl/aggregator-conflict @@ -4,4 +4,4 @@ echo -e " a += 1. a." |./dyna > $0.out -colordiff $0.expect $0.out && echo pass +diff $0.expect $0.out && echo pass diff --git a/test/repl/retract-rule b/test/repl/retract-rule index e96b1c2..cacff9a 100755 --- a/test/repl/retract-rule +++ b/test/repl/retract-rule @@ -10,7 +10,7 @@ retract_rule 0 retract_rule 1 chart" |./dyna > $0.out -colordiff $0.expect $0.out && echo pass +diff $0.expect $0.out && echo pass # TODO: add test to make sure that rule retraction will clear errors.