Update opam dependencies (#626)

This commit is contained in:
Louis Gesbert 2024-06-27 14:24:21 +02:00 committed by GitHub
commit 69d8f433e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 70 additions and 66 deletions

View File

@ -112,7 +112,7 @@ jobs:
- name: Install LaTeX deps
# This is done late because caching would not benefit compared to
# installation through apk (1,5G upload is slow)
run: sudo apk add texlive-xetex texmf-dist-latexextra texmf-dist-pictures font-dejavu groff
run: sudo apk add texlive-xetex texmf-dist-latexextra texmf-dist-binextra texmf-dist-pictures font-dejavu groff
- name: Build Catala extra docs
run: |
cd ~/catala

View File

@ -2,7 +2,7 @@
# STAGE 1: setup an opam switch with all dependencies installed
#
# (only depends on the opam files)
FROM ocamlpro/ocaml:4.14-2024-01-14 AS dev-build-context
FROM ocamlpro/ocaml:4.14-2024-05-26 AS dev-build-context
# Image from https://hub.docker.com/r/ocamlpro/ocaml
RUN mkdir catala
@ -25,10 +25,6 @@ RUN opam --cli=2.1 switch create catala ocaml-system && \
# Note: just `opam switch create . --deps-only --with-test --with-doc && opam clean`
# should be enough once opam 2.2 is released (see opam#5185)
# This is temporary, to avoid pulling in a dependency to Str, until it's merged
# and release into dates_calc
RUN opam --cli=2.1 pin dates_calc.0.0.5 git+https://github.com/AltGr/dates-calc#nostr
#
# STAGE 2: get the whole repo and build
#

View File

@ -99,14 +99,13 @@ prepare-install:
dune build @install --promote-install-files
install: prepare-install
if [ x$$($(OPAM) --version) = "x2.1.5" ]; then \
$(OPAM) install . --working-dir; \
else \
$(OPAM) install . --working-dir --assume-built; \
fi
case x$$($(OPAM) --version) in \
x2.1.5|x2.1.6) $(OPAM) install . --working-dir;; \
*) $(OPAM) install . --working-dir --assume-built;; \
esac
# `dune install` would work, but does a dirty install to the opam prefix without
# registering with opam.
# --assume-built is broken in 2.1.5
# --assume-built is broken in 2.1.5 and 2.1.6
inst: prepare-install
@opam custom-install \

View File

@ -226,15 +226,18 @@ module Cli = struct
~doc:"Display the full list of tests that have been run" );
])
let use_patdiff =
let diff_command =
Arg.(
value
& flag
& info ["patdiff"]
~env:(Cmd.Env.info "CATALA_USE_PATDIFF")
& opt ~vopt:(Some None) (some (some string)) None
& info ["diff"]
~env:(Cmd.Env.info "CATALA_DIFF_COMMAND")
~doc:
"Enable use of the 'patdiff' command for showing test failure \
details (no effect if the command is not available)")
"Use a standard $(i,diff) command instead of the default \
side-by-side view. If no argument is supplied, the command will \
be $(b,patdiff) if available or $(b,diff) otherwise. A supplied \
argument will be used as diff command with arguments pointing to \
the reference file and the output file")
let ninja_flags =
let env =
@ -915,10 +918,10 @@ let test_cmd =
(reset_test_outputs : bool)
(test_flags : string list)
verbosity
(use_patdiff : bool)
(diff_command : string option option)
(ninja_flags : string list) =
set_report_verbosity verbosity;
Clerk_report.set_display_flags ~use_patdiff ();
Clerk_report.set_display_flags ~diff_command ();
ninja_init ~extra:Seq.empty ~test_flags
@@ fun build_dir nin_file ->
let targets =
@ -988,7 +991,7 @@ let test_cmd =
$ Cli.reset_test_outputs
$ Cli.test_flags
$ Cli.report_verbosity
$ Cli.use_patdiff
$ Cli.diff_command
$ Cli.ninja_flags)
let run_cmd =
@ -1051,11 +1054,11 @@ let runtest_cmd =
$ Cli.single_file)
let report_cmd =
let run color debug verbosity use_patdiff build_dir file =
let run color debug verbosity diff_command build_dir file =
let _options = Catala_utils.Global.enforce_options ~debug ~color () in
let build_dir = Option.value ~default:"_build" build_dir in
set_report_verbosity verbosity;
Clerk_report.set_display_flags ~use_patdiff ();
Clerk_report.set_display_flags ~diff_command ();
let open Clerk_report in
let tests = read_many file in
let success = summary ~build_dir tests in
@ -1071,7 +1074,7 @@ let report_cmd =
$ Cli.Global.color
$ Cli.Global.debug
$ Cli.report_verbosity
$ Cli.use_patdiff
$ Cli.diff_command
$ Cli.build_dir
$ Cli.single_file)

