aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbrep/build-extra.sql64
-rw-r--r--libbrep/build-package.hxx16
-rw-r--r--libbrep/build.hxx2
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/package.cxx6
-rw-r--r--libbrep/package.hxx43
-rw-r--r--libbrep/package.xml74
-rw-r--r--load/load.cxx65
-rw-r--r--migrate/migrate.cxx11
-rw-r--r--mod/mod-build-task.cxx53
-rw-r--r--mod/mod-package-version-details.cxx51
-rw-r--r--tests/load/driver.cxx2
12 files changed, 219 insertions, 170 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index b466382..a61f415 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -10,10 +10,6 @@ DROP FOREIGN TABLE IF EXISTS build_package_constraints;
DROP FOREIGN TABLE IF EXISTS build_package_builds;
-DROP FOREIGN TABLE IF EXISTS build_package_benchmarks;
-
-DROP FOREIGN TABLE IF EXISTS build_package_examples;
-
DROP FOREIGN TABLE IF EXISTS build_package_tests;
DROP FOREIGN TABLE IF EXISTS build_package;
@@ -22,6 +18,12 @@ DROP FOREIGN TABLE IF EXISTS build_repository;
DROP FOREIGN TABLE IF EXISTS build_tenant;
+-- @@ TMP Also drop tables that are removed in 12 schema version. Drop these
+-- statements after 0.13.0 is released.
+--
+DROP FOREIGN TABLE IF EXISTS build_package_benchmarks;
+DROP FOREIGN TABLE IF EXISTS build_package_examples;
+
-- The foreign table for build_tenant object.
--
CREATE FOREIGN TABLE build_tenant (
@@ -66,55 +68,15 @@ CREATE FOREIGN TABLE build_package_tests (
version_canonical_release TEXT NOT NULL COLLATE "C",
version_revision INTEGER NOT NULL,
index BIGINT NOT NULL,
- dep_name CITEXT NOT NULL,
- dep_package_tenant TEXT NULL,
- dep_package_name CITEXT NULL,
- dep_package_version_epoch INTEGER NULL,
- dep_package_version_canonical_upstream TEXT NULL,
- dep_package_version_canonical_release TEXT NULL COLLATE "C",
- dep_package_version_revision INTEGER NULL)
+ test_name CITEXT NOT NULL,
+ test_package_tenant TEXT NULL,
+ test_package_name CITEXT NULL,
+ test_package_version_epoch INTEGER NULL,
+ test_package_version_canonical_upstream TEXT NULL,
+ test_package_version_canonical_release TEXT NULL COLLATE "C",
+ test_package_version_revision INTEGER NULL)
SERVER package_server OPTIONS (table_name 'package_tests');
--- The foreign table for the build_package object examples member (that is of a
--- container type).
---
-CREATE FOREIGN TABLE build_package_examples (
- tenant TEXT NOT NULL,
- name CITEXT NOT NULL,
- version_epoch INTEGER NOT NULL,
- version_canonical_upstream TEXT NOT NULL,
- version_canonical_release TEXT NOT NULL COLLATE "C",
- version_revision INTEGER NOT NULL,
- index BIGINT NOT NULL,
- dep_name CITEXT NOT NULL,
- dep_package_tenant TEXT NULL,
- dep_package_name CITEXT NULL,
- dep_package_version_epoch INTEGER NULL,
- dep_package_version_canonical_upstream TEXT NULL,
- dep_package_version_canonical_release TEXT NULL COLLATE "C",
- dep_package_version_revision INTEGER NULL)
-SERVER package_server OPTIONS (table_name 'package_examples');
-
--- The foreign table for the build_package object benchmarks member (that is
--- of a container type).
---
-CREATE FOREIGN TABLE build_package_benchmarks (
- tenant TEXT NOT NULL,
- name CITEXT NOT NULL,
- version_epoch INTEGER NOT NULL,
- version_canonical_upstream TEXT NOT NULL,
- version_canonical_release TEXT NOT NULL COLLATE "C",
- version_revision INTEGER NOT NULL,
- index BIGINT NOT NULL,
- dep_name CITEXT NOT NULL,
- dep_package_tenant TEXT NULL,
- dep_package_name CITEXT NULL,
- dep_package_version_epoch INTEGER NULL,
- dep_package_version_canonical_upstream TEXT NULL,
- dep_package_version_canonical_release TEXT NULL COLLATE "C",
- dep_package_version_revision INTEGER NULL)
-SERVER package_server OPTIONS (table_name 'package_benchmarks');
-
-- The foreign table for the build_package object builds member (that is of a
-- container type).
--
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 228c5c0..09ec41d 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -72,10 +72,10 @@ namespace brep
//
class build_package;
- // Build package test dependency.
+ // Build package external test dependency.
//
#pragma db value
- struct build_dependency
+ struct build_test_dependency
{
package_name name;
lazy_shared_ptr<build_package> package;
@@ -90,12 +90,10 @@ namespace brep
package_id id;
upstream_version version;
- // Mapped to the package object tests, examples, and benchmarks members
- // using the PostgreSQL foreign table mechanism.
+ // Mapped to the package object tests member using the PostgreSQL foreign
+ // table mechanism.
//
- small_vector<build_dependency, 1> tests;
- small_vector<build_dependency, 1> examples;
- small_vector<build_dependency, 1> benchmarks;
+ small_vector<build_test_dependency, 1> tests;
lazy_shared_ptr<build_repository> internal_repository;
bool buildable;
@@ -117,9 +115,7 @@ namespace brep
//
#pragma db member(id) id column("")
#pragma db member(version) set(this.version.init (this.id.version, (?)))
- #pragma db member(tests) id_column("") value_column("dep_")
- #pragma db member(examples) id_column("") value_column("dep_")
- #pragma db member(benchmarks) id_column("") value_column("dep_")
+ #pragma db member(tests) id_column("") value_column("test_")
#pragma db member(builds) id_column("") value_column("")
#pragma db member(constraints) id_column("") value_column("")
diff --git a/libbrep/build.hxx b/libbrep/build.hxx
index a883fa0..1041805 100644
--- a/libbrep/build.hxx
+++ b/libbrep/build.hxx
@@ -25,7 +25,7 @@
//
#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 9
-#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 11, closed)
+#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 12, closed)
// We have to keep these mappings at the global scope instead of inside
// the brep namespace because they need to be also effective in the
diff --git a/libbrep/build.xml b/libbrep/build.xml
index f4ba6cb..03d60e7 100644
--- a/libbrep/build.xml
+++ b/libbrep/build.xml
@@ -1,4 +1,6 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="12"/>
+
<changeset version="11"/>
<changeset version="10">
diff --git a/libbrep/package.cxx b/libbrep/package.cxx
index 5ec1b69..564fec7 100644
--- a/libbrep/package.cxx
+++ b/libbrep/package.cxx
@@ -72,9 +72,7 @@ namespace brep
optional<email_type> bee,
dependencies_type dp,
requirements_type rq,
- small_vector<dependency, 1> ts,
- small_vector<dependency, 1> es,
- small_vector<dependency, 1> bms,
+ small_vector<test_dependency, 1> ts,
build_class_exprs bs,
build_constraints_type bc,
optional<path> lc,
@@ -107,8 +105,6 @@ namespace brep
dependencies (move (dp)),
requirements (move (rq)),
tests (move (ts)),
- examples (move (es)),
- benchmarks (move (bms)),
builds (move (bs)),
build_constraints (move (bc)),
internal_repository (move (rp)),
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 0ab8413..e249573 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -20,7 +20,7 @@
//
#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 17
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 18, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 19, open)
namespace brep
{
@@ -181,6 +181,30 @@ namespace brep
#pragma db value(requirement_alternatives) definition
+ // tests
+ //
+ using bpkg::test_dependency_type;
+ using bpkg::to_test_dependency_type;
+
+ #pragma db map type(test_dependency_type) as(string) \
+ to(to_string (?)) \
+ from(brep::to_test_dependency_type (?))
+
+ #pragma db value
+ struct test_dependency: dependency
+ {
+ test_dependency_type type;
+
+ test_dependency () = default;
+ test_dependency (package_name n,
+ test_dependency_type t,
+ optional<version_constraint> c)
+ : dependency {std::move (n), std::move (c), nullptr /* package */},
+ type (t)
+ {
+ }
+ };
+
// certificate
//
#pragma db value
@@ -386,9 +410,7 @@ namespace brep
optional<email_type> build_error_email,
dependencies_type,
requirements_type,
- small_vector<dependency, 1> tests,
- small_vector<dependency, 1> examples,
- small_vector<dependency, 1> benchmarks,
+ small_vector<test_dependency, 1> tests,
build_class_exprs,
build_constraints_type,
optional<path> location,
@@ -459,9 +481,7 @@ namespace brep
optional<email_type> build_error_email;
dependencies_type dependencies;
requirements_type requirements;
- small_vector<dependency, 1> tests; // Note: foreign-mapped in build.
- small_vector<dependency, 1> examples; // Note: foreign-mapped in build.
- small_vector<dependency, 1> benchmarks; // Note: foreign-mapped in build.
+ small_vector<test_dependency, 1> tests; // Note: foreign-mapped in build.
build_class_exprs builds; // Note: foreign-mapped in build.
build_constraints_type build_constraints; // Note: foreign-mapped in build.
@@ -563,14 +583,9 @@ namespace brep
set(odb::nested_set (this.requirements, std::move (?))) \
id_column("") key_column("") value_column("id")
- // tests, examples, benchmarks
- //
- // Seeing that these reuse the dependency types, we are also going to
- // have identical database mapping.
+ // tests
//
- #pragma db member(tests) id_column("") value_column("dep_")
- #pragma db member(examples) id_column("") value_column("dep_")
- #pragma db member(benchmarks) id_column("") value_column("dep_")
+ #pragma db member(tests) id_column("") value_column("test_")
// builds
//
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 12ae36e..e650555 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,4 +1,78 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
+ <changeset version="19">
+ <alter-table name="package_tests">
+ <add-column name="test_name" type="CITEXT" null="false"/>
+ <add-column name="test_min_version_epoch" type="INTEGER" null="true"/>
+ <add-column name="test_min_version_canonical_upstream" type="TEXT" null="true"/>
+ <add-column name="test_min_version_canonical_release" type="TEXT" null="true"/>
+ <add-column name="test_min_version_revision" type="INTEGER" null="true"/>
+ <add-column name="test_min_version_upstream" type="TEXT" null="true"/>
+ <add-column name="test_min_version_release" type="TEXT" null="true"/>
+ <add-column name="test_max_version_epoch" type="INTEGER" null="true"/>
+ <add-column name="test_max_version_canonical_upstream" type="TEXT" null="true"/>
+ <add-column name="test_max_version_canonical_release" type="TEXT" null="true"/>
+ <add-column name="test_max_version_revision" type="INTEGER" null="true"/>
+ <add-column name="test_max_version_upstream" type="TEXT" null="true"/>
+ <add-column name="test_max_version_release" type="TEXT" null="true"/>
+ <add-column name="test_min_open" type="BOOLEAN" null="true"/>
+ <add-column name="test_max_open" type="BOOLEAN" null="true"/>
+ <add-column name="test_package_tenant" type="TEXT" null="true"/>
+ <add-column name="test_package_name" type="CITEXT" null="true"/>
+ <add-column name="test_package_version_epoch" type="INTEGER" null="true"/>
+ <add-column name="test_package_version_canonical_upstream" type="TEXT" null="true"/>
+ <add-column name="test_package_version_canonical_release" type="TEXT" null="true" options="COLLATE &quot;C&quot;"/>
+ <add-column name="test_package_version_revision" type="INTEGER" null="true"/>
+ <add-column name="test_type" type="TEXT" null="false"/>
+ <add-foreign-key name="test_package_tenant_fk" deferrable="DEFERRED">
+ <column name="test_package_tenant"/>
+ <references table="tenant">
+ <column name="id"/>
+ </references>
+ </add-foreign-key>
+ <add-foreign-key name="test_package_fk" deferrable="DEFERRED">
+ <column name="test_package_tenant"/>
+ <column name="test_package_name"/>
+ <column name="test_package_version_epoch"/>
+ <column name="test_package_version_canonical_upstream"/>
+ <column name="test_package_version_canonical_release"/>
+ <column name="test_package_version_revision"/>
+ <references table="package">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </references>
+ </add-foreign-key>
+ <drop-foreign-key name="dep_package_tenant_fk"/>
+ <drop-foreign-key name="dep_package_fk"/>
+ <drop-column name="dep_name"/>
+ <drop-column name="dep_min_version_epoch"/>
+ <drop-column name="dep_min_version_canonical_upstream"/>
+ <drop-column name="dep_min_version_canonical_release"/>
+ <drop-column name="dep_min_version_revision"/>
+ <drop-column name="dep_min_version_upstream"/>
+ <drop-column name="dep_min_version_release"/>
+ <drop-column name="dep_max_version_epoch"/>
+ <drop-column name="dep_max_version_canonical_upstream"/>
+ <drop-column name="dep_max_version_canonical_release"/>
+ <drop-column name="dep_max_version_revision"/>
+ <drop-column name="dep_max_version_upstream"/>
+ <drop-column name="dep_max_version_release"/>
+ <drop-column name="dep_min_open"/>
+ <drop-column name="dep_max_open"/>
+ <drop-column name="dep_package_tenant"/>
+ <drop-column name="dep_package_name"/>
+ <drop-column name="dep_package_version_epoch"/>
+ <drop-column name="dep_package_version_canonical_upstream"/>
+ <drop-column name="dep_package_version_canonical_release"/>
+ <drop-column name="dep_package_version_revision"/>
+ </alter-table>
+ <drop-table name="package_examples"/>
+ <drop-table name="package_benchmarks"/>
+ </changeset>
+
<changeset version="18">
<alter-table name="package">
<add-column name="unbuildable_reason" type="TEXT" null="true"/>
diff --git a/load/load.cxx b/load/load.cxx
index b289829..e6591f5 100644
--- a/load/load.cxx
+++ b/load/load.cxx
@@ -500,30 +500,25 @@ load_packages (const shared_ptr<repository>& rp,
ds.emplace_back (pda.conditional, pda.buildtime, move (pda.comment));
for (auto& pd: pda)
+ {
// The package member will be assigned during dependency
// resolution procedure.
//
ds.back ().push_back (dependency {move (pd.name),
move (pd.constraint),
nullptr /* package */});
+ }
}
- auto deps = [] (small_vector<bpkg::dependency, 1>&& ds)
- {
- small_vector<dependency, 1> r;
+ small_vector<brep::test_dependency, 1> ts;
- if (!ds.empty ())
- {
- r.reserve (ds.size ());
-
- for (bpkg::dependency& d: ds)
- r.push_back (dependency {move (d.name),
- move (d.constraint),
- nullptr /* package */});
- }
+ if (!pm.tests.empty ())
+ {
+ ts.reserve (pm.tests.size ());
- return r;
- };
+ for (bpkg::test_dependency& td: pm.tests)
+ ts.emplace_back (move (td.name), td.type, move (td.constraint));
+ }
// Cache before the package name is moved.
//
@@ -553,9 +548,7 @@ load_packages (const shared_ptr<repository>& rp,
move (pm.build_error_email),
move (ds),
move (pm.requirements),
- deps (move (pm.tests)),
- deps (move (pm.examples)),
- deps (move (pm.benchmarks)),
+ move (ts),
move (pm.builds),
move (pm.build_constraints),
move (pm.location),
@@ -858,14 +851,13 @@ find (const lazy_shared_ptr<repository>& r,
return false;
}
-// Resolve package run-time dependencies, tests, examples, and benchmarks.
-// Make sure that the best matching dependency belongs to the package
-// repositories, their complements, recursively, or their immediate
-// prerequisite repositories (only for run-time dependencies). Set the
-// buildable flag to false for the resolved tests, examples, and benchmarks
-// packages. Fail if unable to resolve a dependency, unless ignore_unresolved
-// is true in which case leave this dependency NULL. Should be called once per
-// internal package.
+// Resolve package run-time dependencies and external tests. Make sure that
+// the best matching dependency belongs to the package repositories, their
+// complements, recursively, or their immediate prerequisite repositories
+// (only for run-time dependencies). Set the buildable flag to false for the
+// resolved external tests packages. Fail if unable to resolve a dependency,
+// unless ignore_unresolved is true in which case leave this dependency
+// NULL. Should be called once per internal package.
//
static void
resolve_dependencies (package& p, database& db, bool ignore_unresolved)
@@ -877,10 +869,7 @@ resolve_dependencies (package& p, database& db, bool ignore_unresolved)
//
assert (p.internal ());
- if (p.dependencies.empty () &&
- p.tests.empty () &&
- p.examples.empty () &&
- p.benchmarks.empty ())
+ if (p.dependencies.empty () && p.tests.empty ())
return;
auto resolve = [&p, &db] (dependency& d, bool test)
@@ -996,22 +985,10 @@ resolve_dependencies (package& p, database& db, bool ignore_unresolved)
}
}
- for (dependency& d: p.tests)
- {
- if (!resolve (d, true /* test */) && !ignore_unresolved)
- bail (d, "tests");
- }
-
- for (dependency& d: p.examples)
- {
- if (!resolve (d, true /* test */) && !ignore_unresolved)
- bail (d, "examples");
- }
-
- for (dependency& d: p.benchmarks)
+ for (brep::test_dependency& td: p.tests)
{
- if (!resolve (d, true /* test */) && !ignore_unresolved)
- bail (d, "benchmarks");
+ if (!resolve (td, true /* test */) && !ignore_unresolved)
+ bail (td, td.name.string ().c_str ());
}
db.update (p); // Update the package state.
diff --git a/migrate/migrate.cxx b/migrate/migrate.cxx
index feac683..0ef6096 100644
--- a/migrate/migrate.cxx
+++ b/migrate/migrate.cxx
@@ -237,6 +237,17 @@ package_migrate_v18 ([] (database& db)
});
//#endif
+// Merging the package examples and benchmarks tables into the package tests
+// table is a bit hairy. Thus, we won't bother with that and just cleanup the
+// amended package tests table, relying on the loader to fill it in a short
+// time.
+//
+static const package_migration_entry<19>
+package_migrate_v19 ([] (database& db)
+{
+ db.execute ("DELETE from package_tests");
+});
+
// main() function
//
int
diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx
index 741d3b4..04b2a36 100644
--- a/mod/mod-build-task.cxx
+++ b/mod/mod-build-task.cxx
@@ -228,40 +228,33 @@ handle (request& rq, response& rs)
// configuration.
//
small_vector<package, 1> tes;
- auto add_exclusions = [&tes, &cm, this]
- (const small_vector<build_dependency, 1>& tests)
+
+ for (const build_test_dependency& td: p->tests)
{
- for (const build_dependency& t: tests)
+ // Don't exclude unresolved external tests.
+ //
+ // Note that this may result in the build task failure. However,
+ // silently excluding such tests could end up with missed software
+ // bugs which feels much worse.
+ //
+ if (td.package != nullptr)
{
- // Don't exclude unresolved external tests.
- //
- // Note that this may result in the build task failure. However,
- // silently excluding such tests could end up with missed software
- // bugs which feels much worse.
- //
- if (t.package != nullptr)
- {
- shared_ptr<build_package> p (t.package.load ());
+ shared_ptr<build_package> p (td.package.load ());
- // Use the `all` class as a least restrictive default underlying
- // build class set. Note that we should only apply the explicit
- // build restrictions to the external test packages (think about
- // the `builds: all` and `builds: -windows` manifest values for
- // the primary and external test packages, respectively).
- //
- if (exclude (p->builds,
- p->constraints,
- *cm.config,
- nullptr /* reason */,
- true /* default_all_ucs */))
- tes.push_back (package {move (p->id.name), move (p->version)});
- }
+ // Use the `all` class as a least restrictive default underlying
+ // build class set. Note that we should only apply the explicit
+ // build restrictions to the external test packages (think about
+ // the `builds: all` and `builds: -windows` manifest values for
+ // the primary and external test packages, respectively).
+ //
+ if (exclude (p->builds,
+ p->constraints,
+ *cm.config,
+ nullptr /* reason */,
+ true /* default_all_ucs */))
+ tes.push_back (package {move (p->id.name), move (p->version)});
}
- };
-
- add_exclusions (p->tests);
- add_exclusions (p->examples);
- add_exclusions (p->benchmarks);
+ }
task_manifest task (move (b->package_name),
move (b->package_version),
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index bfc08b0..a7682ec 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -397,38 +397,61 @@ handle (request& rq, response& rs)
<< ~TABLE;
}
- auto print_dependencies = [&s, &print_dependency]
- (const small_vector<dependency, 1>& deps,
- const char* heading,
- const char* id)
+ // Print the test dependencies grouped by types as the separate blocks.
+ //
+ // Print test dependencies of the specific type.
+ //
+ auto print_tests = [&pkg, &s, &print_dependency] (test_dependency_type dt)
{
- if (!deps.empty ())
- {
- s << H3 << heading << ~H3
- << TABLE(CLASS="proplist", ID=id)
- << TBODY;
+ string id;
- for (const dependency& d: deps)
+ bool first (true);
+ for (const test_dependency& td: pkg->tests)
+ {
+ if (td.type == dt)
{
+ // Print the table header if this is a first test dependency.
+ //
+ if (first)
+ {
+ id = to_string (dt);
+
+ // Capitalize the heading.
+ //
+ string heading (id);
+ heading[0] = ucase (id[0]);
+
+ s << H3 << heading << ~H3
+ << TABLE(CLASS="proplist", ID=id)
+ << TBODY;
+
+ first = false;
+ }
+
s << TR(CLASS=id)
<< TD
<< SPAN(CLASS="value");
- print_dependency (d);
+ print_dependency (td);
s << ~SPAN
<< ~TD
<< ~TR;
}
+ }
+ // Print the table closing tags if it was printed.
+ //
+ if (!first)
+ {
s << ~TBODY
<< ~TABLE;
}
};
- print_dependencies (pkg->tests, "Tests", "tests");
- print_dependencies (pkg->examples, "Examples", "examples");
- print_dependencies (pkg->benchmarks, "Benchmarks", "benchmarks");
+ print_tests (test_dependency_type::tests);
+ print_tests (test_dependency_type::examples);
+ print_tests (test_dependency_type::benchmarks);
bool builds (build_db_ != nullptr && pkg->buildable);
diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx
index 420c1e3..b4c43cc 100644
--- a/tests/load/driver.cxx
+++ b/tests/load/driver.cxx
@@ -204,7 +204,7 @@ main (int argc, char* argv[])
static inline dependency
dep (const char* n, optional<version_constraint> c)
{
- return dependency {package_name (n), move (c), nullptr};
+ return dependency {package_name (n), move (c), nullptr /* package */};
}
static inline version