Closed arbipher closed 4 months ago
Update: width adjusting works fine on my windows terminal (with ubuntu + fish) but not on the macos (with zsh).
Seconding this. Forcing truncating of the lines without any way to override is a bit of an anti-pattern.
I agree that truncation shouldn't be the default in cases where Alcotest can't successfully determine the terminal width. The fix would be to avoid setting a default here, and them plumb that through to the other pretty-printers in the file (which should then not truncate in the None
case). While we're at it, we could consider setting the margin on the Format.formatter
to match the one that's actually detected.
Regarding manually overriding the determined width, it's already possible (but annoying) to do this by building a different Platform
to sit underneath the Alcotest runner:
let () =
let module Platform (M : Alcotest_engine.Monad.S) = struct
include Alcotest.Unix (M)
let stdout_columns () =
match stdout_columns () with None -> Some 200 | Some _ as x -> x
end in
let module Runner = Alcotest_engine.Cli.Make (Platform) (Alcotest_engine.Monad.Identity) in
Runner.run __FILE__
[
( "foo",
[
Alcotest.test_case
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec \
urna nisi, mattis scelerisque nulla at, rutrum convallis ante. \
Vestibulum bibendum ex at purus gravida, ac pellentesque elit \
facilisis. Etiam lacinia eros fermentum lacinia ornare. \
Vestibulum facilisis mollis dolor ultrices lobortis. In a nisl id \
purus rutrum accumsan non ac ligula."
`Quick (fun () -> assert false);
] );
]
We could make it easier for the user to set a fixed terminal width by passing values down through the config, but it sounds like the real problem here is that the terminal width stubs don't work correctly on MacOS. In that case, we should fix that directly (or just use a library that does get the terminal width correctly on MacOS, e.g. here).
Yes. the direct reason is the stub doesn't work on MacOS and the design topic is to have a configurable value for width.
If you don't have a mac at hand, I could make the mac stub and send a PR.
Thanks for the hacking code snippet.
I was able to get onto MacOS for testing, but your review would still be appreciated on https://github.com/mirage/alcotest/pull/325 :-)
I see the fix is in v1.5. Thanks.
This phenomenon reappears if running with stanza defined in dune file.
It works fine if I build the test executable and run that file outside of dune.
λ make dtest
dune build src-test/dbmc/test_dbmc.exe
ln -s -f _build/default/src-test/dbmc/test_dbmc.exe dtest
./dtest
Testing `DBMC'.
This run has ID `PKOADIQD'.
[OK] dbmc/loop 0 dbmc/loop/bitsize.jay.
[OK] dbmc/loop 1 dbmc/loop/countdown_0.jil.
However, the width is still bound using dune
λ dune build @test_dbmc
Testing `DBMC'.
This run has ID `EIWJFY73'.
[OK] dbmc/loop 0 dbmc/loop/bitsize...
[OK] dbmc/loop 1 dbmc/loop/countdo...
I can build a clean and dedicated example if necessary.
The problem is that we're using stdout to get the dimensions of the terminal, but Dune buffers the output of Alcotest, so stdout doesn't match the terminal. Using /dev/tty
should work portably for unix-like systems. I'm working on and testing a fix.
There also need to be an override switch for reproducibility and Alcotest self tests, I'm thinking of adding a ALCOTEST_COLUMNS
env var, or maybe ALCOTEST_REPRODUCIBLE
that would encompass other (future?) settings?
I'm still experiencing this issue. I'm using macOS and the following setup:
Both in VSCode and a standard terminal emulator the output is truncated, e.g.,
You can set ALCOTEST_COLUMNS
.
Is it possible to set output width manually?
I searched the issues and found this c_stub, but I haven't figured out how to set it, or how I can set
dimension
.It will be convenient for people who have test cases with long names. Currently with the
...
it's hard to know which test cases are failed.