Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print "Leaving Directory" #6419

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Unreleased
0.7. `(mode native)` has been deprecated in favour of detection from the
configuration of Coq. (#6409, @Alizter)

- Print "Leaving Directory" whenever "Entering Directory" is printed. (#6149,
fixes #138, @cpitclaudel, @rgrinberg)

3.6.0 (2022-11-14)
------------------

Expand Down Expand Up @@ -3065,7 +3068,7 @@ Unreleased

- Print `Entering directory '...'` when the workspace root is not the
current directory. This allows Emacs and Vim to know where relative
filenames should be interpreted from. Fixes #138
filenames should be interpreted from. (fixes #138, @jeremiedimino)

- Fix a bug related to `menhir` stanzas: `menhir` stanzas with a
`merge_into` field that were in `jbuild` files in sub-directories
Expand Down
7 changes: 5 additions & 2 deletions bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ let normalize_path path =

let print_entering_message c =
let cwd = Path.to_absolute_filename Path.root in
if cwd <> Fpath.initial_cwd && not c.no_print_directory then
if cwd <> Fpath.initial_cwd && not c.no_print_directory then (
(* Editors such as Emacs parse the output of the build system and interpret
filenames in error messages relative to where the build system was
started.
Expand Down Expand Up @@ -151,7 +151,10 @@ let print_entering_message c =
in
loop ".." (Filename.dirname s)))
in
Console.print [ Pp.verbatim (sprintf "Entering directory '%s'" dir) ]
Console.print [ Pp.verbatim (sprintf "Entering directory '%s'" dir) ];
at_exit (fun () ->
flush stdout;
Console.print [ Pp.verbatim (sprintf "Leaving directory '%s'" dir) ]))

let init ?log_file c =
if c.root.dir <> Filename.current_dir_name then Sys.chdir c.root.dir;
Expand Down
5 changes: 5 additions & 0 deletions otherlibs/site/test/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,11 @@ Test compiling an external plugin

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH dune build --root=e
Entering directory 'e'
Leaving directory 'e'

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH PATH=$(pwd)/_install/bin:$PATH dune exec --root=e -- c
Entering directory 'e'
Leaving directory 'e'
run a
a: $TESTCASE_ROOT/_install/share/a/data
run c: a linked registered:.
Expand All @@ -354,6 +356,7 @@ Test compiling an external plugin

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH dune install --root=e --prefix $(pwd)/_install 2>&1 | sed -e "/^Installing/d"
Entering directory 'e'
Leaving directory 'e'

$ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/c
run a
Expand Down Expand Up @@ -411,6 +414,7 @@ Test %{version:installed-pkg}

$ OCAMLPATH=_install/lib:$OCAMLPATH dune build --root=f
Entering directory 'f'
Leaving directory 'f'
$ cat $(pwd)/f/_build/default/test.target
a = 0.a
e =
Expand All @@ -423,6 +427,7 @@ Test %{version:installed-pkg}
^^^^^^^^^^^^^^^^^
Error: Library names are not allowed in this position. Only package names are
allowed
Leaving directory 'f'
[1]

$ rm f/dune
Expand Down
4 changes: 4 additions & 0 deletions otherlibs/site/test/run_2_9.t
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ Test compiling an external plugin

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH dune build --root=e
Entering directory 'e'
Leaving directory 'e'

$ OCAMLPATH=$(pwd)/_install/lib:$OCAMLPATH PATH=$(pwd)/_install/bin:$PATH dune exec --root=e -- c
Entering directory 'e'
Leaving directory 'e'
run a
a: $TESTCASE_ROOT/_install/share/a/data
run c: a linked registered:.
Expand Down Expand Up @@ -395,6 +397,7 @@ Test %{version:installed-pkg}

$ OCAMLPATH=_install/lib:$OCAMLPATH dune build --root=f
Entering directory 'f'
Leaving directory 'f'
$ cat $(pwd)/f/_build/default/test.target
a = 0.a
e =
Expand All @@ -407,6 +410,7 @@ Test %{version:installed-pkg}
^^^^^^^^^^^^^^^^^
Error: Library names are not allowed in this position. Only package names are
allowed
Leaving directory 'f'
[1]

$ rm f/dune
Expand Down
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/coq/coqtop/coqtop-recomp.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ https://github.com/ocaml/dune/pull/5457#issuecomment-1084161587).
coqdep dir/bar.v.d
coqdep dir/foo.v.d
coqc dir/foo.{glob,vo}
Leaving directory '..'
-topfile $TESTCASE_ROOT/_build/default/dir/bar.v -q -w -deprecated-native-compiler-option -w -native-compiler-disabled -native-compiler ondemand -R $TESTCASE_ROOT/_build/default/dir basic
$ (cd dir && dune coq top --root .. --display short --toplevel echo dir/bar.v)
Entering directory '..'
Leaving directory '..'
-topfile $TESTCASE_ROOT/_build/default/dir/bar.v -q -w -deprecated-native-compiler-option -w -native-compiler-disabled -native-compiler ondemand -R $TESTCASE_ROOT/_build/default/dir basic

9 changes: 9 additions & 0 deletions test/blackbox-tests/test-cases/depend-on/installed-packages.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

$ dune build --root a
Entering directory 'a'
Leaving directory 'a'

$ dune install --root a --prefix $(pwd)/prefix
Entering directory 'a'
Installing $TESTCASE_ROOT/prefix/lib/a/META
Installing $TESTCASE_ROOT/prefix/lib/a/dune-package
Installing $TESTCASE_ROOT/prefix/share/a/CATME
Leaving directory 'a'

$ cat >b/dune-project <<EOF
> (lang dune 2.9)
Expand All @@ -36,9 +38,11 @@
$ OCAMLPATH=$(pwd)/prefix/lib/:$OCAMLPATH dune build --root b @runtest
Entering directory 'b'
Miaou
Leaving directory 'b'

$ OCAMLPATH=$(pwd)/prefix/lib/:$OCAMLPATH dune build --root b @runtest
Entering directory 'b'
Leaving directory 'b'

$ rm a/CATME
$ cat >a/CATME <<EOF
Expand All @@ -47,6 +51,7 @@

$ dune build --root a
Entering directory 'a'
Leaving directory 'a'

$ dune install --root a --prefix $(pwd)/prefix
Entering directory 'a'
Expand All @@ -56,13 +61,16 @@
Installing $TESTCASE_ROOT/prefix/lib/a/dune-package
Deleting $TESTCASE_ROOT/prefix/share/a/CATME
Installing $TESTCASE_ROOT/prefix/share/a/CATME
Leaving directory 'a'

$ OCAMLPATH=$(pwd)/prefix/lib/:$OCAMLPATH dune build --root b @runtest
Entering directory 'b'
Ouaf
Leaving directory 'b'

$ OCAMLPATH=$(pwd)/prefix/lib/:$OCAMLPATH dune build --root b @runtest
Entering directory 'b'
Leaving directory 'b'

$ cat >b/dune-project <<EOF
> (lang dune 2.8)
Expand All @@ -75,4 +83,5 @@
1 | (rule (alias runtest) (deps (package a)) (action (run cat $TESTCASE_ROOT/prefix/share/a/CATME)))
^
Error: Dependency on an installed package requires at least (lang dune 2.9)
Leaving directory 'b'
[1]
5 changes: 5 additions & 0 deletions test/blackbox-tests/test-cases/dune-init.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ We can build the project:

$ dune build --root test_exec_proj
Entering directory 'test_exec_proj'
Leaving directory 'test_exec_proj'

And the opam file will be generated as expected

Expand Down Expand Up @@ -386,12 +387,14 @@ We can build and run the resulting executable:

$ dune exec --root test_exec_proj ./bin/main.exe
Entering directory 'test_exec_proj'
Leaving directory 'test_exec_proj'
Hello, World!

We can build and run the project's tests:

$ dune exec --root test_exec_proj ./test/test_exec_proj.exe
Entering directory 'test_exec_proj'
Leaving directory 'test_exec_proj'

Initializing library projects
================================
Expand Down Expand Up @@ -448,6 +451,7 @@ We can build and install the project:

$ dune build --root test_lib_proj @install
Entering directory 'test_lib_proj'
Leaving directory 'test_lib_proj'

And the opam file will be generated as expected

Expand Down Expand Up @@ -492,6 +496,7 @@ And we we can run the tests:
ocamlopt test/.test_lib_proj.eobjs/native/dune__exe__Test_lib_proj.{cmx,o}
ocamlopt test/test_lib_proj.exe
test_lib_proj alias test/runtest
Leaving directory 'test_lib_proj'

Initializing projects using Esy
===============================
Expand Down
4 changes: 4 additions & 0 deletions test/blackbox-tests/test-cases/dune-package.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

$ dune build --root=a
Entering directory 'a'
Leaving directory 'a'
$ dune_cmd cat a/_build/install/default/lib/a/dune-package | sed "s/(lang dune .*)/(lang dune <version>)/" | dune_cmd sanitize
(lang dune <version>)
(name a)
Expand Down Expand Up @@ -106,6 +107,7 @@
Build with "--store-orig-source-dir" profile
$ dune build --root=a --store-orig-source-dir
Entering directory 'a'
Leaving directory 'a'
$ dune_cmd cat a/_build/install/default/lib/a/dune-package | grep -A 1 '(orig_src_dir'
(orig_src_dir
$TESTCASE_ROOT/a)
Expand All @@ -119,6 +121,7 @@ Build with "--store-orig-source-dir" profile
Build with "DUNE_STORE_ORIG_SOURCE_DIR=true" profile
$ DUNE_STORE_ORIG_SOURCE_DIR=true dune build --root=a
Entering directory 'a'
Leaving directory 'a'
$ dune_cmd cat a/_build/install/default/lib/a/dune-package | grep -A 1 '(orig_src_dir'
(orig_src_dir
$TESTCASE_ROOT/a)
Expand All @@ -133,6 +136,7 @@ Install the package directly

$ dune install "--prefix=$PWD/prefix" --root=a 2>&1 | grep -v "Installing"
Entering directory 'a'
Leaving directory 'a'

$ dune_cmd cat prefix/lib/a/dune-package | grep -e 'lib/a' -e 'share/a'
$TESTCASE_ROOT/prefix/lib/a)
Expand Down
14 changes: 14 additions & 0 deletions test/blackbox-tests/test-cases/dune-ppx-driver-system.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ No ppx driver found
5 | (preprocess (pps)))
^^^^^
Error: You must specify at least one ppx rewriter.
Leaving directory 'no-driver'
[1]

