This is what I was getting at with the question in my last mail about
needing zpty for parallel runs on other platforms. Does this only affect
W01 tests? You need at least two processes to fight over the terminal to
get issues. Or is W01 the only one affected because it does more than
just write text?
There is only W01history.ztst that writes directly to the terminal. When tests are run in sequence, that's not really a problem. The tty output will always show up between the start line `W01history.ztst: starting.` and the end line `W01history.ztst: all tests successful.`. It's just a little ugly. When run in parallel, then it competes for the tty with `runtests.zsh`, which is the script that runs the tests in parallel.
> And since the whole point is to avoid garbled output when tests are run in
> parallel, it's not useful.
If you don't want garbled output, use gmake's --output-sync / -O
That doesn't help because the parallel execution isn't performed by `make` but by `runtests.zsh`. The role of `runtests.zsh` is to run all the requested tests, collect the failing ones and print the test summary. The execution of each test is delegated to `ztst.zsh`, which is run in a subshell. The start and end lines mentioned above are printed by `ztst.zsh`.
In sequential mode, `runtests.zsh` invokes `ztst.zsh` once for each test in a loop and lets each `ztst.zsh` write directly to the tty.
In parallel mode, `runtests.zsh` forks `ztst.zsh` once for each test. The stdout and stderr of each `ztst.zsh` is redirected into a file, which `runtests.zsh` writes to the tty as soon as the `ztst.zsh` terminates. This writing competes for the tty with any direct tty writing done by a test. To avoid that competition, `runtests.zsh` must also redirect (or supress) any direct tty output of each `ztst.zsh`.
> I will try to come up with something that uses `script` if it's present (and
> from a known platform), otherwise uses `zpty` if the module is available, and
> otherwise runs the tests without muting the tty.
I don't see the point in trying to use script instead of zpty,
especially if GNU specific options are needed. Better to be dogfooding
zpty in our tests. Maybe only if zpty is not available. Incidentally,
after checking a few platforms, Haiku OS also lacks the flusho stty
support and it appears to not have a script command either.
OK, I will go zpty first.
In cases where it is not running tests in parallel, it might drop the
need for a pseudo tty and use the stty solution to avoid the noise.
It should also be very easy to disable the pty temporarily by just
commenting out a line or two.
For sure there should be a way to see the tty output. One way would be to always record it in a file (e.g., W01history.tty.log). This would have the advantage that sequential and parallel runs produce the same output and there is no need to implement and document a flag/parameter/… to enable/disable tty muting (and the log file can be documented where mutetty is documented).
Renaming files with @mutetty suffixes seems a bit ugly. We've got
%prep/%test/%clean sections in the test file. How about checking for
%mutetty in the place where those are handled?
I used the filename trick because `runtests.zsh` never opens the test file but I agree that it's not great. Checking for a `%mutetty` (or rather a more general `%attr mutetty`) should be trivial. I will try that.
Philippe