From 8d0af3dad70b29534525584b5d9894a696e7506f Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 25 Oct 2023 18:25:17 +0200 Subject: [PATCH 1/2] reftest: add undefined variable usage in assume built test --- master_changes.md | 1 + tests/reftests/assume-built.test | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/master_changes.md b/master_changes.md index 5208994bd3f..12211966a7d 100644 --- a/master_changes.md +++ b/master_changes.md @@ -119,6 +119,7 @@ users) * dot-install: generalise inner script & use less generic filenames [#5691 @rjbou] * dot-install: add a test for removal of non specified in .install empty directories [#5701 @rjbou] * Add test in assume-built for depends with switch variable filters [#5700 @rjbou] + * Add undefined variable handling in assume built test [#5701 @rjbou] ### Engine * With real path resolved for all opam temp dir, remove `/private` from mac temp dir regexp [#5654 @rjbou] diff --git a/tests/reftests/assume-built.test b/tests/reftests/assume-built.test index df81624afae..d6ebe71c66a 100644 --- a/tests/reftests/assume-built.test +++ b/tests/reftests/assume-built.test @@ -225,3 +225,44 @@ The following actions will be performed: -> installed ongoing.1.0 Done. ### test -f ./ongoing/installed +### : assume built & undefined opam file variables : +### OPAMSTRICT=0 +### opam unpin ongoing +Ok, ongoing is no longer pinned to git+file://${BASEDIR}/ongoing#master (version 1.0) +The following actions will be performed: +=== remove 1 package + - remove ongoing 1.0 + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> removed ongoing.1.0 +Done. +### +opam-version: "2.0" +depends: [ + "qux" + "foo" { not-defined } +] +build: [ + [ "test" "-f" "ongoing.txt" ] + [ "sh" "-c" "cat ongoing.txt > out" ] +] +install: [ + [ "test" "-f" "out" ] + [ "test" "-f" "out2" ] { not-defined } + [ "touch" "installed"] +] +### git -C ongoing clean -fdqx +### opam pin ./ongoing -n +Package ongoing does not exist, create as a NEW package? [y/n] y +ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version dev) +### touch ongoing/out +### opam install ongoing --assume-built --with-test + +<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><> +[NOTE] Ignoring uncommitted changes in ${BASEDIR}/ongoing (`--working-dir' not specified or specified with no argument). +[ongoing.dev] synchronised (no changes) + +Fatal error: Undefined boolean filter value: not-defined +# Return code 99 # +### test -f ./ongoing/installed +# Return code 1 # From adc0b99f86116a320a3d4f68c5be0a852c2dc168 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Mon, 16 Oct 2023 10:36:54 +0200 Subject: [PATCH 2/2] check install: undefined variable default to false --- master_changes.md | 1 + src/client/opamClient.ml | 2 +- tests/reftests/assume-built.test | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/master_changes.md b/master_changes.md index 12211966a7d..b3798a7fc80 100644 --- a/master_changes.md +++ b/master_changes.md @@ -27,6 +27,7 @@ users) ## Install * [BUG] On install driven by `.install` file, track intermediate directories too, in order to have them suppressed at package removal [#5691 @rjbou - fix #5688] * [BUG] With `--assume-built`, resolve variables in depends filter according switch & global environment, not only depends predefined variables [#570 @rjbou - fix #5698] + * [BUG] Handle undefined variables defaults to false in dependencies formula resolution for assume built [#5701 rjbou] ## Remove diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index cd2863966ad..7d44490cf71 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -1096,7 +1096,7 @@ let check_installed ~build ~post t atoms = let cnf_formula = OpamSwitchState.opam t pkg |> OpamFile.OPAM.depends - |> OpamFilter.filter_formula (env pkg) + |> OpamFilter.filter_formula ~default:false (env pkg) |> OpamFormula.to_cnf in let missing_conj = diff --git a/tests/reftests/assume-built.test b/tests/reftests/assume-built.test index d6ebe71c66a..ee021b5f611 100644 --- a/tests/reftests/assume-built.test +++ b/tests/reftests/assume-built.test @@ -262,7 +262,12 @@ ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version dev) [NOTE] Ignoring uncommitted changes in ${BASEDIR}/ongoing (`--working-dir' not specified or specified with no argument). [ongoing.dev] synchronised (no changes) -Fatal error: Undefined boolean filter value: not-defined -# Return code 99 # +The following actions will be performed: +=== install 1 package + - install ongoing dev (pinned) + +<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><> +-> retrieved ongoing.dev (no changes) +-> installed ongoing.dev +Done. ### test -f ./ongoing/installed -# Return code 1 #