Too many drivers
Expand All @@ -26,6 +27,7 @@ Too many drivers
^^^^^^^^^^^^^^^
Error: Too many incompatible ppx drivers were found: foo.driver1 and
foo.driver2.
Leaving directory 'driver-tests'
[1]

Not compatible with Dune
Expand All @@ -38,6 +40,7 @@ Not compatible with Dune
Error: No ppx driver were found. It seems that ppx_other is not compatible
with Dune. Examples of ppx rewriters that are compatible with Dune are ones
using ocaml-migrate-parsetree, ppxlib or ppx_driver.
Leaving directory 'driver-tests'
[1]

Incompatible Cookies
Expand All @@ -49,18 +52,21 @@ Incompatible Cookies
^^^^^^^^^^^^^^^
Error: foo.ppx3 and foo.ppx4 have inconsistent requests for cookie "germany";
foo.ppx3 requests "spritzgeback" and foo.ppx4 requests "lebkuchen"
Leaving directory 'driver-tests'
[1]

Same, but with error pointing to .ppx

$ dune build --root driver-tests .ppx/foo.ppx1+foo.ppx2/ppx.exe
Entering directory 'driver-tests'
Error: invalid ppx key for _build/default/.ppx/foo.ppx1+foo.ppx2/ppx.exe
Leaving directory 'driver-tests'
[1]

