Terminal styling and layout widgets for OCaml (tables, trees, panels, colors)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cram: migrate tests to test/cram/ umbrella across the monorepo

Structural move per the new E521 rule and cram skill:

- Each package's cram tests now live under test/cram/, with shared
shell setup at test/cram/helpers.sh (auto-sourced by dune 3.21's
setup_scripts) and driver exes in test/cram/helpers/.
- Packages migrated: ocaml-git, ocaml-tty, ocaml-vlog, xdge,
ocaml-precommit, ocaml-publicsuffix, ocaml-requests, monopam, irmin.
- ocaml-tty's cram was actively broken; fixed and the driver rewritten
to use Tty.Progress.render.
- irmin: adds scrub_hash/scrub_time helper scripts for normalising
non-deterministic output (dune cram has no glob/regex matching).

+37 -52
+1 -1
dune-project
··· 1 - (lang dune 3.0) 1 + (lang dune 3.21) 2 2 3 3 (name tty) 4 4
+4
test/cram/dune
··· 1 + (cram 2 + (applies_to :whole_subtree) 3 + (deps helpers/dump_progress.exe) 4 + (setup_scripts helpers.sh))
+3
test/cram/helpers.sh
··· 1 + #!/bin/sh 2 + # Sourced before every cram test under test/cram/*.t/. 3 + export PATH="$PWD/../helpers:$PATH"
+19 -32
test/cram/helpers/dump_progress.ml
··· 1 - (* Test progress bar rendering via Format.str_formatter. *) 1 + (** Demonstrates Tty.Progress rendering via the functional core. 2 2 3 - let read_bar () = Format.flush_str_formatter () |> String.trim 3 + Simulates a 3-step job (parse three files) and prints the progress bar's 4 + visible state after each transition. Regressions in the progress renderer 5 + will fail this cram test. *) 4 6 5 - let run label f = 6 - f (); 7 - let output = read_bar () in 8 - Fmt.pr "--- %s ---\n" label; 9 - Fmt.pr " %s\n" output 7 + let cfg = Tty.Progress.config ~width:40 ~style:`Plain () 8 + 9 + let show label s = 10 + (* Rendered bars are padded with trailing spaces to terminal width; 11 + trim so cram diffs aren't whitespace-sensitive. *) 12 + let line = Tty.Progress.render ~frame:0 cfg s |> String.trim in 13 + Printf.printf "%s: %s\n" label line 10 14 11 15 let () = 12 - run "update" (fun () -> 13 - let bar = 14 - Tty.Progress.v ~ppf:Format.str_formatter ~width:50 ~enabled:true 15 - ~style:`Plain ~total:3 "work" 16 - in 17 - ignore (read_bar ()); 18 - Tty.Progress.update bar ~phase:"" ~msg:"first"; 19 - ignore (read_bar ()); 20 - Tty.Progress.update bar ~phase:"" ~msg:"second"; 21 - ignore (read_bar ()); 22 - Tty.Progress.update bar ~phase:"" ~msg:"third"; 23 - Tty.Progress.finish bar); 24 - 25 - run "tick" (fun () -> 26 - let bar = 27 - Tty.Progress.v ~ppf:Format.str_formatter ~width:50 ~enabled:true 28 - ~style:`Plain ~total:3 "work" 29 - in 30 - ignore (read_bar ()); 31 - Tty.Progress.tick bar; 32 - ignore (read_bar ()); 33 - Tty.Progress.tick bar; 34 - ignore (read_bar ()); 35 - Tty.Progress.tick bar; 36 - Tty.Progress.finish bar) 16 + let s = Tty.Progress.state ~total:3 "Processing" in 17 + show "initial" s; 18 + let s = Tty.Progress.incr s |> Tty.Progress.with_message "foo.ml" in 19 + show "after foo.ml" s; 20 + let s = Tty.Progress.incr s |> Tty.Progress.with_message "bar.ml" in 21 + show "after bar.ml" s; 22 + let s = Tty.Progress.incr s |> Tty.Progress.with_message "baz.ml" in 23 + show "after baz.ml" s
+3
test/cram/helpers/dune
··· 1 + (executable 2 + (name dump_progress) 3 + (libraries tty unix re))
+7 -11
test/cram/progress.t/run.t
··· 1 - Progress bar stays on a single line regardless of update pattern. 1 + Progress bar rendering shows percentage, counter, and current message 2 + at each step. This is the user-visible output during a 3-step job. 2 3 3 - $ ./dump_progress.exe 4 - --- update --- 5 - visible lines: 1 6 - [100%] 3/3 third 7 - --- tick --- 8 - visible lines: 1 9 - [100%] 3/3 work 10 - --- message+tick --- 11 - visible lines: 1 12 - [100%] 3/3 third 4 + $ dump_progress.exe 5 + initial: [ 0%] 0/3 Processing 6 + after foo.ml: [ 33%] 1/3 foo.ml 7 + after bar.ml: [ 66%] 2/3 bar.ml 8 + after baz.ml: [100%] 3/3 baz.ml
-8
test/dune
··· 19 19 (libraries tty unix)) 20 20 21 21 (executable 22 - (name dump_progress) 23 - (modules dump_progress) 24 - (libraries tty unix re)) 25 - 26 - (executable 27 22 (name check_width) 28 23 (modules check_width) 29 24 (libraries tty unix)) 30 - 31 - (cram 32 - (deps dump_progress.exe)) 33 25 34 26 (executable 35 27 (name minimal_progress)