Skip to content

Commit

Permalink
Expect tests: support multiple modes
Browse files Browse the repository at this point in the history
Each mode must correspond to a different output file.

Signed-off-by: Jérôme Vouillon <jerome.vouillon@gmail.com>
  • Loading branch information
vouillon committed Jun 26, 2024
1 parent 4bf0ae4 commit 3b1ca90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/dune_rules/test_rules.ml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
open Import

let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
let test_kind (loc, name) =
let test_kind (loc, name, ext) =
let files = Dir_contents.text_files dir_contents in
let expected_basename = name ^ ".expected" in
if Filename.Set.mem files expected_basename
then
`Expect
{ Diff.file1 = String_with_vars.make_text loc expected_basename
; file2 = String_with_vars.make_text loc (name ^ ".output")
; file2 = String_with_vars.make_text loc (name ^ ext ^ ".output")
; optional = false
; mode = Text
}
Expand Down Expand Up @@ -91,7 +91,7 @@ let rules (t : Tests.t) ~sctx ~dir ~scope ~expander ~dir_contents =
in
Simple_rules.alias sctx ~extra_bindings ~dir ~expander alias
in
match test_kind (loc, s) with
match test_kind (loc, s, ext) with
| `Regular -> add_alias ~loc ~action:run_action ~locks:[]
| `Expect diff ->
let rule =
Expand Down
4 changes: 0 additions & 4 deletions test/blackbox-tests/test-cases/tests-stanza/modes.t/run.t
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
$ dune runtest
Error: Multiple rules generated for _build/default/modes.output:
- dune:1
- dune:1
[1]

0 comments on commit 3b1ca90

Please sign in to comment.