sandwich icon indicating copy to clipboard operation
sandwich copied to clipboard

Cannot use TUI from stack test

Open pierre-thierry opened this issue 4 years ago • 1 comments

Into a brand new stack project, I changed test/Spec.hs into the following file:

module Main where

import           Test.Sandwich

basic :: TopSpec
basic = do
  describe "Test TUI" $ do
    it "displays" $ do
      True `shouldBe` True

main :: IO ()
main = runSandwichWithCommandLineArgs defaultOptions basic

Running stack test works as expected, but not with the TUI:

$ stack test --test-arguments --tui                                                                                                                                                   
foo> test (suite: foo-test, args: --tui)

Some formatters failed: '[getTerminalAttributes: illegal operation (Inappropriate ioctl for device)]'
1 runs succeeded out of 1 repeats

foo> Test suite foo-test passed

pierre-thierry avatar Aug 26 '21 08:08 pierre-thierry

Yes, this is a problem. This is why all the examples use "executables" rather than "tests" in their cabal file.

I was thinking about submitting a PR to Stack to provide a tty when doing stack test, when possible. I don't think it would make sense to do all the time since stack test is also used in non-interactive scenarios. But it would be nice to be able to use the normal "tests" target.

thomasjm avatar Aug 26 '21 09:08 thomasjm

This works out of the box now with Stack 2.9.3!

thomasjm avatar Jan 25 '23 18:01 thomasjm