2013-08-15 08:32:02 +04:00
|
|
|
{- We setup the environment to envoke certain terminals of interest.
|
|
|
|
- This assumes appropriate definitions exist in the current environment for the terminals of
|
|
|
|
- interest.
|
|
|
|
-}
|
2013-12-20 10:24:56 +04:00
|
|
|
module VerifyOutput where
|
2009-09-04 21:29:28 +04:00
|
|
|
import Verify
|
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
import Graphics.Vty
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
import Verify.Graphics.Vty.Image
|
2013-12-20 10:24:56 +04:00
|
|
|
import Verify.Graphics.Vty.Output
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
import Control.Monad
|
2013-07-22 12:11:50 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
import qualified System.Console.Terminfo as Terminfo
|
|
|
|
import System.Posix.Env
|
|
|
|
import System.IO
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
tests :: IO [Test]
|
|
|
|
tests = concat <$> forM terminals_of_interest (\term_name -> do
|
|
|
|
-- check if that terminfo exists
|
|
|
|
putStrLn $ "testing end to end for terminal: " ++ term_name
|
|
|
|
mti <- try $ Terminfo.setupTerm term_name
|
|
|
|
case mti of
|
|
|
|
Left (_ :: SomeException) -> return []
|
|
|
|
Right _ -> return [ verify ("verify " ++ term_name ++ " could output a picture")
|
|
|
|
(smoke_test_term_non_mac term_name)
|
|
|
|
-- this is excessive.
|
|
|
|
, verify ("verify " ++ term_name ++ " could output a picture on a Mac.")
|
|
|
|
(smoke_test_term_mac term_name)
|
|
|
|
]
|
|
|
|
)
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
smoke_test_term_non_mac :: String -> Image -> Property
|
|
|
|
smoke_test_term_non_mac term_name i = liftIOResult $ do
|
|
|
|
-- unset the TERM_PROGRAM environment variable if set.
|
|
|
|
-- Required to execute regression test for #42 on a mac
|
|
|
|
unsetEnv "TERM_PROGRAM"
|
|
|
|
smoke_test_term term_name i
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
smoke_test_term_mac :: String -> Image -> Property
|
|
|
|
smoke_test_term_mac term_name i = liftIOResult $ do
|
|
|
|
setEnv "TERM_PROGRAM" "Apple_Terminal" True
|
|
|
|
smoke_test_term term_name i
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
smoke_test_term :: String -> Image -> IO Result
|
|
|
|
smoke_test_term term_name i = do
|
|
|
|
null_out <- openFile "/dev/null" WriteMode
|
2013-12-22 04:02:51 +04:00
|
|
|
t <- output_for_name_and_io term_name null_out
|
2013-08-15 08:32:02 +04:00
|
|
|
putStrLn $ "context color count: " ++ show (context_color_count t)
|
|
|
|
reserve_display t
|
2013-12-20 10:24:56 +04:00
|
|
|
dc <- display_context t (100,100)
|
2013-08-15 08:32:02 +04:00
|
|
|
-- always show the cursor to produce tests for terminals with no cursor support.
|
|
|
|
let pic = (pic_for_image i) { pic_cursor = Cursor 0 0 }
|
2013-07-08 00:55:23 +04:00
|
|
|
output_picture dc pic
|
2013-08-15 08:32:02 +04:00
|
|
|
set_cursor_pos t 0 0
|
|
|
|
when (supports_cursor_visibility t) $ do
|
|
|
|
hide_cursor t
|
|
|
|
show_cursor t
|
|
|
|
release_display t
|
|
|
|
release_terminal t
|
|
|
|
return succeeded
|
2009-09-04 21:29:28 +04:00
|
|
|
|