aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-01-31 18:27:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-02-02 13:43:02 +0300
commitc77d65b4472ef0e2734ffde5556e279e62bb964a (patch)
treee24d4b47690c6a9e8649ef8cfe7a85a57499635d
parentc835121db614efa56093dde7a1557372a43ab09b (diff)
Add support for enable clause in tests package manifest value
-rw-r--r--bpkg/package.hxx2
-rw-r--r--bpkg/package.xml6
-rw-r--r--bpkg/rep-fetch.cxx2
-rw-r--r--doc/manual.cli63
-rw-r--r--tests/common/satisfy/t10/libbar-baz-1.0.0.tar.gzbin0 -> 399 bytes
-rw-r--r--tests/common/satisfy/t10/libbar-foo-1.0.0.tar.gzbin0 -> 401 bytes
-rw-r--r--tests/common/satisfy/t10/libbar-tests-1.0.0.tar.gzbin0 -> 632 bytes
-rw-r--r--tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gzbin413 -> 492 bytes
-rw-r--r--tests/pkg-build.testscript156
9 files changed, 215 insertions, 14 deletions
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 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="sqlite" version="1">
+ <changeset version="26">
+ <alter-table name="main.available_package_tests">
+ <add-column name="test_enable" type="TEXT" null="true"/>
+ </alter-table>
+ </changeset>
+
<changeset version="25">
<alter-table name="main.selected_package_prerequisites">
<drop-column name="config_dependency_index"/>
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]: [*] <name> [<version-constraint>]
-[examples]: [*] <name> [<version-constraint>]
-[benchmarks]: [*] <name> [<version-constraint>]
+[tests]: [*] <package> ['?' <enable-cond>] [<reflect-var>]
+[examples]: [*] <package> ['?' <enable-cond>] [<reflect-var>]
+[benchmarks]: [*] <package> ['?' <enable-cond>] [<reflect-var>]
+
+<package> = <name> [<version-constraint>]
+<enable-cond> = '(' <buildfile-eval-expr> ')'
+<reflect-var> = <config-var> '=' <value>
\
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
--- /dev/null
+++ b/tests/common/satisfy/t10/libbar-baz-1.0.0.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/common/satisfy/t10/libbar-foo-1.0.0.tar.gz
Binary files 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
--- /dev/null
+++ b/tests/common/satisfy/t10/libbar-tests-1.0.0.tar.gz
Binary files 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
--- a/tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gz
+++ b/tests/common/satisfy/t10/libfoo-tests-1.0.0.tar.gz
Binary files 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