$ dune build --root driver-tests .ppx/foo.ppx-other/ppx.exe
Entering directory 'driver-tests'
Error: invalid ppx key for _build/default/.ppx/foo.ppx-other/ppx.exe
Leaving directory 'driver-tests'
[1]

Test the argument syntax
Expand Down Expand Up @@ -90,6 +96,7 @@ Test the argument syntax
95 | -foo bar %{env:ENGLAND=undefined})))
Error: Rule failed to generate the following targets:
- test_ppx_args.pp.ml
Leaving directory 'driver-tests'
[1]

Test the argument syntax with list expansion allowed (dune > 3.2)
Expand Down Expand Up @@ -123,6 +130,7 @@ Test the argument syntax with list expansion allowed (dune > 3.2)
24 | -foo bar %{env:ENGLAND=undefined} %{read-lines:ppx-args})))
Error: Rule failed to generate the following targets:
- test_ppx_args.pp.ml
Leaving directory 'driver-tests-list-args'
[1]

Test that going through the -ppx option of the compiler works
Expand All @@ -131,11 +139,13 @@ Test that going through the -ppx option of the compiler works
Entering directory 'driver-tests'
tool name: ocamlc
args:--as-ppx -arg1 -arg2 -arg3=Oreo -foo bar Snickerdoodle --cookie france="Petit Beurre" --cookie italy="Biscotti" --cookie library-name="test_ppx_staged"
Leaving directory 'driver-tests'

