tests
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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 Data.List (List)
|
||||
import Data.Functor ((<&>))
|
||||
import System.Directory
|
||||
import Data.Function
|
||||
|
||||
|
||||
disabled :: List String
|
||||
disabled =
|
||||
[ "square"
|
||||
]
|
||||
|
||||
main :: IO ()
|
||||
main = defaultMain =<< goldenTests
|
||||
|
||||
goldenTests :: IO TestTree
|
||||
goldenTests = do
|
||||
all_cases <- listDirectory "golden"
|
||||
let tests = all_cases
|
||||
& filter (`notElem` disabled)
|
||||
& fmap ("golden"</>)
|
||||
pure $ testGroup "golden"
|
||||
[ 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 -> TestTree
|
||||
executionTests files =
|
||||
testGroup "execution" $ files <&> \test ->
|
||||
let wat = test </> "out.wat"
|
||||
testname = takeFileName test
|
||||
resultfile = test </> "exec"
|
||||
in goldenVsProg
|
||||
testname
|
||||
resultfile
|
||||
"wasmtime"
|
||||
["--invoke", "main", wat]
|
||||
""
|
||||
Reference in New Issue
Block a user