View File

@ -33,22 +33,22 @@ type disp_flags = {
mutable files : [ `All | `Failed | `None ];
mutable tests : [ `All | `FailedFile | `Failed | `None ];
mutable diffs : bool;
mutable use_patdiff : bool;
mutable diff_command : string option option;
}
let disp_flags =
{ files = `Failed; tests = `FailedFile; diffs = true; use_patdiff = false }
{ files = `Failed; tests = `FailedFile; diffs = true; diff_command = None }
let set_display_flags
?(files = disp_flags.files)
?(tests = disp_flags.tests)
?(diffs = disp_flags.diffs)
?(use_patdiff = disp_flags.use_patdiff)
?(diff_command = disp_flags.diff_command)
() =
disp_flags.files <- files;
disp_flags.tests <- tests;
disp_flags.diffs <- diffs;
disp_flags.use_patdiff <- use_patdiff
disp_flags.diff_command <- diff_command
let write_to f file =
File.with_out_channel f (fun oc -> Marshal.to_channel oc (file : file) [])
@ -81,20 +81,14 @@ let longuest_common_prefix_length s1 s2 =
aux 0
let diff_command =
let has_gnu_diff () =
File.process_out ~check_exit:ignore "diff" ["--version"]
|> Re.(execp (compile (str "GNU")))
in
lazy
begin
if
disp_flags.use_patdiff
&& has_command "patdiff"
&& Message.has_color stdout
then
( ["patdiff"; "-alt-old"; "expected"; "-alt-new"; "result"],
fun ppf s ->
s
|> String.split_on_char '\n'
|> List.filter (( <> ) "")
|> Format.pp_print_list Format.pp_print_string ppf )
else
match disp_flags.diff_command with
| None when Message.has_color stdout && has_gnu_diff () ->
let width = Message.terminal_columns () - 5 in
( [
"diff";
@ -147,6 +141,21 @@ let diff_command =
(String.sub r w (String.length r - w))
| _ -> Format.pp_print_string ppf li))
ppf )
| Some cmd_opt | (None as cmd_opt) ->
let command =
match cmd_opt with
| Some str -> String.split_on_char ' ' str
| None ->
if Message.has_color stdout && has_command "patdiff" then
["patdiff"; "-alt-old"; "Reference"; "-alt-new"; "Result"]
else ["diff"; "-u"; "-L"; "Reference"; "-L"; "Result"]
in
( command,
fun ppf s ->
s
|> String.trim_end
|> String.split_on_char '\n'
|> Format.pp_print_list Format.pp_print_string ppf )
end
let print_diff ppf p1 p2 =

View File

@ -43,6 +43,6 @@ val set_display_flags :
?files:[ `All | `Failed | `None ] ->
?tests:[ `All | `FailedFile | `Failed | `None ] ->
?diffs:bool ->
?use_patdiff:bool ->
?diff_command:string option option ->
unit ->
unit

View File

@ -22,7 +22,7 @@ depends: [
"bindlib" {>= "6.0"}
"cmdliner" {>= "1.1.0"}
"cppo" {>= "1"}
"dates_calc" {>= "0.0.4"}
"dates_calc" {>= "0.0.6"}
"dune" {>= "3.11"}
"js_of_ocaml-ppx" {= "4.1.0"}
"menhir" {>= "20200211"}
@ -31,7 +31,7 @@ depends: [
"ocamlfind" {!= "1.9.5"}
"ocamlgraph" {>= "1.8.8"}
"re" {>= "1.10"}
"sedlex" {>= "2.4"}
"sedlex" {>= "3.1"}
"uutf" {>= "1.0.3"}
"ubase" {>= "0.05"}
"unionFind" {>= "20220109"}
@ -47,7 +47,6 @@ depends: [
"conf-npm" {cataladevmode}
"conf-python-3-dev" {cataladevmode}
"cpdf" {cataladevmode}
"conf-diffutils" {cataladevmode}
"conf-pandoc" {cataladevmode}
"z3" {catalaz3mode}
"conf-ninja"

View File

@ -185,21 +185,24 @@ let process_out ?check_exit cmd args =
let () =
let default = 80 in
let get_terminal_cols () =
let from_env () =
try int_of_string (Sys.getenv "COLUMNS") with Not_found | Failure _ -> 0
in
let count =
try
(* terminfo *)
process_out "tput" ["cols"] |> String.trim |> int_of_string
with Failure _ -> (
if not Unix.(isatty stdin) then from_env ()
else
try
(* stty *)
process_out "stty" ["size"]
|> String.trim
|> fun s ->
let i = String.rindex s ' ' + 1 in
String.sub s i (String.length s - i) |> int_of_string
with Failure _ | Not_found | Invalid_argument _ -> (
try int_of_string (Sys.getenv "COLUMNS")
with Not_found | Failure _ -> 0))
(* terminfo *)
process_out "tput" ["cols"] |> String.trim |> int_of_string
with Failure _ -> (
try
(* stty *)
process_out "stty" ["size"]
|> String.trim
|> fun s ->
let i = String.rindex s ' ' + 1 in
String.sub s i (String.length s - i) |> int_of_string
with Failure _ | Not_found | Invalid_argument _ -> from_env ())
in
if count > 0 then count else default
in

View File

@ -778,9 +778,6 @@ let lex_raw (lexbuf : lexbuf) : token =
| _ -> (
(* Nested match for lower priority; `_` matches length 0 so we effectively retry the
sub-match at the same point *)
let lexbuf = lexbuf in
(* workaround sedlex bug, see https://github.com/ocaml-community/sedlex/issues/12
(fixed in 3.1) *)
match%sedlex lexbuf with
| Star (Compl '\n'), ('\n' | eof) -> LAW_TEXT (Utf8.lexeme lexbuf)
| _ -> L.raise_lexer_error (Pos.from_lpos prev_pos) prev_lexeme)
@ -817,9 +814,6 @@ let lex_law (lexbuf : lexbuf) : token =
| _ -> (
(* Nested match for lower priority; `_` matches length 0 so we effectively retry the
sub-match at the same point *)
let lexbuf = lexbuf in
(* workaround sedlex bug, see https://github.com/ocaml-community/sedlex/issues/12
(fixed in 3.1) *)
match%sedlex lexbuf with
| Star (Compl '\n'), ('\n' | eof) -> LAW_TEXT (Utf8.lexeme lexbuf)
| _ -> L.raise_lexer_error (Pos.from_lpos prev_pos) prev_lexeme)

View File

@ -3,7 +3,7 @@ name = "catala-runtime"
description = "Runtime libraries needed to execute Catala programs compiled to Python"
version = "0.10.0"
dependencies = [
"gmpy2",
"gmpy2 ~= 2.2.0rc1",
"typing",
"mypy",
"python-dateutil",

View File

@ -1,6 +1,6 @@
> Module Test_grave_char_en
## Law text should be able to contain grave accent '`'.
## Law text should be able to contain backquote chars `` ` ``.
This is a block of law text containing `.
This allows to:
@ -60,7 +60,8 @@ $ catala latex
\textbf{This defines the catala module \texttt{Test\_grave\_char\_en}}
\subsection{Law text should be able to contain grave accent ``'.}
\subsection{Law text should be able to contain backquote chars
\texttt{\textasciigrave{}}.}
This is a block of law text containing `. This allows to: