Skip to content

Commit

Permalink
fix(install): respect display options
Browse files Browse the repository at this point in the history
<!-- ps-id: e2cecc12-1609-4398-97d1-1d56cdbcfd8d -->

Signed-off-by: Ali Caglayan <[email protected]>
  • Loading branch information
Alizter committed Feb 21, 2023
1 parent 8d552d3 commit 30d2542
Show file tree
Hide file tree
Showing 43 changed files with 125 additions and 95 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Unreleased
- Invoke preprocessor commands from directory of dune file containing the
commands rather than from the workspace root (#7057, fixes #7043, @gridbugs)

- dune install now respects --display=quiet mode (#7116, fixes #4573, fixes
#7106, @Alizter)

3.7.0 (2023-02-17)
------------------

Expand Down
7 changes: 5 additions & 2 deletions bin/install_uninstall.ml
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,11 @@ let install_uninstall ~what =
| true ->
Ops.remove_dir_if_exists ~if_non_empty:Fail dst
| false -> Ops.remove_file_if_exists dst);
print_line "%s %s" msg
(Path.to_string_maybe_quoted dst);
(match config.display.verbosity with
| Quiet -> ()
| _ ->
print_line "%s %s" msg
(Path.to_string_maybe_quoted dst));
Ops.mkdir_p dir;
let executable =
Section.should_set_executable_bit entry.section
Expand Down
6 changes: 3 additions & 3 deletions otherlibs/build-info/test/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Test embedding of build information
> EOF

$ dune build
$ dune install --prefix _install 2> /dev/null
$ dune install --prefix _install

Inside _build, we have no version information:

Expand Down Expand Up @@ -130,7 +130,7 @@ craft an example with a single placeholder to make the output stable:
$ cp c/c.ml d/d.ml

$ dune build d/d.install
$ dune install d --prefix _install --debug-artifact-substitution 2>&1|grep -v '^\(Installing\|Deleting\)'
$ dune install d --prefix _install --debug-artifact-substitution
Found placeholder in _build/install/default/bin/d:
- placeholder: Vcs_describe In_source_tree "d"
- evaluates to: "1.0+d"
Expand All @@ -149,7 +149,7 @@ Version is picked from dune-project if available

$ echo '(version project-version)' >> c/dune-project
$ dune build
$ dune install --prefix _install 2> /dev/null
$ dune install --prefix _install
$ _install/bin/c | sed 's/build-info: .*/build-info: XXX/'
project-version
lib a: 1.0+a
Expand Down
3 changes: 0 additions & 3 deletions otherlibs/site/test/github4389.t/run.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
$ dune build @install
$ dune install --prefix _install
Installing _install/lib/github4389/META
Installing _install/lib/github4389/dune-package
Installing _install/bin/main
$ grep sites _install/lib/github4389/dune-package
(sites (github4389 share))
$ grep -o '[^ ]*/_install/share/github4389' _install/lib/github4389/dune-package
Expand Down
3 changes: 0 additions & 3 deletions otherlibs/site/test/github4389_without_build_info.t/run.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
$ dune build @install
$ dune install --prefix _install
Installing _install/lib/github4389/META
Installing _install/lib/github4389/dune-package
Installing _install/bin/main
$ grep sites _install/lib/github4389/dune-package
(sites (github4389 share))
$ grep -o '[^ ]*/_install/share/github4389' _install/lib/github4389/dune-package
Expand Down
17 changes: 11 additions & 6 deletions otherlibs/site/test/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,18 @@ Test with an opam like installation
$ test -e a/a.install
[1]

$ dune install -p a --create-install-files a 2>&1 | sed -e "/^Copying/d"
$ dune install -p a --create-install-files a
Error: The mandir installation directory is unknown.
Hint: It could be specified with --mandir
[1]

$ grep "_destdir" a/a.install -c
7
grep: a/a.install: No such file or directory
[2]

$ grep "_build" a/a.install -c
12
grep: a/a.install: No such file or directory
[2]

Build everything
----------------
Expand All @@ -191,7 +196,7 @@ Build everything
Test with a normal installation
--------------------------------

$ dune install --prefix _install 2>&1 | sed -e "/^Installing/d"
$ dune install --prefix _install

Once installed, we have the sites information:

Expand All @@ -213,7 +218,7 @@ Once installed, we have the sites information:
Test with a relocatable installation
--------------------------------

$ dune install --prefix _install_relocatable --relocatable 2>&1 | sed -e "/^Installing/d"
$ dune install --prefix _install_relocatable --relocatable

Once installed, we have the sites information:

Expand Down Expand Up @@ -354,7 +359,7 @@ Test compiling an external plugin
info.txt is found: true
run c: registered:e,b.

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

$ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/c
run a
Expand Down
17 changes: 11 additions & 6 deletions otherlibs/site/test/run_2_9.t
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,18 @@ Test with an opam like installation
$ test -e a/a.install
[1]

$ dune install -p a --create-install-files a 2> /dev/null
$ dune install -p a --create-install-files a
Error: The mandir installation directory is unknown.
Hint: It could be specified with --mandir
[1]

$ grep "_destdir" a/a.install -c
7
grep: a/a.install: No such file or directory
[2]

$ grep "_build" a/a.install -c
12
grep: a/a.install: No such file or directory
[2]

Build everything
----------------
Expand All @@ -179,7 +184,7 @@ Build everything
Test with a normal installation
--------------------------------

$ dune install --prefix _install 2> /dev/null
$ dune install --prefix _install

Once installed, we have the sites information:

Expand All @@ -198,7 +203,7 @@ Once installed, we have the sites information:
Test with a relocatable installation
--------------------------------

$ dune install --prefix _install_relocatable --relocatable 2> /dev/null
$ dune install --prefix _install_relocatable --relocatable

Once installed, we have the sites information:

Expand Down Expand Up @@ -339,7 +344,7 @@ Test compiling an external plugin
info.txt is found: true
run c: registered:e,b.

$ OCAMLPATH=$PWD/_install/lib:$OCAMLPATH dune install --root=e --prefix $PWD/_install 2> /dev/null
$ OCAMLPATH=$PWD/_install/lib:$OCAMLPATH dune install --root=e --prefix $PWD/_install

$ OCAMLPATH=_install/lib:$OCAMLPATH _install/bin/c
run a
Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/depend-on/installed-packages.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Entering directory 'a'
Leaving directory 'a'

$ dune install --root a --prefix $PWD/prefix
$ dune install --root a --prefix $PWD/prefix --display short
Installing $TESTCASE_ROOT/prefix/lib/a/META
Installing $TESTCASE_ROOT/prefix/lib/a/dune-package
Installing $TESTCASE_ROOT/prefix/share/a/CATME
Expand Down Expand Up @@ -51,7 +51,7 @@
Entering directory 'a'
Leaving directory 'a'

$ dune install --root a --prefix $PWD/prefix
$ dune install --root a --prefix $PWD/prefix --display short
Deleting $TESTCASE_ROOT/prefix/lib/a/META
Installing $TESTCASE_ROOT/prefix/lib/a/META
Deleting $TESTCASE_ROOT/prefix/lib/a/dune-package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tests that the "old_public_name" field is evaluated lazily

$ (cd a
> dune build @install --root .
> dune install --prefix $PWD/../_install)
> dune install --prefix $PWD/../_install --display short)
Installing $TESTCASE_ROOT/a/../_install/lib/a/META
Installing $TESTCASE_ROOT/a/../_install/lib/a/dune-package

