Skip to content

Commit

Permalink
fix: print "Leaving Directory"
Browse files Browse the repository at this point in the history
Print "Leaving Directory '%s'" in addition to "Entering Directory"

Fixes #138

Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: 462a51cc-0bc8-44da-85d2-027bc1e372d7
  • Loading branch information
cpitclaudel authored and rgrinberg committed Nov 12, 2022
1 parent 73f6316 commit 523b415
Show file tree
Hide file tree
Showing 34 changed files with 113 additions and 3 deletions.
7 changes: 5 additions & 2 deletions bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,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 @@ -144,7 +144,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
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
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/github1549.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Reproduction case for #1549: too many parentheses in installed .dune files

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

$ dune_cmd cat backend/_build/install/default/lib/dune_inline_tests/dune-package | sed "s/(lang dune .*)/(lang dune <version>)/" | dune_cmd sanitize
(lang dune <version>)
Expand Down Expand Up @@ -45,3 +46,4 @@ Reproduction case for #1549: too many parentheses in installed .dune files

$ env OCAMLPATH=backend/_build/install/default/lib dune runtest --root example
Entering directory 'example'
Leaving directory 'example'
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/github1616.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Regression test for #1616
$ env PATH="$PWD/bin2:$PWD/bin1:$PATH" dune build --root root
Entering directory 'root'
Hello, World!
Leaving directory 'root'
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ package:
$ export OCAMLPATH=$PWD/_install/lib; dune runtest --root dune-file-user
Entering directory 'dune-file-user'
414243
Leaving directory 'dune-file-user'
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ to be successful.
$ dune runtest valid_options --root ./test-project
Entering directory 'test-project'
backend_foo
Leaving directory 'test-project'

Lastly, we pass an invalid option to flags field expecting compilation
to fail.
Expand Down
Loading

0 comments on commit 523b415

Please sign in to comment.