Skip to content
New issue

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

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

Already on GitHub? # to your account

Add --with-tools test, resolve for post messages #5160

Merged
merged 4 commits into from
Aug 6, 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
2 changes: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ users)
* [BUG] Prevent `.changes` files from being updated during dry-run [#5144 @na4zagin3 - fix #5132]
* Log a summary of recorded `.changes` as a `ACTION` trace log to help debug #4419 [#5144 @na4zagin3]
* ◈ Add `--with-tools` option to install recommended development tools from opam file (as `with-test`/`with-doc`), and its environment variable `OPAMWITHTOOLS` [#5016 @rjbou]
* Resolve `with-tools` for post messages too [#5160 @rjbou]

## Remove
*
Expand Down Expand Up @@ -310,6 +311,7 @@ users)
* Add test for opam file write with format preserved bug in #4936, fixed in #4941 [#4159 @rjbou]
* Add test for switch upgrade from 2.0 root, with pinned compiler [#5176 @rjbou @kit-ty-kate]
* Add switch import (for pinned packages) test [#5181 @rjbou]
* Add `--with-tools` test [#5160 @rjbou]
### Engine
* Add `opam-cat` to normalise opam file printing [#4763 @rjbou @dra27] [2.1.0~rc2 #4715]
* Fix meld reftest: open only with failing ones [#4913 @rjbou]
Expand Down
4 changes: 4 additions & 0 deletions src/client/opamSolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ let post_message ?(failed=false) st action =
OpamVariable.Map.add (OpamVariable.of_string "failure")
(Some (B failed)) local_variables
in
let local_variables =
OpamVariable.Map.add (OpamVariable.of_string "with-tools")
(Some (B OpamStateConfig.(!r.with_tools))) local_variables
in
let messages =
let filter_env = OpamPackageVar.resolve ~opam ~local:local_variables st in
(if OpamFile.OPAM.has_flag Pkgflag_Deprecated opam then
Expand Down
17 changes: 17 additions & 0 deletions tests/reftests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,23 @@
%{targets}
(run ./run.exe %{bin:opam} %{dep:var-option.test} %{read-lines:testing-env}))))

(rule
(alias reftest-with-tools)
(action
(diff with-tools.test with-tools.out)))

(alias
(name reftest)
(deps (alias reftest-with-tools)))

(rule
(targets with-tools.out)
(deps root-N0REP0)
(action
(with-stdout-to
%{targets}
(run ./run.exe %{bin:opam} %{dep:with-tools.test} %{read-lines:testing-env}))))

(rule
(alias reftest-working-dir)
(action
Expand Down
58 changes: 58 additions & 0 deletions tests/reftests/with-tools.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
N0REP0
### <pkg:a.1>
opam-version: "2.0"
depends: [ "b" "tool" {with-tools} ]
build: [ [ "touch" "one" ] [ "touch" "two" ] {with-tools} ]
install: [ [ "cp" "one" "%{lib}%" ] [ "cp" "two" "%{lib}%" ] {with-tools} ]
post-messages:
[ "Thanks for installing the packages"
"and its tool dependencies too" {with-tools} ]
### <pkg:b.1>
opam-version: "2.0"
### <pkg:tool.1>
opam-version: "2.0"
### OPAMYES=1
### opam switch create tooling --empty
### opam install a
The following actions will be performed:
=== install 2 packages
- install a 1
- install b 1 [required by a]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed b.1
-> installed a.1
Done.

<><> a.1 installed successfully <><><><><><><><><><><><><><><><><><><><><><><><>
=> Thanks for installing the packages
### opam list a --column=installed-files
# Packages matching: name-match(a) & (installed | available)
# Installed files
${BASEDIR}/OPAM/tooling/lib/one
### opam remove a
The following actions will be performed:
=== remove 1 package
- remove a 1

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> removed a.1
Done.
### opam install a --with-tools
The following actions will be performed:
=== install 2 packages
- install a 1
- install tool 1 [required by a]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed tool.1
-> installed a.1
Done.

<><> a.1 installed successfully <><><><><><><><><><><><><><><><><><><><><><><><>
=> Thanks for installing the packages
=> and its tool dependencies too
### opam list a --column=installed-files
# Packages matching: name-match(a) & (installed | available)
# Installed files
${BASEDIR}/OPAM/tooling/lib/one ${BASEDIR}/OPAM/tooling/lib/two