2019-05-07 12:42:45 +03:00
|
|
|
module Main
|
|
|
|
|
|
|
|
import System
|
|
|
|
|
|
|
|
%default covering
|
|
|
|
|
|
|
|
ttimpTests : List String
|
2019-07-30 14:56:27 +03:00
|
|
|
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-10-15 22:52:44 +03:00
|
|
|
"with001", "with002" ]
|
2019-05-07 12:42:45 +03:00
|
|
|
|
2019-06-09 13:58:29 +03:00
|
|
|
idrisTests : List String
|
|
|
|
idrisTests
|
2020-02-09 20:05:22 +03:00
|
|
|
= -- Fundamental language feturea
|
|
|
|
["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-12 10:32:36 +03:00
|
|
|
"basic021", "basic022", "basic023", "basic024", "basic025",
|
2020-01-11 20:27:27 +03:00
|
|
|
"basic026", "basic027", "basic028", "basic029", "basic030",
|
2020-02-11 20:24:03 +03:00
|
|
|
"basic031", "basic032", "basic033", "basic034", "basic035",
|
2020-02-25 17:07:44 +03:00
|
|
|
"basic036",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Coverage checking
|
2019-06-29 21:10:08 +03:00
|
|
|
"coverage001", "coverage002", "coverage003", "coverage004",
|
2020-02-24 00:40:23 +03:00
|
|
|
"coverage005",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Error messages
|
2019-06-25 23:46:28 +03:00
|
|
|
"error001", "error002", "error003", "error004", "error005",
|
2019-07-28 23:04:55 +03:00
|
|
|
"error006", "error007", "error008", "error009", "error010",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Modules and imports
|
2019-09-07 16:54:29 +03:00
|
|
|
"import001", "import002", "import003", "import004",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Interactive editing support
|
2019-06-24 18:23:32 +03:00
|
|
|
"interactive001", "interactive002", "interactive003", "interactive004",
|
|
|
|
"interactive005", "interactive006", "interactive007", "interactive008",
|
|
|
|
"interactive009", "interactive010", "interactive011", "interactive012",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Interfaces
|
2019-06-24 20:04:43 +03:00
|
|
|
"interface001", "interface002", "interface003", "interface004",
|
2019-07-22 18:21:33 +03:00
|
|
|
"interface005", "interface006", "interface007", "interface008",
|
2019-07-27 19:01:02 +03:00
|
|
|
"interface009", "interface010", "interface011", "interface012",
|
2020-02-23 20:30:48 +03:00
|
|
|
"interface013", "interface014", "interface015",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Miscellaneous REPL
|
2019-12-22 23:47:25 +03:00
|
|
|
"interpreter001",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Implicit laziness, lazy evaluation
|
2019-06-24 20:08:32 +03:00
|
|
|
"lazy001",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- QTT and linearity related
|
2019-06-27 21:28:14 +03:00
|
|
|
"linear001", "linear002", "linear003", "linear004", "linear005",
|
2020-02-13 21:24:12 +03:00
|
|
|
"linear006", "linear007", "linear008",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Parameters blocks
|
2019-10-25 16:03:15 +03:00
|
|
|
"params001",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Performance: things which have been slow in the past, or which
|
|
|
|
-- pose interesting challenges for the elaborator
|
2019-12-07 21:54:02 +03:00
|
|
|
"perf001", "perf002", "perf003",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Parse errors
|
2019-06-29 23:37:30 +03:00
|
|
|
"perror001", "perror002", "perror003", "perror004", "perror005",
|
|
|
|
"perror006",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Packages and ipkg files
|
2020-02-23 02:25:02 +03:00
|
|
|
"pkg001", "pkg002",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Larger programs arising from real usage. Typically things with
|
|
|
|
-- interesting interactions between features
|
2020-02-16 19:33:17 +03:00
|
|
|
"real001", "real002",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Records, access and dependent update
|
2019-06-24 20:14:07 +03:00
|
|
|
"record001", "record002",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Miscellaneous regressions
|
2020-02-23 18:58:14 +03:00
|
|
|
"reg001", "reg002", "reg003", "reg004", "reg005",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- Totality checking
|
2019-06-25 14:57:49 +03:00
|
|
|
"total001", "total002", "total003", "total004", "total005",
|
2019-07-30 14:32:33 +03:00
|
|
|
"total006",
|
2020-02-09 20:05:22 +03:00
|
|
|
-- The 'with' rule
|
2019-07-30 14:32:33 +03:00
|
|
|
"with001"]
|
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",
|
2019-07-10 21:22:00 +03:00
|
|
|
"chapter11", "chapter12"]
|
2019-06-30 17:50:58 +03:00
|
|
|
|
2019-06-25 16:05:54 +03:00
|
|
|
chezTests : List String
|
|
|
|
chezTests
|
2019-10-15 22:52:44 +03:00
|
|
|
= ["chez001", "chez002", "chez003", "chez004", "chez005", "chez006",
|
2020-01-30 20:04:33 +03:00
|
|
|
"chez007", "chez008", "chez009", "chez010", "chez011", "chez012"]
|
2019-06-25 16:05:54 +03:00
|
|
|
|
2019-08-28 09:40:00 +03:00
|
|
|
ideModeTests : List String
|
|
|
|
ideModeTests
|
2019-09-13 18:33:14 +03:00
|
|
|
= [ "ideMode001", "ideMode002" ]
|
2019-08-28 09:40:00 +03:00
|
|
|
|
2019-05-07 12:42:45 +03:00
|
|
|
chdir : String -> IO Bool
|
2019-07-30 14:56:27 +03:00
|
|
|
chdir dir
|
2019-05-07 12:42:45 +03:00
|
|
|
= do ok <- foreign FFI_C "chdir" (String -> IO Int) dir
|
|
|
|
pure (ok == 0)
|
|
|
|
|
|
|
|
fail : String -> IO ()
|
2019-07-30 14:56:27 +03:00
|
|
|
fail err
|
2019-05-07 12:42:45 +03:00
|
|
|
= do putStrLn err
|
|
|
|
exitWith (ExitFailure 1)
|
|
|
|
|
2019-07-28 19:27:51 +03:00
|
|
|
runTest : String -> String -> IO Bool
|
|
|
|
runTest prog testPath
|
|
|
|
= do chdir testPath
|
2019-09-06 21:44:33 +03:00
|
|
|
isSuccess <- runTest'
|
2019-05-07 12:42:45 +03:00
|
|
|
chdir "../.."
|
2019-09-06 21:44:33 +03:00
|
|
|
pure isSuccess
|
|
|
|
where
|
|
|
|
runTest' : IO Bool
|
|
|
|
runTest'
|
|
|
|
= do putStr $ testPath ++ ": "
|
|
|
|
system $ "sh ./run " ++ prog ++ " | tr -d '\\r' > 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 do
|
|
|
|
putStrLn "FAILURE"
|
|
|
|
putStrLn "Expected:"
|
|
|
|
printLn exp
|
|
|
|
putStrLn "Given:"
|
|
|
|
printLn out
|
|
|
|
|
|
|
|
pure (out == exp)
|
2019-05-07 12:42:45 +03:00
|
|
|
|
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
|
2019-07-10 01:45:33 +03:00
|
|
|
= do env <- getEnv "CHEZ"
|
|
|
|
case env of
|
|
|
|
Just n => pure $ Just n
|
|
|
|
Nothing => firstExists [p ++ x | p <- ["/usr/bin/", "/usr/local/bin/"],
|
2019-12-21 16:12:09 +03:00
|
|
|
x <- ["chez", "chezscheme9.5", "scheme"]]
|
2019-06-25 16:05:54 +03:00
|
|
|
|
2019-07-28 19:27:51 +03:00
|
|
|
runChezTests : String -> List String -> IO (List Bool)
|
|
|
|
runChezTests prog tests
|
|
|
|
= do chexec <- findChez
|
|
|
|
maybe (do putStrLn "Chez Scheme not found"
|
|
|
|
pure [])
|
|
|
|
(\c => do putStrLn $ "Found Chez Scheme at " ++ c
|
|
|
|
traverse (runTest prog) tests)
|
|
|
|
chexec
|
|
|
|
|
2019-05-07 12:42:45 +03:00
|
|
|
main : IO ()
|
|
|
|
main
|
2019-07-28 19:27:51 +03:00
|
|
|
= do args <- getArgs
|
|
|
|
let (_ :: idris2 :: _) = args
|
|
|
|
| _ => do putStrLn "Usage: runtests <idris2 path> [--only <name>]"
|
|
|
|
let filterTests = case drop 2 args of
|
|
|
|
("--only" :: onlyName :: _) => filter (\testName => isInfixOf onlyName testName)
|
|
|
|
_ => id
|
|
|
|
let filteredNonCGTests =
|
|
|
|
filterTests $ concat [testPaths "ttimp" ttimpTests,
|
|
|
|
testPaths "idris2" idrisTests,
|
2019-08-28 09:40:00 +03:00
|
|
|
testPaths "typedd-book" typeddTests,
|
|
|
|
testPaths "ideMode" ideModeTests]
|
2019-07-28 19:27:51 +03:00
|
|
|
let filteredChezTests = filterTests (testPaths "chez" chezTests)
|
|
|
|
nonCGTestRes <- traverse (runTest idris2) filteredNonCGTests
|
|
|
|
chezTestRes <- if length filteredChezTests > 0
|
|
|
|
then runChezTests idris2 filteredChezTests
|
|
|
|
else pure []
|
|
|
|
let res = nonCGTestRes ++ chezTestRes
|
2019-07-30 14:56:27 +03:00
|
|
|
putStrLn (show (length (filter id res)) ++ "/" ++ show (length res)
|
2019-06-30 00:43:06 +03:00
|
|
|
++ " 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
|
2019-07-28 19:27:51 +03:00
|
|
|
where
|
|
|
|
testPaths : String -> List String -> List String
|
|
|
|
testPaths dir tests = map (\test => dir ++ "/" ++ test) tests
|