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 10, 2022
1 parent 0b33b36 commit 8d1fcc9
Show file tree
Hide file tree
Showing 53 changed files with 196 additions and 10 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
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/bad-alias-error.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
^^^^^^^^
Error: Invalid alias!
Tried to reference path outside build dir: "/foo/bar"
Leaving directory 'absolute-path'
[1]
$ dune runtest --root outside-workspace
Entering directory 'outside-workspace'
File "dune", line 4, characters 9-42:
4 | (alias %{workspace_root}/../../../foobar)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: path outside the workspace: ./../../../foobar from default
Leaving directory 'outside-workspace'
[1]
9 changes: 8 additions & 1 deletion test/blackbox-tests/test-cases/copy_files.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ Test that (copy_files ...) works

$ dune build --root test1 test.exe .merlin-conf/lib-foo .merlin-conf/exe-test
Entering directory 'test1'
Leaving directory 'test1'
$ dune build --root test1 @bar-source
Entering directory 'test1'
#line 1 "include/bar.h"
int foo () {return 42;}
Leaving directory 'test1'
$ dune build --root test2 @foo/cat
Entering directory 'test2'
# 1 "dummy.txt"
hello
helloLeaving directory 'test2'

Test (alias ...) and (mode ...) fields:

Expand All @@ -33,6 +35,7 @@ Test (alias ...) and (mode ...) fields:
^^^^^^^^^^^
Error: 'alias' is only available since version 2.7 of the dune language.
Please update your dune-project file to have (lang dune 2.7).
Leaving directory 'test3'
[1]

$ cat >test3/dune-project <<EOF
Expand All @@ -41,6 +44,7 @@ Test (alias ...) and (mode ...) fields:

$ dune build --root test3 @foo
Entering directory 'test3'
Leaving directory 'test3'

$ cat test3/foo.txt
Foo
Expand All @@ -58,6 +62,7 @@ Test external paths:
> EOF
$ dune build --root test4 $(basename $P)
Entering directory 'test4'
Leaving directory 'test4'
$ cat test4/_build/default/$(basename $P)
Hola

Expand All @@ -75,12 +80,14 @@ Test (enabled_if ...)
> EOF
$ dune build --root test5
Entering directory 'test5'
Leaving directory 'test5'
$ ls test5/_build/default | grep foo.txt
[1]
$ cat >test5/dune <<EOF
> (copy_files (enabled_if true) (files subdir/foo.txt))
> EOF
$ dune build --root test5
Entering directory 'test5'
Leaving directory 'test5'
$ ls test5/_build/default | grep foo.txt
foo.txt
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
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/dune-jbuild-var-case.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ All builtin variables are lower cased in Dune:

$ dune runtest --root dune-lower
Entering directory 'dune-lower'
Leaving directory 'dune-lower'

$ dune runtest --root dune-upper
Entering directory 'dune-upper'
Expand All @@ -10,4 +11,5 @@ All builtin variables are lower cased in Dune:
^^^^^^^
Error: %{MAKE} was renamed to '%{make}' in the 1.0 version of the dune
language
Leaving directory 'dune-upper'
[1]
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
Loading

0 comments on commit 8d1fcc9

Please sign in to comment.