-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be able to run TUI applications with "stack test" #5916
Conversation
@thomasjm, many thanks! One thing on my mind is: in introducing this new functionality, is the existing functionality affected in any way? I don't have much time to work through that myself at present. Is that something you could address expressly in your testing, and document here? (I see the CI has green ticks, which is a start.) On the linting fail, HLint's suggestion (in the CI logs) seems to me to be a good one. Please can you adopt it. |
That's the question... the new behavior is only used a) when run in a terminal, and I think that limits the potential regressions reasonably well--normal builds and things being run in CI shouldn't be affected, for example. I just ran some tests with both versions and compared them side-by-side and they look identical to me. I guess some questions remain:
|
@thomasjm, I am still working through this. If I understand correctly, I am not sure you need, or want, Again, if I understand correctly, the main 'point of departure' is that this assumes that if we are in a terminal, the user wants, simply: runProcess :: MonadIO m => ProcessConfig stdin stdout stderr -> m ExitCode and not the existing manipulation of the
If that is correct, is the major difference the treatment of the standard input? Seeking to understand the existing I understand that If that is the case, it might be better to have an express flag - I am wondering if the heart of this is as follows: if you are in a terminal, you are not |
By way of exploring my idea above, I took the current Stack let pc = setStdout output
$ setStderr output
pc0 I'm testing with a simple adaptation of the test executable in main :: IO ()
main = do
putStrLn "Input a line"
line <- getLine
putStrLn $ "Test suite not yet implemented: " <> line and, with the simple removal, So, I am wondering if the solution is just a simple flag added to |
@thomasjm, I've implemented my idea at #5916 (comment) above in the The key part of my code is this extract, especially the line mec <- withWorkingDir (toFilePath pkgDir) $
optionalTimeout $ proc (toFilePath exePath) args $ \pc0 -> do
changeStdin <-
if isTestTypeLib
then do
logPath <- buildLogPath package (Just stestName)
ensureDir (parent logPath)
pure $ setStdin
$ byteStringInput
$ BL.fromStrict
$ encodeUtf8 $ fromString $
show (logPath, mkUnqualComponentName (T.unpack testName))
else do
isTerminal <- view $ globalOptsL.to globalTerminal
if toAllowStdin topts && isTerminal
then pure id
else pure $ setStdin $ byteStringInput mempty
let pc = changeStdin
$ setStdout output
$ setStderr output
pc0 ( What do you think? That seems to me more straight-forward than introducing additional data constructors of the |
Hey, sorry for the delay, and thanks for looking into this! It's a good catch that what we want to do can be enabled just by leaving Also a good catch that Cabal already defines certain test suite interfaces, and that interactive TTY apps aren't conformant with the My original plan was to open a PR against Cabal after the Stack one is done, since I'm primarily a Stack user. But your findings make me think I should have done Cabal first :). What should probably happen is I make a proposal for a new test suite interface for Cabal, called However, who knows how long it will take for such a thing to land in Cabal, so it would be nice to land this in Stack in the meantime. The Cabal part might be an uphill struggle--for example, I notice that Regarding your solution:
What do you think? |
Opened an RFC on Cabal: haskell/cabal#8604 |
@thomasjm, I have changed the name of the flag to I have created a new pull request #5951 to give effect to the above. |
@thomasjm, having tested it, I think the current |
Hi @mpilgrem -- I have something I'm starting to feel good about for #5897!
This PR shows my latest and best approach. There is no longer a command-line flag; instead we just test whether
stack test
is being run inside a terminal using the existinghIsTerminalDeviceOrMinTTY
function. If so, then we launch the test process using a simpleproc
function rather than the traditional ways which captures stdout/stderr; see here.I've tested this by installing it on my machine and running (in the sandwich repo):
stack test demo-stack-test --test-arguments --tui