Expand All @@ -68,7 +68,7 @@ deprecated library will be resolved in the installed world only.

$ (cd b
> dune build @install --root .
> dune install --prefix $PWD/../_install 2>&1 | dune_cmd sanitize)
> dune install --prefix $PWD/../_install 2>&1 --display short | dune_cmd sanitize)
Installing $TESTCASE_ROOT/b/../_install/lib/b/META
Installing $TESTCASE_ROOT/b/../_install/lib/b/b$ext_lib
Installing $TESTCASE_ROOT/b/../_install/lib/b/b.cma
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Allow directories to be installable
]

$ mkdir ./installation
$ dune install --prefix ./installation
$ dune install --prefix ./installation --display short
Installing installation/lib/foo/META
Installing installation/lib/foo/dune-package
Installing installation/lib/foo/renamed/x
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/dune-package.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Build with "DUNE_STORE_ORIG_SOURCE_DIR=true" profile

Install the package directly

$ dune install "--prefix=$PWD/prefix" --root=a 2>&1 | grep -v "Installing"
$ dune install "--prefix=$PWD/prefix" --root=a
[1]

$ dune_cmd cat prefix/lib/a/dune-package | grep -e 'lib/a' -e 'share/a'
Expand Down
3 changes: 2 additions & 1 deletion test/blackbox-tests/test-cases/foreign-library.t
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,8 @@ Testsuite for the (foreign_library ...) stanza.

