diff --git a/src/jbuild.ml b/src/jbuild.ml index 98b8a4a0ce1d..b554633dda33 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -1360,11 +1360,11 @@ module Tests = struct ; deps : Dep_conf.t list } - let t = + let gen_parse names = record - (Buildable.t >>= fun buildable -> + (Buildable.t >>= fun buildable -> field_oslu "link_flags" >>= fun link_flags -> - field "names" (list (located string)) >>= fun names -> + names >>= fun names -> field "deps" (list Dep_conf.t) ~default:[] >>= fun deps -> field_o "package" Pkg.t >>= fun package -> field "locks" (list String_with_vars.t) ~default:[] >>= fun locks -> @@ -1383,6 +1383,10 @@ module Tests = struct ; package ; deps }) + + let multi = gen_parse (field "names" (list (located string))) + + let single = gen_parse (field "name" (located string) >>| List.singleton) end module Copy_files = struct @@ -1519,7 +1523,10 @@ module Stanzas = struct Jbuild_version.t >>| fun _ -> []) ; "tests", (Syntax.since Stanza.syntax (1, 0) >>= fun () -> - (Tests.t >>| fun t -> [Tests t])) + (Tests.multi >>| fun t -> [Tests t])) + ; "test", + (Syntax.since Stanza.syntax (1, 0) >>= fun () -> + (Tests.single >>| fun t -> [Tests t])) ; "env", (Syntax.since Stanza.syntax (1, 0) >>= fun () -> loc >>= fun loc -> diff --git a/src/stdune/list.ml b/src/stdune/list.ml index 5342445f8872..395119d6694d 100644 --- a/src/stdune/list.ml +++ b/src/stdune/list.ml @@ -102,3 +102,5 @@ let rec assoc t x = match t with | [] -> None | (k, v) :: t -> if x = k then Some v else assoc t x + +let singleton x = [x] diff --git a/src/stdune/list.mli b/src/stdune/list.mli index c636079c8c07..b19ace2bba16 100644 --- a/src/stdune/list.mli +++ b/src/stdune/list.mli @@ -38,3 +38,5 @@ val stable_sort : 'a t -> compare:('a -> 'a -> Ordering.t) -> 'a t val compare : 'a t -> 'a t -> compare:('a -> 'a -> Ordering.t) -> Ordering.t val assoc : ('a * 'b) t -> 'a -> 'b option + +val singleton : 'a -> 'a t diff --git a/test/blackbox-tests/test-cases/tests-stanza/dune b/test/blackbox-tests/test-cases/tests-stanza/dune index dd47434707d9..ed5f15344d5b 100644 --- a/test/blackbox-tests/test-cases/tests-stanza/dune +++ b/test/blackbox-tests/test-cases/tests-stanza/dune @@ -1,2 +1,7 @@ (tests - (names expect_test regular_test)) \ No newline at end of file + (names expect_test regular_test) + (modules :standard \ singular)) + +(test + (name singular) + (modules singular)) \ No newline at end of file diff --git a/test/blackbox-tests/test-cases/tests-stanza/run.t b/test/blackbox-tests/test-cases/tests-stanza/run.t index 9a7aedf1e413..93ebf2bfcb72 100644 --- a/test/blackbox-tests/test-cases/tests-stanza/run.t +++ b/test/blackbox-tests/test-cases/tests-stanza/run.t @@ -1,4 +1,10 @@ $ dune runtest --display short + 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 ocamldep .expect_test.eobjs/expect_test.ml.d ocamldep .expect_test.eobjs/regular_test.ml.d ocamlc .expect_test.eobjs/regular_test.{cmi,cmo,cmt} diff --git a/test/blackbox-tests/test-cases/tests-stanza/singular.ml b/test/blackbox-tests/test-cases/tests-stanza/singular.ml new file mode 100644 index 000000000000..bef74aacbe06 --- /dev/null +++ b/test/blackbox-tests/test-cases/tests-stanza/singular.ml @@ -0,0 +1 @@ +print_endline "singular test"