Skip to content

Commit

Permalink
Merge pull request #1243 from rgrinberg/fix-1240
Browse files Browse the repository at this point in the history
Allow expect tests to generated in test stanza
  • Loading branch information
rgrinberg authored Sep 10, 2018
2 parents 4041db3 + 529a8e6 commit fc7aaa1
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 14 deletions.
10 changes: 4 additions & 6 deletions src/gen_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,11 @@ module Gen(P : Install_rules.Params) = struct
| Tests |
+-----------------------------------------------------------------+ *)

let tests_rules (t : Tests.t) ~dir ~scope ~dir_contents
~dir_kind ~src_dir =
let tests_rules (t : Tests.t) ~dir ~scope ~dir_contents ~dir_kind =
let test_kind (loc, name) =
let sources = SC.source_files sctx ~src_path:src_dir in
let files = Dir_contents.text_files dir_contents in
let expected_basename = name ^ ".expected" in
if String.Set.mem sources expected_basename then
if String.Set.mem files expected_basename then
`Expect
{ Action.Unexpanded.Diff.
file1 = String_with_vars.make_text loc expected_basename
Expand Down Expand Up @@ -244,8 +243,7 @@ module Gen(P : Install_rules.Params) = struct
loop stanzas merlins cctxs
| Tests tests ->
let cctx, merlin =
tests_rules tests ~dir ~scope ~src_dir
~dir_contents ~dir_kind:kind
tests_rules tests ~dir ~scope ~dir_contents ~dir_kind:kind
in
loop stanzas (merlin :: merlins)
((tests.exes.buildable.loc, cctx) :: cctxs)
Expand Down
7 changes: 0 additions & 7 deletions test/blackbox-tests/test-cases/tests-stanza/dune

This file was deleted.

6 changes: 6 additions & 0 deletions test/blackbox-tests/test-cases/tests-stanza/generated/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(rule
(with-stdout-to generated.expected (echo "foo\nbar\n")))

(test
(name generated)
(modules generated))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline "foo\nbaz"
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/tests-stanza/plural/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(tests
(names expect_test regular_test))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 1.0)
16 changes: 15 additions & 1 deletion test/blackbox-tests/test-cases/tests-stanza/run.t
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
$ dune runtest --display short
$ dune runtest --root singular --display short
Entering directory 'singular'
ocamldep .singular.eobjs/singular.ml.d
ocamlc .singular.eobjs/singular.{cmi,cmo,cmt}
ocamlopt .singular.eobjs/singular.{cmx,o}
ocamlopt singular.exe
singular alias runtest
singular test

$ dune runtest --root plural --display short
Entering directory 'plural'
ocamldep .expect_test.eobjs/expect_test.ml.d
ocamldep .expect_test.eobjs/regular_test.ml.d
ocamlc .expect_test.eobjs/expect_test.{cmi,cmo,cmt}
Expand All @@ -16,3 +20,13 @@
ocamlopt regular_test.exe
regular_test alias runtest
regular test
$ dune runtest --diff-command false --root generated --display short
Entering directory 'generated'
ocamldep .generated.eobjs/generated.ml.d
ocamlc .generated.eobjs/generated.{cmi,cmo,cmt}
ocamlopt .generated.eobjs/generated.{cmx,o}
ocamlopt generated.exe
generated generated.output
sh (internal) (exit 1)
(cd _build/default && /bin/sh -c 'false generated.expected generated.output')
[1]
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/tests-stanza/singular/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(test (name singular))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 1.0)

0 comments on commit fc7aaa1

Please sign in to comment.