-
Notifications
You must be signed in to change notification settings - Fork 843
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 allocate a TTY when running tests #5897
Comments
@thomasjm, thanks for raising this. It took me a little while to follow your examples: on Windows the
I'd run into this before: #5771. It was fixed with: apt install libtinfo-dev So, I can see and reproduce the problem. Once built,
but when Stack runs the same executable with
I'm going to see if I can find out where Stack runs the executable in its code. |
Some notes for myself:
|
Thanks for pointing me in the right direction @mpilgrem -- I was able to come up with a proof of concept! https://github.com/codedownio/stack/tree/test-tty If you install this version of stack test demo-stack-test --test-tty --test-arguments --tui |
@thomasjm, thanks and interesting. It will take me a little while to work my way through it. Is the key difference in the If it is, I am wondering if these parts of -- Output to the console if this is the last task, and the user
-- asked to build it specifically. When the action is a
-- 'ConcurrencyDisallowed' action (benchmarks), then we can also be
-- sure to have exclusive access to the console, so output is also
-- sent to the console in this case.
--
-- See the discussion on #426 for thoughts on sending output to the
-- console from concurrent tasks.
console =
(wanted &&
all (\(ActionId ident _) -> ident == taskProvides) (Set.toList acRemaining) &&
eeTotalWanted == 1
) || (acConcurrency == ConcurrencyDisallowed)
withOutputType pkgDir package inner
-- Not in interleaved mode. When building a single wanted package, dump
-- to the console with no prefix.
| console = inner $ OTConsole Nothing It seems to me that at the heart of what This is a link to the Stack issue mentioned in the comment: #426 |
@thomasjm, ignore my question above about the key difference being in the |
I'd say the key difference is invoking the test process with Everything else is plumbing to support this. When you start the test process via a shell, it creates a pseudo-terminal which allows the TUI stuff to work. A few thoughts about this solution:
On a UX note, I made this opt-in via the |
Fix #5897 Add `--[no-]tests-allow-stdin` flag to `stack test`
I'm the author of the Sandwich test framework. One of Sandwich's key features is the ability to present a TUI interface for your tests. I think TUI-based testing is really useful, because it gives you a nice interface to watch and inspect the way your tests run.
The problem is, the default
stack test
behavior doesn't support this, because it doesn't allocate a TTY for the tests. I have a couple demos to demonstrate this:Normal operation:
demo-basic
is an executableThis is the workaround we've used until now--rather than using a
test-suite
, we just make the tests anexecutable
and run them withstack run
.However, this has the downside that Stack builds all executables by default, so now library users have to build the tests even when they aren't planning on running them.
stack test
operation:demo-stack-test
is atest-suite
If you try to run a
test-suite
with the TUI, it errors out:stack test demo-stack-test --test-arguments --tui
Feature request
Thus, this is a feature request to modify how
stack test
works so it can use a TUI, similar tostack run
. I'm not sure this should happen all the time, maybe it should be controlled by a flag?I could take a stab at implementing this if I could get some guidance from a Stack dev.
The text was updated successfully, but these errors were encountered: