-
Notifications
You must be signed in to change notification settings - Fork 2
/
runAllTests.hs
69 lines (54 loc) · 3.17 KB
/
runAllTests.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- Run all tests for the Haskell CnC Runtime System.
import System.Directory
import qualified Intel.Cnc
import qualified Intel.CncPure
import qualified Intel.CncUtil
import System.Cmd(system)
import System.Exit
import HSH
import Test.HUnit
import Data.String.Utils -- from MissingH package
main = do
cd <- getCurrentDirectory
putStrLn$ "Running Unit tests in directory: " ++ show cd
putStrLn$ "\n================================================================================"
putStrLn$ "Running "++ show (testCaseCount Intel.CncUtil.tests) ++" tests from Intel.CncUtil"
putStrLn$ "================================================================================\n"
code1 <- runTestTT Intel.CncUtil.tests
putStrLn$ "\n================================================================================"
putStrLn$ "Running "++ show (testCaseCount Intel.Cnc.tests) ++" tests from Intel.Cnc"
putStrLn$ "================================================================================\n"
code2 <- runTestTT Intel.Cnc.tests
putStrLn$ "\n================================================================================"
putStrLn$ "Running "++ show (testCaseCount Intel.CncPure.tests) ++" tests from Intel.CncPure"
putStrLn$ "================================================================================\n"
code3 <- runTestTT Intel.CncPure.tests
let problems = errors code1 + failures code1 +
errors code2 + failures code2 +
errors code3 + failures code3
putStrLn$ "\n================================================================================"
putStrLn$ "Finally running system tests in all configurations (example programs):"
putStrLn$ "================================================================================\n"
b1 <- doesFileExist "run_all_examples.sh"
if b1
then putStrLn "!!! run_all_examples.sh found in current directory, using that!\n\n"
else do [ver] <- run "ghc-pkg latest haskell-cnc"
dir <- run$ ("ghc-pkg field "++ver++" include-dirs ") -|- replace "include-dirs:" ""
putStrLn$ "Switching to directory: " ++ show (strip dir)
setCurrentDirectory (strip dir)
b2 <- doesFileExist "run_all_examples.sh"
if not b2
then error$ "Uh oh, the script run_all_examples.sh doesn't exist in this directory.\n"
-- " If cabal installed the package you may find it in your ~/.cabal/lib directory."
else return ()
-- I have problems with cabal sdist not preserving executable flags.
system "chmod +x ./runcnc"
system "chmod +x ./run_all_examples.sh"
system "chmod +x ./ntimes"
system "chmod +x ./ntimes_minmedmax"
code <- system "TRIALS=1 ./run_all_examples.sh"
let code = ExitSuccess
case (problems,code) of
(0, ExitSuccess) -> exitWith ExitSuccess
(n, ExitSuccess) -> do putStrLn$ "ERROR: "++ show n ++" failures in unit tests!"; exitWith (ExitFailure n)
(_, ExitFailure n) -> do putStrLn "ERROR: Example programs failed!\n"; exitWith (ExitFailure n)