Make -p honor test stanzas

Previously, this option would consider that test stanzas do not have any
package set.

Closes #1231

Signed-off-by: Etienne Millon <me@emillon.org>
This commit is contained in:
Etienne Millon 2018-09-07 11:19:26 +02:00
parent 3c9cfbf1c0
commit dcf3f0713b
10 changed files with 46 additions and 11 deletions

View File

@ -54,6 +54,8 @@ next
- Cleanup the way we detect the library search path. We no longer call
`opam config var lib` in the default build context (#1226, @diml)
- Make test stanzas honor the -p flag. (#1236, fix #1231, @emillon)
1.1.1 (08/08/2018)
------------------

View File

@ -359,6 +359,21 @@ module type Gen = sig
val sctx : Super_context.t
end
let stanza_package = function
| Library { public = Some { package; _ }; _ }
| Alias { package = Some package ; _ }
| Install { package; _ }
| Documentation { package; _ }
| Tests { package = Some package; _} ->
Some package
| _ -> None
let relevant_stanzas pkgs stanzas =
List.filter stanzas ~f:(fun stanza ->
match stanza_package stanza with
| Some package -> Package.Name.Set.mem pkgs package.name
| None -> true)
let gen ~contexts ~build_system
?(external_lib_deps_mode=false)
?only_packages conf =
@ -388,17 +403,9 @@ let gen ~contexts ~build_system
| None -> stanzas
| Some pkgs ->
List.map stanzas ~f:(fun (dir_conf : Jbuild_load.Jbuild.t) ->
let stanzas =
List.filter dir_conf.stanzas ~f:(fun stanza ->
match (stanza : Stanza.t) with
| Library { public = Some { package; _ }; _ }
| Alias { package = Some package ; _ }
| Install { package; _ }
| Documentation { package; _ } ->
Package.Name.Set.mem pkgs package.name
| _ -> true)
in
{ dir_conf with stanzas })
{ dir_conf with
stanzas = relevant_stanzas pkgs dir_conf.stanzas
})
in
Fiber.fork_and_join host stanzas >>= fun (host, stanzas) ->
let sctx =

View File

@ -271,6 +271,14 @@
test-cases/github1099
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias
(name github1231)
(deps (package dune) (source_tree test-cases/github1231))
(action
(chdir
test-cases/github1231
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))
(alias
(name github20)
(deps (package dune) (source_tree test-cases/github20))
@ -888,6 +896,7 @@
(alias gen-opam-install-file)
(alias github1019)
(alias github1099)
(alias github1231)
(alias github20)
(alias github24)
(alias github25)
@ -992,6 +1001,7 @@
(alias force-test)
(alias github1019)
(alias github1099)
(alias github1231)
(alias github20)
(alias github24)
(alias github25)

View File

@ -0,0 +1,12 @@
(test
(name test_a)
(modules test_a)
(package a)
)
(test
(name test_b)
(modules test_b)
(package b)
(libraries does-not-exist)
)

View File

@ -0,0 +1 @@
(lang dune 1.2)

View File

@ -0,0 +1,3 @@
When -p is passed, other packages are not considered.
$ dune runtest -p a