$ rm -rf _build
$ touch external/external_library.opam
$ ( cd external && ../sdune build @install && ../sdune install --prefix install 2>&1 | dune_cmd sanitize )
$ ( cd external && ../sdune build @install \
> && ../sdune install --prefix install --display=short 2>&1 | dune_cmd sanitize )
Installing install/lib/external_library/META
Installing install/lib/external_library/correction.h
Installing install/lib/external_library/dune-package
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/github2228.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ would fail because the .cmi wasn't correctly copied to the _build/install dir.
$ dune build @install
$ dune runtest
testing
$ dune install --prefix ./installed 2>&1 | grep -i cmi
$ dune install --prefix ./installed --display short 2>&1 | grep -i cmi
Installing installed/lib/foobar/foobar.cmi
Installing installed/lib/foobar/impl/foobar.cmi
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/github2629.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$ export DUNE_BUILD_DIR=$(mktemp -d -t github2629XXXXXX);
> dune build @install;
> cat $DUNE_BUILD_DIR/default/foo.install | sed s#$DUNE_BUILD_DIR#DUNE_BUILD_DIR#g;
> dune install --dry-run 2>&1 | awk '/Internal/,/External/'
> dune install --dry-run
lib: [
"DUNE_BUILD_DIR/install/default/lib/foo/META"
"DUNE_BUILD_DIR/install/default/lib/foo/dune-package"
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/github3727.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ visible regardless if the stanzas were filtered.

$ rm -rf _build
$ dune build -p foo
$ dune install foo --prefix ./_install
$ dune install foo --prefix ./_install --display=short
Installing _install/lib/foo/META
Installing _install/lib/foo/bar/private_foo.a
Installing _install/lib/foo/bar/private_foo.cma
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Then we install the backend and check that the "inline_tests.backend"
field is properly generated in the installed `dune-package` file:

$ dune build dune-file/foo.install
$ dune install foo --prefix _install 2> /dev/null
$ dune install foo --prefix _install
$ grep -A8 inline_tests.backend _install/lib/foo/dune-package
(inline_tests.backend
(runner_libraries str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
> EOF
$ dune build @install
$ mkdir install bindir sbindir
$ dune install --dry-run --prefix ./install --bindir $PWD/bindir --sbindir $PWD/sbindir 2>&1 | grep bindir
$ dune install --dry-run --prefix ./install --bindir $PWD/bindir --sbindir $PWD/sbindir --display short 2>&1 | grep bindir
Removing (if it exists) $TESTCASE_ROOT/bindir/user
Installing $TESTCASE_ROOT/bindir/user
Creating directory $TESTCASE_ROOT/bindir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> EOF
$ dune build @install
$ mkdir install datadir
$ dune install --dry-run --prefix ./install --datadir $PWD/datadir 2>&1 | grep datadir
$ dune install --dry-run --prefix ./install --datadir $PWD/datadir --display short 2>&1 | grep datadir
Removing (if it exists) $TESTCASE_ROOT/datadir/foo/datafile
Installing $TESTCASE_ROOT/datadir/foo/datafile
Creating directory $TESTCASE_ROOT/datadir/foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> EOF
$ dune build @install
$ mkdir install docdir
$ dune install --dry-run --prefix ./install --docdir $PWD/docdir 2>&1 | grep docdir
$ dune install --dry-run --prefix ./install --docdir $PWD/docdir --display short 2>&1 | grep docdir
Removing (if it exists) $TESTCASE_ROOT/docdir/foo/docfile
Installing $TESTCASE_ROOT/docdir/foo/docfile
Creating directory $TESTCASE_ROOT/docdir/foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> EOF
$ dune build @install
$ mkdir install etcdir
$ dune install --dry-run --prefix ./install --etcdir $PWD/etcdir 2>&1 | grep etcdir
$ dune install --dry-run --prefix ./install --etcdir $PWD/etcdir --display short 2>&1 | grep etcdir
Removing (if it exists) $TESTCASE_ROOT/etcdir/foo/configfile
Installing $TESTCASE_ROOT/etcdir/foo/configfile
Creating directory $TESTCASE_ROOT/etcdir/foo
Expand Down
20 changes: 10 additions & 10 deletions test/blackbox-tests/test-cases/install-dir/install-libdir.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
`dune install` should handle destination directories that don't exist

$ dune build @install
$ dune install --prefix install --libdir $PWD/install/lib 2>&1 | dune_cmd sanitize
$ dune install --prefix install --libdir $PWD/install/lib --display short 2>&1 | dune_cmd sanitize
Installing $TESTCASE_ROOT/install/lib/foo/META
Installing $TESTCASE_ROOT/install/lib/foo/dune-package
Installing $TESTCASE_ROOT/install/lib/foo/foo$ext_lib
Expand All @@ -22,7 +22,7 @@
Installing install/man/man3/another-man-page.3

Even if it is possible to ask for different libexecdir than libdir, the installed .cmxs will not be found
$ dune install --prefix install2 --libdir $PWD/install2/lib --libexecdir $PWD/install2/libexec 2>&1 | dune_cmd sanitize
$ dune install --prefix install2 --libdir $PWD/install2/lib --libexecdir $PWD/install2/libexec --display short 2>&1 | dune_cmd sanitize
Installing $TESTCASE_ROOT/install2/lib/foo/META
Installing $TESTCASE_ROOT/install2/lib/foo/dune-package
Installing $TESTCASE_ROOT/install2/lib/foo/foo$ext_lib
Expand All @@ -41,7 +41,7 @@ Even if it is possible to ask for different libexecdir than libdir, the installe

If prefix is passed, the default for libdir is `$prefix/lib`:

$ dune install --prefix install --dry-run 2>&1 | dune_cmd sanitize
$ dune install --prefix install --dry-run --display short 2>&1 | dune_cmd sanitize
Removing (if it exists) install/lib/foo/META
Installing install/lib/foo/META
Creating directory install/lib/foo
Expand Down Expand Up @@ -106,8 +106,8 @@ If prefix is passed, the default for libdir is `$prefix/lib`:
If prefix is not passed, libdir defaults to the opam-prefix/lib directory:

$ (export OCAMLFIND_DESTDIR=/OCAMLFIND_DESTDIR
> dune install --dry-run 2>&1 | dune_cmd sanitize
> dune uninstall --dry-run 2>&1 | dune_cmd sanitize)
> dune install --dry-run --display short 2>&1 | dune_cmd sanitize
> dune uninstall --dry-run --display short 2>&1 | dune_cmd sanitize)
Removing (if it exists) /OPAM_PREFIX/lib/foo/META
Installing /OPAM_PREFIX/lib/foo/META
Creating directory /OPAM_PREFIX/lib/foo
Expand Down Expand Up @@ -192,8 +192,8 @@ If prefix is not passed, libdir defaults to the opam-prefix/lib directory:
If only libdir is passed, binaries are installed under prefix/bin and libraries
in libdir:

$ dune install --libdir /LIBDIR --dry-run 2>&1 | dune_cmd sanitize
> dune uninstall --libdir /LIBDIR --dry-run
$ dune install --libdir /LIBDIR --dry-run --display short 2>&1 | dune_cmd sanitize
> dune uninstall --libdir /LIBDIR --dry-run --display short
Removing (if it exists) /LIBDIR/foo/META
Installing /LIBDIR/foo/META
Creating directory /LIBDIR/foo
Expand Down Expand Up @@ -278,7 +278,7 @@ in libdir:
The DESTDIR var is supported. When set, it is prepended to the prefix.
This is the case when the prefix is implicit:

$ DESTDIR=DESTDIR dune install --dry-run 2>&1 | dune_cmd sanitize
$ DESTDIR=DESTDIR dune install --dry-run --display short 2>&1 | dune_cmd sanitize
Removing (if it exists) DESTDIR/OPAM_PREFIX/lib/foo/META
Installing DESTDIR/OPAM_PREFIX/lib/foo/META
Creating directory DESTDIR/OPAM_PREFIX/lib/foo
Expand Down Expand Up @@ -342,7 +342,7 @@ This is the case when the prefix is implicit:

But also when the prefix is explicit:

$ DESTDIR=DESTDIR dune install --prefix prefix --dry-run 2>&1 | dune_cmd sanitize
$ DESTDIR=DESTDIR dune install --prefix prefix --dry-run --display short 2>&1 | dune_cmd sanitize
Removing (if it exists) DESTDIR/prefix/lib/foo/META
Installing DESTDIR/prefix/lib/foo/META
Creating directory DESTDIR/prefix/lib/foo
Expand Down Expand Up @@ -406,7 +406,7 @@ But also when the prefix is explicit:

DESTDIR can also be passed as a command line flag.

$ dune install --destdir DESTDIR --prefix prefix --dry-run 2>&1 | dune_cmd sanitize
$ dune install --destdir DESTDIR --prefix prefix --dry-run --display short 2>&1 | dune_cmd sanitize
Removing (if it exists) DESTDIR/prefix/lib/foo/META
Installing DESTDIR/prefix/lib/foo/META
Creating directory DESTDIR/prefix/lib/foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> EOF
$ dune build @install
$ mkdir install mandir
$ dune install --dry-run --prefix ./install --mandir $PWD/mandir 2>&1 | grep mandir
$ dune install --dry-run --prefix ./install --mandir $PWD/mandir --display short 2>&1 | grep mandir
Removing (if it exists) $TESTCASE_ROOT/mandir/manfile
Installing $TESTCASE_ROOT/mandir/manfile
Creating directory $TESTCASE_ROOT/mandir
Expand Down
Loading

0 comments on commit 30d2542

Please sign in to comment.