Clerk: fix options passed to catala in out-test mode

This commit is contained in:
Louis Gesbert 2024-02-09 10:47:30 +01:00
parent 12974b089f
commit 82fb66daef
5 changed files with 10 additions and 14 deletions

View File

@ -461,7 +461,6 @@ let base_bindings catala_exe catala_flags build_dir include_dirs =
Nj.binding Var.clerk_flags
("-e"
:: Var.(!catala_exe)
:: ("--build-dir=" ^ Var.(!builddir))
:: includes
@ List.map (fun f -> "--catala-opts=" ^ f) catala_flags);
Nj.binding Var.ocamlopt_exe ["ocamlopt"];
@ -498,7 +497,7 @@ let[@ocamlformat "disable"] static_base_rules =
Nj.rule "out-test"
~command: [
!catala_exe; !test_command; !catala_flags; !input;
!catala_exe; !test_command; "--plugin-dir="; "-o -"; !catala_flags; !input;
">"; !output; "2>&1";
"||"; "true";
]
@ -985,16 +984,15 @@ let run_cmd =
$ Cli.ninja_flags)
let runtest_cmd =
let run catala_exe catala_opts build_dir include_dirs file =
let run catala_exe catala_opts include_dirs file =
let catala_opts =
List.fold_left
(fun opts dir -> "-I" :: dir :: opts)
catala_opts include_dirs
in
let build_dir = Poll.build_dir ?dir:build_dir () in
Clerk_runtest.run_inline_tests
(Option.value ~default:"catala" catala_exe)
catala_opts build_dir file;
catala_opts file;
0
in
let doc =
@ -1006,7 +1004,6 @@ let runtest_cmd =
const run
$ Cli.catala_exe
$ Cli.catala_opts
$ Cli.build_dir
$ Cli.include_dirs
$ Cli.single_file)

View File

@ -16,7 +16,7 @@
open Catala_utils
let run_catala_test catala_exe catala_opts build_dir file program args oc =
let run_catala_test catala_exe catala_opts file program args oc =
let cmd_in_rd, cmd_in_wr = Unix.pipe () in
Unix.set_close_on_exec cmd_in_wr;
let command_oc = Unix.out_channel_of_descr cmd_in_wr in
@ -41,7 +41,6 @@ let run_catala_test catala_exe catala_opts build_dir file program args oc =
|> Seq.cons "CATALA_OUT=-"
(* |> Seq.cons "CATALA_COLOR=never" *)
|> Seq.cons "CATALA_PLUGINS="
|> Seq.cons ("CATALA_BUILD_DIR=" ^ build_dir)
|> Array.of_seq
in
flush oc;
@ -59,7 +58,7 @@ let run_catala_test catala_exe catala_opts build_dir file program args oc =
(** Directly runs the test (not using ninja, this will be called by ninja rules
through the "clerk runtest" command) *)
let run_inline_tests catala_exe catala_opts build_dir filename =
let run_inline_tests catala_exe catala_opts filename =
let module L = Surface.Lexer_common in
let lang =
match Clerk_scan.get_lang filename with
@ -95,7 +94,7 @@ let run_inline_tests catala_exe catala_opts build_dir filename =
skip_block lines
| Some args ->
let args = String.split_on_char ' ' args in
run_catala_test catala_exe catala_opts build_dir filename
run_catala_test catala_exe catala_opts filename
lines_until_now args oc;
skip_block lines)
and skip_block lines =

View File

@ -22,7 +22,7 @@
open Catala_utils
val run_inline_tests : string -> string list -> File.t -> File.t -> unit
(** [run_inline_tests catala_exe catala_opts build_dir file] runs the tests in
val run_inline_tests : string -> string list -> File.t -> unit
(** [run_inline_tests catala_exe catala_opts file] runs the tests in
Catala [file] using the given path to the Catala executable and the provided
options. Output is printed to [stdout]. *)

View File

@ -29,5 +29,5 @@ scope Baz:
```catala-test { id = "c" }
$ catala c -o -
$ catala c
```

View File

@ -41,5 +41,5 @@ $ catala typecheck --disable-warnings
```
```catala-test { id="ml" }
$ catala ocaml --disable-warnings -o -
$ catala ocaml --disable-warnings
```