@@ -0,0 +1,45 @@
|
||||
module Gyehoek.Test.Golden (root) where
|
||||
|
||||
import Test.Tasty (TestTree, testGroup)
|
||||
import Test.Tasty.Silver
|
||||
import Gyehoek.Driver qualified as Driver
|
||||
import System.FilePath
|
||||
import Data.List (List)
|
||||
import Data.Functor ((<&>))
|
||||
import System.Directory
|
||||
import Data.Function
|
||||
import System.Environment.Blank (getEnvDefault)
|
||||
import qualified System.Process.Text as PT
|
||||
|
||||
|
||||
disabled :: List String
|
||||
disabled =
|
||||
[ "square"
|
||||
]
|
||||
|
||||
root :: IO TestTree
|
||||
root = do
|
||||
all_cases <- listDirectory "golden"
|
||||
let tests = all_cases
|
||||
& filter (`notElem` disabled)
|
||||
& fmap ("golden"</>)
|
||||
testGroup "golden" <$> sequenceA
|
||||
[ executionTests tests
|
||||
]
|
||||
|
||||
executionTests :: List FilePath -> IO TestTree
|
||||
executionTests files = do
|
||||
cmd <- getEnvDefault "GYEHOEK_RUNTIME"
|
||||
"runtime/target/debug/gyehoek-runtime"
|
||||
pure $ testGroup "execution" $ files <&> \test ->
|
||||
let testname = takeFileName test
|
||||
scmfile = test </> "source.scm"
|
||||
resultfile = test </> "exec"
|
||||
action = do
|
||||
t <- Driver.lower_e2e scmfile
|
||||
PT.readProcessWithExitCode cmd ["-"] t
|
||||
in goldenVsAction
|
||||
testname
|
||||
resultfile
|
||||
action
|
||||
printProcResult
|
||||
+7
-51
@@ -1,60 +1,16 @@
|
||||
module Main (main) where
|
||||
|
||||
import Test.Tasty (TestTree, testGroup)
|
||||
import Test.Tasty.Silver
|
||||
import Test.Tasty.Silver.Interactive (defaultMain)
|
||||
import Data.Traversable
|
||||
import Gyehoek.Driver qualified as Driver
|
||||
import System.FilePath
|
||||
import qualified Gyehoek.Test.Golden
|
||||
import Data.List (List)
|
||||
import Data.Functor ((<&>))
|
||||
import System.Directory
|
||||
import Data.Function
|
||||
import System.Environment.Blank (getEnvDefault)
|
||||
|
||||
|
||||
disabled :: List String
|
||||
disabled =
|
||||
[ "square"
|
||||
main :: IO ()
|
||||
main = defaultMain =<< root
|
||||
|
||||
root :: IO TestTree
|
||||
root = testGroup "test" <$> sequenceA
|
||||
[ Gyehoek.Test.Golden.root
|
||||
]
|
||||
|
||||
main :: IO ()
|
||||
main = defaultMain =<< goldenTests
|
||||
|
||||
goldenTests :: IO TestTree
|
||||
goldenTests = do
|
||||
all_cases <- listDirectory "golden"
|
||||
let tests = all_cases
|
||||
& filter (`notElem` disabled)
|
||||
& fmap ("golden"</>)
|
||||
testGroup "golden" <$> sequenceA
|
||||
[ pure $ watTests tests
|
||||
, executionTests tests
|
||||
]
|
||||
|
||||
watTests :: List FilePath -> TestTree
|
||||
watTests files =
|
||||
testGroup "wat" $ files <&> \test ->
|
||||
let source = test </> "source.scm"
|
||||
golden = test </> "out.wat"
|
||||
testname = takeFileName test
|
||||
in goldenVsAction
|
||||
testname
|
||||
golden
|
||||
(Driver.lower_e2e source)
|
||||
id
|
||||
|
||||
executionTests :: List FilePath -> IO TestTree
|
||||
executionTests files = do
|
||||
cmd <- getEnvDefault "GYEHOEK_RUNTIME"
|
||||
"runtime/target/debug/gyehoek-runtime"
|
||||
pure $ testGroup "execution" $ files <&> \test ->
|
||||
let wat = test </> "out.wat"
|
||||
testname = takeFileName test
|
||||
resultfile = test </> "exec"
|
||||
in goldenVsProg
|
||||
testname
|
||||
resultfile
|
||||
cmd
|
||||
[wat]
|
||||
"" -- stdin
|
||||
|
||||
Reference in New Issue
Block a user