Skip to content

Commit

Permalink
Attach actions from cinaps to @cinaps and @runtest
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Rebours <[email protected]>
  • Loading branch information
NathanReb committed Nov 15, 2019
1 parent 0d355dd commit 5f57ed9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
2.0.0 (unreleased)
------------------

- Attach cinaps stanza actions to both `@runtest` and `@cinaps` aliases
(#2831, @NathanReb)

- Remove existing destination files in `install` before installing the new
ones. (#2885, fixes #2883, @bschommer)

Expand Down
17 changes: 13 additions & 4 deletions src/dune/cinaps.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Stanza.t += T of t
let syntax =
Dune_lang.Syntax.create ~name:"cinaps" ~desc:"the cinaps extension" [ (1, 0) ]

let alias = Alias.(make (Name.of_string "cinaps"))

let decode =
let open Dune_lang.Decoder in
fields
Expand Down Expand Up @@ -99,9 +101,8 @@ let gen_rules sctx t ~dir ~scope =
~program:{ name; main_module_name; loc }
~linkages:[ Exe.Linkage.native_or_custom (Super_context.context sctx) ]
~promote:None;
Super_context.add_alias_action sctx ~dir ~loc:(Some loc) ~stamp:"cinaps"
(Alias.runtest ~dir)
(let module A = Action in
let action =
let module A = Action in
let cinaps_exe = Path.build cinaps_exe in
let+ () = Build.path cinaps_exe in
A.chdir (Path.build dir)
Expand All @@ -110,4 +111,12 @@ let gen_rules sctx t ~dir ~scope =
:: List.map cinapsed_files ~f:(fun fn ->
let fn = Path.build fn in
A.diff ~optional:true fn
(Path.extend_basename fn ~suffix:".cinaps-corrected")) )))
(Path.extend_basename fn ~suffix:".cinaps-corrected")) ))
in
let cinaps_alias = alias ~dir in
Super_context.add_alias_action sctx ~dir ~loc:(Some loc) ~stamp:"cinaps"
cinaps_alias action;
let stamp_file =
Alias.stamp_file cinaps_alias |> Path.build |> Path.Set.singleton
in
Rules.Produce.Alias.add_deps (Alias.runtest ~dir) stamp_file
25 changes: 23 additions & 2 deletions test/blackbox-tests/test-cases/cinaps/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,34 @@ Test of cinaps integration
> (*$*)
> let x = 1
> "EOF"
sh: line 4: warning: here-document at line 0 delimited by end-of-file (wanted `EOF')

The cinaps actions should be attached to the runtest alias:

$ dune runtest --diff-command diff
sh (internal) (exit 1)
(cd _build/default && /usr/bin/sh -c 'diff test.ml test.ml.cinaps-corrected')
1a2
> hello
[1]

but also to the cinaps alias:

$ dune build @cinaps --diff-command diff
sh (internal) (exit 1)
(cd _build/default && /usr/bin/sh -c 'diff test.ml test.ml.cinaps-corrected')
1a2
> hello
[1]

The cinaps stanza offers a promotion workflow:

$ dune runtest --auto-promote
File "test.ml", line 1, characters 0-0:
Files _build/default/test.ml and _build/default/test.ml.cinaps-corrected differ.
Error: Files _build/default/test.ml and
_build/default/test.ml.cinaps-corrected differ.
Promoting _build/default/test.ml.cinaps-corrected to test.ml.
[1]

$ cat test.ml
(*$ print_endline "\nhello" *)
hello
Expand Down

0 comments on commit 5f57ed9

Please sign in to comment.