2019-05-07 12:42:45 +03:00
|
|
|
module Main
|
|
|
|
|
|
|
|
import System
|
|
|
|
|
|
|
|
%default covering
|
|
|
|
|
|
|
|
ttimpTests : List String
|
|
|
|
ttimpTests
|
2019-05-11 22:50:51 +03:00
|
|
|
= ["basic001", "basic002", "basic003", "basic004", "basic005",
|
2019-05-26 13:34:02 +03:00
|
|
|
"basic006",
|
2019-06-03 01:43:21 +03:00
|
|
|
"coverage001", "coverage002",
|
2019-05-25 20:39:21 +03:00
|
|
|
"dot001",
|
2019-05-07 17:06:00 +03:00
|
|
|
"eta001", "eta002",
|
2019-05-22 21:42:43 +03:00
|
|
|
"lazy001",
|
2019-05-17 15:52:09 +03:00
|
|
|
"nest001", "nest002",
|
2019-05-19 22:24:14 +03:00
|
|
|
"perf001", "perf002", "perf003",
|
2019-05-27 12:56:13 +03:00
|
|
|
"record001", "record002",
|
2019-05-27 14:15:37 +03:00
|
|
|
"rewrite001",
|
2019-05-26 13:34:02 +03:00
|
|
|
"qtt001", "qtt002", "qtt003",
|
2019-06-02 03:23:01 +03:00
|
|
|
"search001", "search002", "search003", "search004", "search005",
|
2019-06-05 19:28:55 +03:00
|
|
|
"total001", "total002", "total003",
|
2019-05-29 13:57:07 +03:00
|
|
|
"with001"]
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-06-09 13:58:29 +03:00
|
|
|
idrisTests : List String
|
|
|
|
idrisTests
|
2019-06-27 15:42:49 +03:00
|
|
|
= ["basic001", "basic002", "basic003", "basic004", "basic005",
|
2019-06-27 21:16:33 +03:00
|
|
|
"basic006", "basic007", "basic008", "basic009", "basic010",
|
2019-06-27 22:19:00 +03:00
|
|
|
"basic011", "basic012", "basic013", "basic014", "basic015",
|
2019-06-29 22:51:48 +03:00
|
|
|
"basic016", "basic017", "basic018", "basic019", "basic020",
|
2019-07-03 17:11:57 +03:00
|
|
|
"basic021", "basic022", "basic023", "basic024",
|
2019-06-29 21:10:08 +03:00
|
|
|
"coverage001", "coverage002", "coverage003", "coverage004",
|
2019-06-25 23:46:28 +03:00
|
|
|
"error001", "error002", "error003", "error004", "error005",
|
2019-07-07 15:10:14 +03:00
|
|
|
"error006", "error007", "error008", "error009",
|
2019-06-30 14:49:11 +03:00
|
|
|
"import001", "import002",
|
2019-06-24 18:23:32 +03:00
|
|
|
"interactive001", "interactive002", "interactive003", "interactive004",
|
|
|
|
"interactive005", "interactive006", "interactive007", "interactive008",
|
|
|
|
"interactive009", "interactive010", "interactive011", "interactive012",
|
2019-06-24 20:04:43 +03:00
|
|
|
"interface001", "interface002", "interface003", "interface004",
|
|
|
|
"interface005",
|
2019-06-24 20:08:32 +03:00
|
|
|
"lazy001",
|
2019-06-27 21:28:14 +03:00
|
|
|
"linear001", "linear002", "linear003", "linear004", "linear005",
|
2019-06-29 23:37:30 +03:00
|
|
|
"perror001", "perror002", "perror003", "perror004", "perror005",
|
|
|
|
"perror006",
|
2019-06-24 20:14:07 +03:00
|
|
|
"record001", "record002",
|
2019-06-25 14:57:49 +03:00
|
|
|
"total001", "total002", "total003", "total004", "total005",
|
|
|
|
"total006"]
|
2019-06-09 13:58:29 +03:00
|
|
|
|
2019-06-30 17:50:58 +03:00
|
|
|
typeddTests : List String
|
|
|
|
typeddTests
|
2019-07-05 02:07:04 +03:00
|
|
|
= ["chapter01", "chapter02", "chapter03", "chapter04", "chapter05",
|
2019-07-09 00:46:20 +03:00
|
|
|
"chapter06", "chapter07", "chapter08", "chapter09", "chapter10",
|
|
|
|
"chapter11"]
|
2019-06-30 17:50:58 +03:00
|
|
|
|
2019-06-25 16:05:54 +03:00
|
|
|
chezTests : List String
|
|
|
|
chezTests
|
2019-06-29 23:32:19 +03:00
|
|
|
= ["chez001", "chez002", "chez003", "chez004",
|
2019-06-30 00:43:06 +03:00
|
|
|
"chez005", "chez006", "chez007"]
|
2019-06-25 16:05:54 +03:00
|
|
|
|
2019-05-07 12:42:45 +03:00
|
|
|
chdir : String -> IO Bool
|
|
|
|
chdir dir
|
|
|
|
= do ok <- foreign FFI_C "chdir" (String -> IO Int) dir
|
|
|
|
pure (ok == 0)
|
|
|
|
|
|
|
|
fail : String -> IO ()
|
|
|
|
fail err
|
|
|
|
= do putStrLn err
|
|
|
|
exitWith (ExitFailure 1)
|
|
|
|
|
|
|
|
runTest : String -> String -> String -> IO Bool
|
|
|
|
runTest dir prog test
|
|
|
|
= do chdir (dir ++ "/" ++ test)
|
|
|
|
putStr $ dir ++ "/" ++ test ++ ": "
|
|
|
|
system $ "sh ./run " ++ prog ++ " > output"
|
|
|
|
Right out <- readFile "output"
|
|
|
|
| Left err => do print err
|
|
|
|
pure False
|
|
|
|
Right exp <- readFile "expected"
|
|
|
|
| Left err => do print err
|
|
|
|
pure False
|
|
|
|
if (out == exp)
|
|
|
|
then putStrLn "success"
|
|
|
|
else putStrLn "FAILURE"
|
|
|
|
chdir "../.."
|
|
|
|
pure (out == exp)
|
|
|
|
|
2019-06-25 16:05:54 +03:00
|
|
|
exists : String -> IO Bool
|
|
|
|
exists f
|
|
|
|
= do Right ok <- openFile f Read
|
|
|
|
| Left err => pure False
|
|
|
|
closeFile ok
|
|
|
|
pure True
|
|
|
|
|
|
|
|
firstExists : List String -> IO (Maybe String)
|
|
|
|
firstExists [] = pure Nothing
|
|
|
|
firstExists (x :: xs) = if !(exists x) then pure (Just x) else firstExists xs
|
|
|
|
|
|
|
|
findChez : IO (Maybe String)
|
|
|
|
findChez
|
|
|
|
= firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
|
|
|
x <- ["scheme", "chez", "chezscheme9.5"]]
|
|
|
|
|
2019-05-07 12:42:45 +03:00
|
|
|
main : IO ()
|
|
|
|
main
|
2019-06-11 13:54:47 +03:00
|
|
|
= do [_, idris2] <- getArgs
|
2019-05-07 12:42:45 +03:00
|
|
|
| _ => do putStrLn "Usage: runtests [ttimp path]"
|
2019-06-11 13:54:47 +03:00
|
|
|
ttimps <- traverse (runTest "ttimp" idris2) ttimpTests
|
|
|
|
idrs <- traverse (runTest "idris2" idris2) idrisTests
|
2019-06-30 19:38:40 +03:00
|
|
|
typedds <- traverse (runTest "typedd-book" idris2) typeddTests
|
2019-06-25 16:05:54 +03:00
|
|
|
chexec <- findChez
|
|
|
|
chezs <- maybe (do putStrLn "Chez Scheme not found"
|
|
|
|
pure [])
|
|
|
|
(\c => do putStrLn $ "Found Chez Scheme at " ++ c
|
|
|
|
traverse (runTest "chez" idris2) chezTests)
|
|
|
|
chexec
|
2019-06-30 17:50:58 +03:00
|
|
|
let res = ttimps ++ typedds ++ idrs ++ chezs
|
2019-06-30 00:43:06 +03:00
|
|
|
putStrLn (show (length (filter id res)) ++ "/" ++ show (length res)
|
|
|
|
++ " tests successful")
|
2019-06-30 17:50:58 +03:00
|
|
|
if (any not res)
|
2019-05-07 12:42:45 +03:00
|
|
|
then exitWith (ExitFailure 1)
|
|
|
|
else exitWith ExitSuccess
|
|
|
|
|