diff --git a/src/dune/mdx.ml b/src/dune/mdx.ml index ff6979e569d..e19d7e09a8d 100644 --- a/src/dune/mdx.ml +++ b/src/dune/mdx.ml @@ -118,7 +118,7 @@ end type t = { loc : Loc.t ; files : Predicate_lang.Glob.t - ; packages : Package.Name.t list + ; packages : (Loc.t * Package.Name.t) list ; preludes : Prelude.t list } @@ -139,7 +139,8 @@ let decode = (let+ loc = loc and+ files = field "files" Predicate_lang.Glob.decode ~default:default_files - and+ packages = field ~default:[] "packages" (repeat Package.Name.decode) + and+ packages = + field ~default:[] "packages" (repeat (located Package.Name.decode)) and+ preludes = field ~default:[] "preludes" (repeat Prelude.decode) in { loc; files; packages; preludes }) @@ -181,7 +182,7 @@ let gen_rules_for_single_file stanza ~sctx ~dir ~expander ~mdx_prog src = let dyn_deps = Build.map deps ~f:(fun d -> ((), d)) in let pkg_deps = stanza.packages - |> List.map ~f:(fun pkg -> + |> List.map ~f:(fun (loc, pkg) -> Dep_conf.Package (Package.Name.to_string pkg |> String_with_vars.make_text loc)) in diff --git a/test/blackbox-tests/test-cases/mdx-stanza.t/run.t b/test/blackbox-tests/test-cases/mdx-stanza.t/run.t index 8fe85ddc048..3f950c98096 100644 --- a/test/blackbox-tests/test-cases/mdx-stanza.t/run.t +++ b/test/blackbox-tests/test-cases/mdx-stanza.t/run.t @@ -57,10 +57,9 @@ Dune does not fail if the `packages` are not available at evaluation time Dune fails if the `packages` are not avaliable at execution time $ cd local-package-unrelated && dune runtest -p unrelated-package; cd ../ - File "dune", line 1, characters 0-40: - 1 | (mdx - 2 | (files README.md) + File "dune", line 3, characters 11-14: 3 | (packages pkg)) + ^^^ Error: Package pkg does not exist You can set MDX preludes using the preludes field of the stanza