Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Always "dumb" down the terminal
More tests were failing because of the difference between high-color terminal
escape sequences. I think a less colorful terminal is almost always what we
want which makes the tests between us and the CI more reliable.
  • Loading branch information
romanofski committed Jun 30, 2018
1 parent 4abdc0a commit 574ab55
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/TestUserAcceptance.hs
Expand Up @@ -94,10 +94,6 @@ testCanJumpToFirstListItem = withTmuxSession "updates read state for mail and th
testUpdatesReadState :: Int -> TestTree
testUpdatesReadState = withTmuxSession "updates read state for mail and thread" $
\step -> do
-- Make the regex less color code dependent. This can happen if different
-- environments support more than 16 colours (e.g. background values > 37),
-- while our CI environment only supports 16 colours.
setEnvVarInSession "TERM" "ansi"
startApplication

liftIO $ step "navigate to thread mails"
Expand Down Expand Up @@ -512,6 +508,7 @@ setUp i desc = do
sessionName = intercalate "-" (sessionNamePrefix : show i : descWords)
descWords = words $ filter (\c -> isAscii c && (isAlphaNum c || c == ' ')) desc
setUpTmuxSession sessionName
prepareEnvironment sessionName
(testdir, maildir) <- setUpTempMaildir
setUpPurebredConfig testdir
pure $ Env testdir maildir sessionName
Expand Down Expand Up @@ -675,6 +672,18 @@ startApplication = do
communicateSessionArgs sessionName ("purebred --database " <> testmdir <> "\r") False
void $ waitForString "Purebred: Item" defaultCountdown


-- | Prepare the environment
-- Here we're setting up the environment to run in a more predictable fasion.
--
-- a) Make the regex less color code dependent by setting the TERM to 'ansi'.
-- This can happen if different environments support more than 16 colours (e.g.
-- background values > 37), while our CI environment only supports 16 colours.
prepareEnvironment :: String -> IO ()
prepareEnvironment sessionName =
liftIO $ callProcess "tmux" $
communicateSessionArgs sessionName "export TERM=ansi\r" False

-- | Sets a shell environment variable
-- Note: The tmux program provides a command to set environment variables for
-- running sessions, yet they seem to be not inherited by the shell.
Expand Down

0 comments on commit 574ab55

Please sign in to comment.