Test using installed drivers

$ dune build --root driver @install
Entering directory 'driver'
Leaving directory 'driver'
$ OCAMLPATH=driver/_build/install/default/lib dune build --root use-external-driver driveruser.cma
Entering directory 'use-external-driver'
.ppx/35d69311d5da258d073875db2b34f33b/ppx.exe
Expand All @@ -155,6 +165,7 @@ Test using installed drivers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Rule failed to generate the following targets:
- driveruser.pp.ml
Leaving directory 'use-external-driver'
[1]

$ OCAMLPATH=driver/_build/install/default/lib dune build --root replaces driveruser.cma
Expand All @@ -177,10 +188,12 @@ Test using installed drivers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Rule failed to generate the following targets:
- driveruser.pp.ml
Leaving directory 'replaces'
[1]

$ OCAMLPATH=driver/_build/install/default/lib dune build --root driver-replaces @install
Entering directory 'driver-replaces'
Leaving directory 'driver-replaces'
$ OCAMLPATH=driver/_build/install/default/lib:driver-replaces/_build/install/default/lib dune build --root replaces-external driveruser.cma
Entering directory 'replaces-external'
replacesdriver
Expand All @@ -201,4 +214,5 @@ Test using installed drivers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Rule failed to generate the following targets:
- driveruser.pp.ml
Leaving directory 'replaces-external'
[1]
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/dup-fields.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Duplicating a field in a dune file is an error:
4 | (action (echo bar)))
^^^^^^^^^^^^^^^^^^^
Error: Field "action" is present too many times
Leaving directory 'dune'
[1]
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/exec-cmd.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

$ (cd test; dune exec --root .. -- dunetestbar)
Entering directory '..'
Leaving directory '..'
Bar

$ ls -a test/_build
Expand Down
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/exes-with-c.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
4 | (foreign_stubs (language c) (names stubs)))
Error: Pure bytecode executables cannot contain foreign stubs.
Hint: If you only need to build a native executable use "(modes exe)".
Leaving directory 'err'
[1]
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/findlib-error.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ We are dropping support for findlib in dune
^^^^^^^^^^^^^^
Error: %{findlib:..} was renamed to '%{lib:..}' in the 1.0 version of the
dune language
Leaving directory 'in-dune'
[1]
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/foreign-library.t
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ Testsuite for the (foreign_library ...) stanza.

$ export OCAMLPATH=$PWD/external/install/lib; ./sdune exec ./main.exe --root=some/dir
Entering directory 'some/dir'
Leaving directory 'some/dir'
Answer = 42

----------------------------------------------------------------------------------
Expand Down Expand Up @@ -791,6 +792,7 @@ Testsuite for the (foreign_library ...) stanza.
2 | (archive_name some/path/id)
^^^^^^^^^^^^
Error: Path separators are not allowed in archive names.
Leaving directory 'github2914/dir'
[1]

----------------------------------------------------------------------------------
Expand Down Expand Up @@ -902,5 +904,6 @@ Testsuite for the (foreign_library ...) stanza.
> EOF
$ dune build --root stubs_in_libs
Entering directory 'stubs_in_libs'
Leaving directory 'stubs_in_libs'
$ stubs_in_libs/_build/default/main.exe
12
Loading