Skip to content

Commit

Permalink
Add test select validation tests
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Nov 7, 2019
1 parent 8af8a21 commit 55d0da0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dune/lib_dep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module Select = struct
"The prefix for files in this select branch must be %S"
prefix
];
if not (String.is_suffix result_fn ~suffix) then
if not (String.is_suffix file ~suffix) then
User_error.raise ~loc:loc_file
[ Pp.textf
"The suffix for files in this select branch must be %S"
Expand Down
10 changes: 10 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,14 @@
test-cases/select
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(rule
(alias select-2-0-rules)
(deps (package dune) (source_tree test-cases/select-2-0-rules))
(action
(chdir
test-cases/select-2-0-rules
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(rule
(alias several-packages)
(deps (package dune) (source_tree test-cases/several-packages))
Expand Down Expand Up @@ -2100,6 +2108,7 @@
(alias scope-bug)
(alias scope-ppx-bug)
(alias select)
(alias select-2-0-rules)
(alias several-packages)
(alias shadow-bindings)
(alias stale-artifact-removal)
Expand Down Expand Up @@ -2305,6 +2314,7 @@
(alias sandboxing)
(alias scope-bug)
(alias select)
(alias select-2-0-rules)
(alias several-packages)
(alias shadow-bindings)
(alias stale-artifact-removal)
Expand Down
19 changes: 19 additions & 0 deletions test/blackbox-tests/test-cases/select-2-0-rules/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$ echo "(lang dune 2.0)" > dune-project
$ cat > dune <<EOF
> (library (name foo) (libraries (select foo.ml from (!bar -> f.ml))))
> EOF
$ dune build
File "dune", line 1, characters 60-64:
1 | (library (name foo) (libraries (select foo.ml from (!bar -> f.ml))))
^^^^
Error: The prefix for files in this select branch must be "foo."
[1]
$ cat > dune <<EOF
> (library (name foo) (libraries (select foo.ml from (!bar -> foo.mli))))
> EOF
$ dune build
File "dune", line 1, characters 60-67:
1 | (library (name foo) (libraries (select foo.ml from (!bar -> foo.mli))))
^^^^^^^
Error: The suffix for files in this select branch must be ".ml"
[1]

0 comments on commit 55d0da0

Please sign in to comment.