diff --git a/CHANGES.md b/CHANGES.md index 231139f0..8f158a1b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -59,6 +59,9 @@ next - Remove hard-coded knowledge of ppx_driver and ocaml-migrate-parsetree when using a `dune` file (#576, @diml) +- Make the output of Dune slightly more deterministic when run from + inside Dune (#855, @diml) + 1.0+beta20 (10/04/2018) ----------------------- diff --git a/src/scheduler.ml b/src/scheduler.ml index 9847d7ae..8d2ec4a4 100644 --- a/src/scheduler.ml +++ b/src/scheduler.ml @@ -161,7 +161,30 @@ let go ?(log=Log.no_log) ?(config=Config.default) (Path.to_absolute_filename Path.root |> String.maybe_quoted); let cwd = Sys.getcwd () in if cwd <> initial_cwd then - Printf.eprintf "Entering directory '%s'\n%!" cwd; + Printf.eprintf "Entering directory '%s'\n%!" + (if Config.inside_dune then + let descendant_simple p ~of_ = + match + String.drop_prefix p ~prefix:of_ + with + | None | Some "" -> None + | Some s -> Some (String.sub s ~pos:1 ~len:(String.length s - 1)) + in + match descendant_simple cwd ~of_:initial_cwd with + | Some s -> s + | None -> + match descendant_simple initial_cwd ~of_:cwd with + | None -> cwd + | Some s -> + let rec loop acc dir = + if dir = Filename.current_dir_name then + acc + else + loop (Filename.concat acc "..") (Filename.dirname dir) + in + loop ".." (Filename.dirname s) + else + cwd); let t = { log ; gen_status_line diff --git a/test/blackbox-tests/test-cases/bad-alias-error/run.t b/test/blackbox-tests/test-cases/bad-alias-error/run.t index b614b185..b7aa6583 100644 --- a/test/blackbox-tests/test-cases/bad-alias-error/run.t +++ b/test/blackbox-tests/test-cases/bad-alias-error/run.t @@ -1,7 +1,11 @@ - $ dune runtest --root absolute-path 2>&1 | grep -v Entering + $ dune runtest --root absolute-path + Entering directory 'absolute-path' File "jbuild", line 3, characters 16-24: Error: Invalid alias! Tried to reference path outside build dir: "/foo/bar" - $ dune runtest --root outside-workspace 2>&1 | grep -v Entering + [1] + $ dune runtest --root outside-workspace + Entering directory 'outside-workspace' File "jbuild", line 4, characters 16-39: Error: path outside the workspace: ./../../../foobar from default + [1] diff --git a/test/blackbox-tests/test-cases/github644/run.t b/test/blackbox-tests/test-cases/github644/run.t index d64d64c1..ed8c8889 100644 --- a/test/blackbox-tests/test-cases/github644/run.t +++ b/test/blackbox-tests/test-cases/github644/run.t @@ -6,12 +6,12 @@ These should print something: - $ dune external-lib-deps --display quiet @runtest + $ dune external-lib-deps @runtest These are the external library dependencies in the default context: - ocaml-migrate-parsetree - ppx_that_doesn't_exist - $ dune external-lib-deps --display quiet --missing @runtest + $ dune external-lib-deps --missing @runtest Error: The following libraries are missing in the default context: - ppx_that_doesn't_exist Hint: try: opam install ppx_that_doesn't_exist diff --git a/test/blackbox-tests/test-cases/github660/run.t b/test/blackbox-tests/test-cases/github660/run.t index 8e5b0f64..9eff5181 100644 --- a/test/blackbox-tests/test-cases/github660/run.t +++ b/test/blackbox-tests/test-cases/github660/run.t @@ -1,20 +1,24 @@ When there are explicit interfaces, modules must be rebuilt. - $ dune runtest --root explicit-interfaces --display quiet -j1 2>&1 | grep -v Entering + $ dune runtest --root explicit-interfaces + Entering directory 'explicit-interfaces' main alias runtest hello $ echo 'let x = 1' >> explicit-interfaces/lib_sub.ml - $ dune runtest --root explicit-interfaces --display quiet -j1 2>&1 | grep -v Entering | grep -v ocamlopt + $ dune runtest --root explicit-interfaces + Entering directory 'explicit-interfaces' main alias runtest hello When there are no interfaces, the situation is the same, but it is not possible to rely on these. - $ dune runtest --root no-interfaces --display quiet -j1 2>&1 | grep -v Entering + $ dune runtest --root no-interfaces + Entering directory 'no-interfaces' main alias runtest hello $ echo 'let x = 1' >> no-interfaces/lib_sub.ml - $ dune runtest --root no-interfaces --display quiet -j1 2>&1 | grep -v Entering | grep -v ocamlopt + $ dune runtest --root no-interfaces + Entering directory 'no-interfaces' main alias runtest hello diff --git a/test/blackbox-tests/test-cases/intf-only/run.t b/test/blackbox-tests/test-cases/intf-only/run.t index 0365f33b..93ece8a2 100644 --- a/test/blackbox-tests/test-cases/intf-only/run.t +++ b/test/blackbox-tests/test-cases/intf-only/run.t @@ -1,6 +1,7 @@ Successes: - $ dune build --display short --root foo --debug-dep 2>&1 | grep -v Entering + $ dune build --display short --root foo --debug-dep + Entering directory 'foo' ocamldep test/bar.ml.d ocamldep foo.ml.d ocamlc .foo.objs/foo__.{cmi,cmo,cmt} @@ -20,7 +21,8 @@ Successes: Errors: - $ dune build --display short --root a foo.cma 2>&1 | grep -v Entering + $ dune build --display short --root a foo.cma + Entering directory 'a' File "dune", line 2, characters 1-13: Warning: Some modules don't have an implementation. You need to add the following field to this stanza: @@ -30,16 +32,21 @@ Errors: This will become an error in the future. ocamlc .foo.objs/foo.{cmi,cmo,cmt} ocamlc foo.cma - $ dune build --display short --root b foo.cma 2>&1 | grep -v Entering + $ dune build --display short --root b foo.cma + Entering directory 'b' File "dune", line 3, characters 34-37: Warning: The following modules must be listed here as they don't have an implementation: - y This will become an error in the future. ocamlc .foo.objs/foo.{cmi,cmo,cmt} ocamlc foo.cma - $ dune build --display short --root c foo.cma 2>&1 | grep -v Entering + $ dune build --display short --root c foo.cma + Entering directory 'c' File "dune", line 3, characters 35-36: Error: Module X doesn't exist. - $ dune build --display short --root d foo.cma 2>&1 | grep -v Entering + [1] + $ dune build --display short --root d foo.cma + Entering directory 'd' File "dune", line 3, characters 35-36: Error: Module X has an implementation, it cannot be listed here + [1] diff --git a/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t b/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t index 65ff14bc..76230e00 100644 --- a/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t +++ b/test/blackbox-tests/test-cases/odoc-unique-mlds/run.t @@ -1,5 +1,6 @@ Duplicate mld's in the same scope - $ dune build @doc --display short --root ./same-scope 2>&1 | grep -v Entering + $ dune build @doc --display short --root ./same-scope + Entering directory 'same-scope' odoc _doc/_html/odoc.css ocamlc lib1/.root_lib1.objs/root_lib1.{cmi,cmo,cmt} odoc _doc/_odoc/lib/root.lib1/root_lib1.odoc @@ -12,7 +13,8 @@ Duplicate mld's in the same scope Duplicate mld's in different scope $ rm -rf diff-scope/_build - $ dune build @doc --display short --root ./diff-scope 2>&1 | grep -v Entering + $ dune build @doc --display short --root ./diff-scope + Entering directory 'diff-scope' odoc _doc/_html/odoc.css ocamlc scope1/.scope1.objs/scope1.{cmi,cmo,cmt} odoc _doc/_odoc/lib/scope1/scope1.odoc diff --git a/test/blackbox-tests/test-cases/private-public-overlap/run.t b/test/blackbox-tests/test-cases/private-public-overlap/run.t index 78dde583..c4f146d0 100644 --- a/test/blackbox-tests/test-cases/private-public-overlap/run.t +++ b/test/blackbox-tests/test-cases/private-public-overlap/run.t @@ -1,13 +1,16 @@ public libraries may not have private dependencies - $ dune build --display short --root private-dep 2>&1 | grep -v Entering + $ dune build --display short --root private-dep + Entering directory 'private-dep' File "dune", line 10, characters 14-24: Error: Library "privatelib" is private, it cannot be a dependency of a public library. You need to give "privatelib" a public name. ocamldep publiclib.ml.d + [1] On the other hand, public libraries may have private preprocessors - $ dune build --display short --root private-rewriter 2>&1 | grep -v Entering + $ dune build --display short --root private-rewriter + Entering directory 'private-rewriter' ocamlc .ppx_internal.objs/ppx_internal.{cmi,cmo,cmt} ocamlopt .ppx_internal.objs/ppx_internal.{cmx,o} ocamlopt ppx_internal.{a,cmxa} @@ -21,7 +24,8 @@ On the other hand, public libraries may have private preprocessors ocamlc mylib.cma Unless they introduce private runtime dependencies: - $ dune build --display short --root private-runtime-deps 2>&1 | grep -v Entering + $ dune build --display short --root private-runtime-deps + Entering directory 'private-runtime-deps' File "jbuild", line 16, characters 20-31: Error: Library "private_runtime_dep" is private, it cannot be a dependency of a public library. You need to give "private_runtime_dep" a public name. @@ -31,14 +35,16 @@ Unless they introduce private runtime dependencies: ocamlopt .ppx/jbuild/private_ppx@mylib/ppx.exe ppx mylib.pp.ml ocamldep mylib.pp.ml.d + [1] However, public binaries may accept private dependencies - $ dune build --display short --root exes 2>&1 | grep -v Entering + $ dune build --display short --root exes + Entering directory 'exes' ocamldep publicbin.ml.d ocamlc .publicbin.eobjs/publicbin.{cmi,cmo,cmt} ocamlopt .publicbin.eobjs/publicbin.{cmx,o} ocamlopt publicbin.exe Private dependencies shouldn't make the library optional - $ dune build --display short --root optional 2>&1 | grep -v Entering - [1] + $ dune build --display short --root optional + Entering directory 'optional' diff --git a/test/blackbox-tests/test-cases/quoting/run.t b/test/blackbox-tests/test-cases/quoting/run.t index 5bfd5e4d..d1f6f44a 100644 --- a/test/blackbox-tests/test-cases/quoting/run.t +++ b/test/blackbox-tests/test-cases/quoting/run.t @@ -1,15 +1,19 @@ This behavior is surprising, we should get an error about the fact that ${@} is not quoted and doesn't contain exactly 1 element - $ dune build --root bad x 2>&1 | grep -v Entering + $ dune build --root bad x + Entering directory 'bad' Error: Rule failed to generate the following targets: - x - y + [1] The targets should only be interpreted as a single path when quoted - $ dune build --root good s 2>&1 | grep -v Entering + $ dune build --root good s + Entering directory 'good' Error: Rule failed to generate the following targets: - s - t + [1]