1
1
{-# LANGUAGE OverloadedStrings #-}
2
- -- Usage:
3
- -- ghc ../examples/Test.hs
4
- -- ghc Unit.hs
5
- -- ./Unit ../examples/Test
6
2
-- Requirements:
7
3
-- - Empty ~/.haskeline (or set to defaults)
8
- -- - Assumes the dummy folder is in the current folder
9
- -- - On Mac OS X, may need to clear out /usr/lib/charset.alias
10
- -- (In particular, the line "* UTF-8" which makes locale_charset()
11
- -- always return UTF-8; otherwise we can't test latin-1.)
4
+ -- - On Mac OS X, the "dumb term" test may fail.
5
+ -- In particular, the line "* UTF-8" which makes locale_charset()
6
+ -- always return UTF-8; otherwise we can't test latin-1.
12
7
-- - NB: Window size isn't provided by screen so it's picked up from
13
8
-- terminfo or defaults (either way: 80x24), rather than the user's
14
9
-- terminal.
15
10
module Main where
16
11
17
- import System.Environment
18
- import Test.HUnit
12
+ import Control.Monad (when )
19
13
import qualified Data.ByteString as B
20
14
import qualified Data.ByteString.Char8 as BC
21
15
import Data.Word
22
16
import qualified Data.Text as T
23
17
import qualified Data.Text.Encoding as E
24
18
import Data.Monoid ((<>) )
19
+ import System.Exit (exitFailure )
20
+ import System.Process (readProcess )
21
+ import Test.HUnit
25
22
26
23
import RunTTY
27
24
@@ -37,18 +34,19 @@ legacyEncoding = False
37
34
whenLegacy :: BC. ByteString -> BC. ByteString
38
35
whenLegacy s = if legacyEncoding then s else B. empty
39
36
40
- main :: IO Counts
37
+ main :: IO ()
41
38
main = do
42
- [p] <- getArgs
39
+ -- forkProcess needs an absolute path to the binary.
40
+ p <- head . lines <$> readProcess " which" [" haskeline-examples-Test" ] " "
43
41
let i = setTerm " xterm"
44
42
Invocation {
45
43
prog = p,
46
44
progArgs = [] ,
47
45
runInTTY = True ,
48
46
environment = []
49
47
}
50
- runTestTT $ test [interactionTests i, fileStyleTests i]
51
-
48
+ result <- runTestTT $ test [interactionTests i, fileStyleTests i]
49
+ when (errors result > 0 || failures result > 0 ) exitFailure
52
50
53
51
interactionTests :: Invocation -> Test
54
52
interactionTests i = " interaction" ~: test
@@ -113,10 +111,10 @@ unicodeMovement i = "Unicode movement" ~:
113
111
114
112
tabCompletion :: Invocation -> Test
115
113
tabCompletion i = " tab completion" ~:
116
- [ utf8Test i [ utf8 " dummy-μ\t\t " ]
117
- [ prompt 0 , utf8 " dummy-μασ/"
118
- <> nl <> utf8 " bar ςερτ " <> nl
119
- <> prompt' 0 <> utf8 " dummy-μασ/"
114
+ [ utf8Test i [ utf8 " tests/ dummy-μ\t\t " ]
115
+ [ prompt 0 , utf8 " tests/ dummy-μασ/"
116
+ <> nl <> utf8 " ςερτ bar " <> nl
117
+ <> prompt' 0 <> utf8 " tests/ dummy-μασ/"
120
118
]
121
119
]
122
120
0 commit comments