From c77d65b4472ef0e2734ffde5556e279e62bb964a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 31 Jan 2024 18:27:27 +0300 Subject: Add support for enable clause in tests package manifest value --- bpkg/package.hxx | 2 +- bpkg/package.xml | 6 + bpkg/rep-fetch.cxx | 2 +- doc/manual.cli | 63 +++++++-- tests/common/satisfy/t10/libbar-baz-1.0.0.tar.gz | Bin 0 -> 399 bytes tests/common/satisfy/t10/libbar-foo-1.0.0.tar.gz | Bin 0 -> 401 bytes tests/common/satisfy/t10/libbar-tests-1.0.0.tar.gz | Bin 0 -> 632 bytes tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gz | Bin 413 -> 492 bytes tests/pkg-build.testscript | 156 ++++++++++++++++++++- 9 files changed, 215 insertions(+), 14 deletions(-) create mode 100644 tests/common/satisfy/t10/libbar-baz-1.0.0.tar.gz create mode 100644 tests/common/satisfy/t10/libbar-foo-1.0.0.tar.gz create mode 100644 tests/common/satisfy/t10/libbar-tests-1.0.0.tar.gz diff --git a/bpkg/package.hxx b/bpkg/package.hxx index 8f4b46c..6577b18 100644 --- a/bpkg/package.hxx +++ b/bpkg/package.hxx @@ -32,7 +32,7 @@ // #define DB_SCHEMA_VERSION_BASE 12 -#pragma db model version(DB_SCHEMA_VERSION_BASE, 25, closed) +#pragma db model version(DB_SCHEMA_VERSION_BASE, 26, closed) namespace bpkg { diff --git a/bpkg/package.xml b/bpkg/package.xml index 07595af..8020ff3 100644 --- a/bpkg/package.xml +++ b/bpkg/package.xml @@ -1,4 +1,10 @@ + + + + + + diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx index d7f4cc6..4f7dbcc 100644 --- a/bpkg/rep-fetch.cxx +++ b/bpkg/rep-fetch.cxx @@ -1707,7 +1707,7 @@ namespace bpkg << package_string (p->id.name, p->version); } - dependency_alternative da (nullopt /* enable */, + dependency_alternative da (td.enable, td.reflect, nullopt /* prefer */, nullopt /* accept */, diff --git a/doc/manual.cli b/doc/manual.cli index 999d924..99e3caa 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -2142,9 +2142,13 @@ configuration. See the \l{bbot \c{bbot} documentation} for details. \h2#manifest-package-tests-examples-benchmarks|\c{tests}, \c{examples}, \c{benchmarks}| \ -[tests]: [*] [] -[examples]: [*] [] -[benchmarks]: [*] [] +[tests]: [*] ['?' ] [] +[examples]: [*] ['?' ] [] +[benchmarks]: [*] ['?' ] [] + + = [] + = '(' ')' + = '=' \ Separate tests, examples, and benchmarks packages. If the value starts with @@ -2163,7 +2167,7 @@ example: \ name: hello -tests : hello-tests +tests: hello-tests examples: hello-examples \ @@ -2176,18 +2180,57 @@ it can also be specified in terms of the primary package's version (see the tests: hello-tests ~$ \ -Note that normally the tests, etc., packages themselves do not have an -explicit dependency on the primary package (in a sense, the primary package -has a special dependency on them). They are also not built by automated build -bots separately from their primary package but may have their own build -constraints, for example, to be excluded from building on some platforms where -the primary package is still built, for example: +Note that normally the tests, etc., packages themselves (we'll call them all +test packages for short) do not have an explicit dependency on the primary +package (in a sense, the primary package has a special test dependency on +them). They are also not built by automated build bots separately from their +primary package but may have their own build constraints, for example, to be +excluded from building on some platforms where the primary package is still +built, for example: \ name: hello-tests builds: -windows \ +Also note that a test package may potentially be used as a test dependency for +multiple primary packages. In this case a primary package normally needs to +reflect to the test package the fact that it is the one being tested. This can +be achieved by setting the test package's configuration variable (see the +\l{#manifest-package-depends \c{depends}} value for details on +reflection). For example: + +\ +name: hello-foo +tests: hello-tests config.hello_tests.test=hello-foo + +name: hello-bar +tests: hello-tests config.hello_tests.test=hello-bar +\ + +If it is plausible that the test package may also be built explicitly, for +example, to achieve a more complicated setup (test multiple main packages +simultaneously, etc), then the test dependencies need to be made conditional +in the primary packages so that the explicit configuration is preferred over +the reflections (see the \l{#manifest-package-depends \c{depends}} value for +details on conditional dependencies). For example: + +\ +name: hello-foo +tests: hello-tests \ +? (!$defined(config.hello_tests.test)) config.hello_tests.test=hello-foo + +name: hello-bar +tests: hello-tests \ +? (!$defined(config.hello_tests.test)) config.hello_tests.test=hello-bar +\ + +Note that in contrast to the \l{#manifest-package-depends \c{depends}} value, +both the reflection and condition refer to the variables defined not by the +package which specifies the test dependency (primary package), but the package +such a dependency refers to (test package). + + \h2#manifest-package-builds|\c{builds}| \ diff --git a/tests/common/satisfy/t10/libbar-baz-1.0.0.tar.gz b/tests/common/satisfy/t10/libbar-baz-1.0.0.tar.gz new file mode 100644 index 0000000..9075ee4 Binary files /dev/null and b/tests/common/satisfy/t10/libbar-baz-1.0.0.tar.gz differ diff --git a/tests/common/satisfy/t10/libbar-foo-1.0.0.tar.gz b/tests/common/satisfy/t10/libbar-foo-1.0.0.tar.gz new file mode 100644 index 0000000..2dd5e69 Binary files /dev/null and b/tests/common/satisfy/t10/libbar-foo-1.0.0.tar.gz differ diff --git a/tests/common/satisfy/t10/libbar-tests-1.0.0.tar.gz b/tests/common/satisfy/t10/libbar-tests-1.0.0.tar.gz new file mode 100644 index 0000000..7f587d9 Binary files /dev/null and b/tests/common/satisfy/t10/libbar-tests-1.0.0.tar.gz differ diff --git a/tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gz b/tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gz index 594a9b8..bc58a14 100644 Binary files a/tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gz and b/tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gz differ diff --git a/tests/pkg-build.testscript b/tests/pkg-build.testscript index 9e25f5f..9d19846 100644 --- a/tests/pkg-build.testscript +++ b/tests/pkg-build.testscript @@ -251,9 +251,12 @@ # | `-- repositories.manifest # | # |-- t10 -# | |-- libfoo-bar-1.0.0.tar.gz -> libfoo-tests -# | |-- libfoo-baz-1.0.0.tar.gz -> libfoo-tests +# | |-- libfoo-bar-1.0.0.tar.gz (tests) -> libfoo-tests +# | |-- libfoo-baz-1.0.0.tar.gz (tests) -> libfoo-tests # | |-- libfoo-tests-1.0.0.tar.gz +# | |-- libbar-foo-1.0.0.tar.gz (tests) -> libbar-tests +# | |-- libbar-baz-1.0.0.tar.gz (tests) -> libbar-tests +# | |-- libbar-tests-1.0.0.tar.gz -> ? libbar-foo, ? libbar-baz # | `-- repositories.manifest # | # | NOTE: remember to update @@ -26379,6 +26382,155 @@ test.arguments += --sys-no-query info: while satisfying libfoo-tests/1.0.0 EOE } + + : reflection-foo + : + { + $clone_cfg; + + $* libbar-tests 2>>EOE != 0; + error: unable to select dependency alternative for package libbar-tests/1.0.0 + info: explicitly specify dependency packages to manually select the alternative + info: alternative: libbar-baz + info: alternative: libbar-foo + info: while satisfying libbar-tests/1.0.0 + EOE + + $* libbar-foo libbar-tests 2>>~%EOE%; + fetched libbar-foo/1.0.0 + unpacked libbar-foo/1.0.0 + fetched libbar-tests/1.0.0 + unpacked libbar-tests/1.0.0 + configured libbar-foo/1.0.0 + configured libbar-tests/1.0.0 + %info: .+libbar-foo-1.0.0.+ is up to date% + %info: .+libbar-tests-1.0.0.+ is up to date% + updated libbar-foo/1.0.0 + updated libbar-tests/1.0.0 + EOE + + cat cfg/libbar-tests-1.0.0/build/config.build >>~%EOO%; + %.* + config.libbar_tests.test = libbar-foo + %.* + EOO + + $* libbar-baz 2>>~%EOE%; + fetched libbar-baz/1.0.0 + unpacked libbar-baz/1.0.0 + configured libbar-baz/1.0.0 + %info: .+libbar-baz-1.0.0.+ is up to date% + updated libbar-baz/1.0.0 + EOE + + cat cfg/libbar-tests-1.0.0/build/config.build >>~%EOO%; + %.* + config.libbar_tests.test = libbar-foo + %.* + EOO + + $pkg_status -r >>EOO; + !libbar-foo configured 1.0.0 + !libbar-tests configured 1.0.0 + !libbar-foo configured 1.0.0 + !libbar-baz configured 1.0.0 + EOO + + $pkg_drop libbar-foo libbar-baz libbar-tests + } + + : reflection-baz + : + { + $clone_cfg; + + $* libbar-baz libbar-tests 2>>~%EOE%; + fetched libbar-baz/1.0.0 + unpacked libbar-baz/1.0.0 + fetched libbar-tests/1.0.0 + unpacked libbar-tests/1.0.0 + configured libbar-baz/1.0.0 + configured libbar-tests/1.0.0 + %info: .+libbar-baz-1.0.0.+ is up to date% + %info: .+libbar-tests-1.0.0.+ is up to date% + updated libbar-baz/1.0.0 + updated libbar-tests/1.0.0 + EOE + + cat cfg/libbar-tests-1.0.0/build/config.build >>~%EOO%; + %.* + config.libbar_tests.test = libbar-baz + %.* + EOO + + $* libbar-foo 2>>~%EOE%; + fetched libbar-foo/1.0.0 + unpacked libbar-foo/1.0.0 + configured libbar-foo/1.0.0 + %info: .+libbar-foo-1.0.0.+ is up to date% + updated libbar-foo/1.0.0 + EOE + + cat cfg/libbar-tests-1.0.0/build/config.build >>~%EOO%; + %.* + config.libbar_tests.test = libbar-baz + %.* + EOO + + $pkg_status -r >>EOO; + !libbar-baz configured 1.0.0 + !libbar-tests configured 1.0.0 + !libbar-baz configured 1.0.0 + !libbar-foo configured 1.0.0 + EOO + + $pkg_drop libbar-baz libbar-foo libbar-tests + } + + : reflection-both + : + { + $clone_cfg; + + $* libbar-foo libbar-baz libbar-tests 2>!; + + cat cfg/libbar-tests-1.0.0/build/config.build >>~%EOO%; + %.* + config.libbar_tests.test = libbar-baz + %.* + EOO + + $pkg_status -r >>EOO; + !libbar-foo configured 1.0.0 + !libbar-baz configured 1.0.0 + !libbar-tests configured 1.0.0 + !libbar-baz configured 1.0.0 + EOO + + $pkg_drop libbar-foo libbar-baz libbar-tests + } + + : configure-explicit + : + { + $clone_cfg; + + $* --yes "config.libbar_tests.test = libbar-foo libbar-baz" -- libbar-tests 2>!; + + cat cfg/libbar-tests-1.0.0/build/config.build >>~%EOO%; + %.* + config.libbar_tests.test = libbar-foo libbar-baz + %.* + EOO + + $pkg_status -r >>EOO; + !libbar-tests configured 1.0.0 + libbar-baz configured 1.0.0 + libbar-foo configured 1.0.0 + EOO + + $pkg_drop libbar-tests + } } : dependent -- cgit v1.1