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
|
|
|
|
2014-08-15 02:08:44 +04:00
|
|
|
import Data.Default
|
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
import qualified System.Console.Terminfo as Terminfo
|
|
|
|
import System.Posix.Env
|
2014-08-15 02:08:44 +04:00
|
|
|
import System.Posix.IO
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2013-08-15 08:32:02 +04:00
|
|
|
tests :: IO [Test]
|
2014-04-12 04:51:13 +04:00
|
|
|
tests = concat <$> forM terminalsOfInterest (\termName -> do
|
2013-08-15 08:32:02 +04:00
|
|
|
-- check if that terminfo exists
|
2014-05-31 12:52:55 +04:00
|
|
|
-- putStrLn $ "testing end to end for terminal: " ++ termName
|
2014-04-12 04:51:13 +04:00
|
|
|
mti <- try $ Terminfo.setupTerm termName
|
2013-08-15 08:32:02 +04:00
|
|
|
case mti of
|
|
|
|
Left (_ :: SomeException) -> return []
|
2014-04-12 04:51:13 +04:00
|
|
|
Right _ -> return [ verify ("verify " ++ termName ++ " could output a picture")
|
|
|
|
(smokeTestTermNonMac termName)
|
2013-08-15 08:32:02 +04:00
|
|
|
]
|
|
|
|
)
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2014-04-12 04:51:13 +04:00
|
|
|
smokeTestTermNonMac :: String -> Image -> Property
|
|
|
|
smokeTestTermNonMac termName i = liftIOResult $ do
|
|
|
|
smokeTestTerm termName i
|
|
|
|
|
|
|
|
smokeTestTerm :: String -> Image -> IO Result
|
|
|
|
smokeTestTerm termName i = do
|
2014-08-15 02:08:44 +04:00
|
|
|
nullOut <- openFd "/dev/null" WriteOnly Nothing defaultFileFlags
|
|
|
|
t <- outputForConfig $ def { outputFd = Just nullOut, termName = Just termName }
|
2014-05-31 12:52:55 +04:00
|
|
|
-- putStrLn $ "context color count: " ++ show (contextColorCount t)
|
2014-04-12 04:51:13 +04:00
|
|
|
reserveDisplay t
|
|
|
|
dc <- displayContext t (100,100)
|
2013-08-15 08:32:02 +04:00
|
|
|
-- always show the cursor to produce tests for terminals with no cursor support.
|
2014-04-12 04:51:13 +04:00
|
|
|
let pic = (picForImage i) { picCursor = Cursor 0 0 }
|
|
|
|
outputPicture dc pic
|
|
|
|
setCursorPos t 0 0
|
|
|
|
when (supportsCursorVisibility t) $ do
|
|
|
|
hideCursor t
|
|
|
|
showCursor t
|
|
|
|
releaseDisplay t
|
|
|
|
releaseTerminal t
|
2014-08-15 02:08:44 +04:00
|
|
|
closeFd nullOut
|
2013-08-15 08:32:02 +04:00
|
|
|
return succeeded
|
2009-09-04 21:29:28 +04:00
|
|
|
|