-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also refactor the system tests: instead of testing all backends at once in one test-suite, give each backend its own test suite. The benefit of that is that we can use flags in cabal to deactivate test suite if need be
- Loading branch information
Showing
5 changed files
with
258 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | ||
module Main where | ||
|
||
import Filesystem.Path (basename) | ||
import Filesystem.Path.CurrentOS (decodeString, encodeString) | ||
import Text.Printf (printf) | ||
import Shelly | ||
import Prelude hiding (FilePath) | ||
import Data.Text.Lazy (Text) | ||
import Control.Exception (assert) | ||
import Paths_BNFC | ||
import SystemTesting (systemTestMain, Backend, assertExists) | ||
|
||
default (Text) | ||
|
||
cBackend :: Backend | ||
cBackend bnfcBin cfFile testFile = | ||
shelly $ print_commands True $ withTmpDir $ \temp -> do | ||
cd temp | ||
-- Preconditions: testing for the existence of the input files | ||
assertExists cfFile | ||
assertExists testFile | ||
-- TODO test existance and executability of bnf | ||
bnfc "-m" "-c" cfFile | ||
make | ||
-- Now we run the test programme, passing the content of | ||
-- the test source file on stdin | ||
-- Note that we don't print stdout because it can be very verbose | ||
-- and we only rely on the status code returned by the test | ||
-- program to decide if the test passes or fails | ||
readfile testFile >>= setStdin | ||
test | ||
where make = cmd "make" | ||
bnfc = cmd bnfcBin | ||
testProg = decodeString ("Test" ++ (encodeString $ basename cfFile)) | ||
test = cmd ("." </> testProg) | ||
|
||
-- Main is defined in SystemTesting, we just pass our backend as a parameter | ||
main = systemTestMain cBackend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | ||
module Main where | ||
|
||
import Filesystem.Path (basename) | ||
import Filesystem.Path.CurrentOS (decodeString, encodeString) | ||
import Text.Printf (printf) | ||
import Shelly | ||
import Prelude hiding (FilePath) | ||
import Data.Text.Lazy (Text) | ||
import Control.Exception (assert) | ||
import Paths_BNFC | ||
import SystemTesting (systemTestMain, Backend, assertExists) | ||
|
||
default (Text) | ||
|
||
haskellBackend :: Backend | ||
haskellBackend bnfcBin cfFile testFile = | ||
shelly $ print_commands True $ withTmpDir $ \temp -> do | ||
cd temp | ||
-- Preconditions: testing for the existence of the input files | ||
assertExists cfFile | ||
assertExists testFile | ||
-- TODO test existance and executability of bnf | ||
bnfc "-m" "-haskell" cfFile | ||
make | ||
-- Now we run the test programme, passing the content of | ||
-- the test source file on stdin | ||
-- Note that we don't print stdout because it can be very verbose | ||
-- and we only rely on the status code returned by the test | ||
-- program to decide if the test passes or fails | ||
readfile testFile >>= setStdin | ||
test | ||
where make = cmd "make" | ||
bnfc = cmd bnfcBin | ||
testProg = decodeString ("Test" ++ (encodeString $ basename cfFile)) | ||
test = cmd ("." </> testProg) | ||
|
||
-- Main is defined in SystemTesting, we just pass our backend as a parameter | ||
main = systemTestMain haskellBackend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | ||
module Main where | ||
|
||
import Filesystem.Path (basename) | ||
import Filesystem.Path.CurrentOS (decodeString, encodeString) | ||
import Text.Printf (printf) | ||
import Shelly | ||
import Prelude hiding (FilePath) | ||
import Data.Text.Lazy (Text) | ||
import Control.Exception (assert) | ||
import Paths_BNFC | ||
import SystemTesting (systemTestMain, Backend, assertExists) | ||
|
||
default (Text) | ||
|
||
javaBackend :: Backend | ||
javaBackend bnfcBin cfFile testFile = | ||
shelly $ print_commands True $ withTmpDir $ \temp -> do | ||
cd temp | ||
-- Preconditions: testing for the existence of the input files | ||
assertExists cfFile | ||
assertExists testFile | ||
-- TODO test existance and executability of bnf | ||
bnfc "-m" "-java" cfFile | ||
make | ||
-- Now we run the test programme, passing the content of | ||
-- the test source file on stdin | ||
-- Note that we don't print stdout because it can be very verbose | ||
-- and we only rely on the status code returned by the test | ||
-- program to decide if the test passes or fails | ||
readfile testFile >>= setStdin | ||
java testProg | ||
where make = cmd "make" | ||
bnfc = cmd bnfcBin | ||
java = cmd "java" | ||
testProg = basename cfFile </> "Test" | ||
|
||
-- Main is defined in SystemTesting, we just pass our backend as a parameter | ||
main = systemTestMain javaBackend | ||
|