aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-05-27 21:18:52 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-05-28 10:50:30 +0300
commit2aa6e85b395f82d80322895b118975dde4d0af69 (patch)
tree632ee5508a8aa3b608c7e719e7950d2eda64e51a
parenteeb020bc2c15d75772b249b5f115b1a7841bc843 (diff)
Fix publish and ci commands diagnostics when package is not initialized in default configuration (GH issue #294)
-rw-r--r--bdep/ci.cxx18
-rw-r--r--bdep/publish.cxx12
-rw-r--r--tests/ci.testscript2
3 files changed, 16 insertions, 16 deletions
diff --git a/bdep/ci.cxx b/bdep/ci.cxx
index cca2234..dbe07bf 100644
--- a/bdep/ci.cxx
+++ b/bdep/ci.cxx
@@ -404,8 +404,8 @@ namespace bdep
// Add a package to the list and suppressing duplicates.
//
auto add_package = [&pkgs] (package_name n,
- const dir_path& d,
- package_info&& pi)
+ const dir_path& d,
+ package_info&& pi)
{
auto i (find_if (pkgs.begin (),
pkgs.end (),
@@ -447,15 +447,17 @@ namespace bdep
}
else
{
- configurations cfgs;
+ pair<configurations, bool> cfgs;
{
// Don't keep the database open longer than necessary.
//
database db (open (prj, trace));
transaction t (db.begin ());
- cfgs = find_configurations (o, prj, t).first;
+ cfgs = find_configurations (o, prj, t);
t.commit ();
+
+ verify_project_packages (pp, cfgs);
}
// Add a package to the list, suppressing duplicates and verifying that
@@ -494,7 +496,7 @@ namespace bdep
if (pp.packages.empty ())
{
- for (const shared_ptr<configuration>& c: cfgs)
+ for (const shared_ptr<configuration>& c: cfgs.first)
{
for (const package_state& p: c->packages)
add_package (p.name, c);
@@ -506,7 +508,7 @@ namespace bdep
{
bool init (false);
- for (const shared_ptr<configuration>& c: cfgs)
+ for (const shared_ptr<configuration>& c: cfgs.first)
{
if (find_if (c->packages.begin (),
c->packages.end (),
@@ -523,9 +525,7 @@ namespace bdep
}
}
- if (!init)
- fail << "package " << p.name << " is not initialized in any "
- << "configuration";
+ assert (init); // Wouldn't be here otherwise.
}
}
}
diff --git a/bdep/publish.cxx b/bdep/publish.cxx
index c358add..3bdbf46 100644
--- a/bdep/publish.cxx
+++ b/bdep/publish.cxx
@@ -1053,15 +1053,17 @@ namespace bdep
}
else
{
- configurations cfgs;
+ pair<configurations, bool> cfgs;
{
// Don't keep the database open longer than necessary.
//
database db (open (prj, trace));
transaction t (db.begin ());
- cfgs = find_configurations (o, prj, t).first;
+ cfgs = find_configurations (o, prj, t);
t.commit ();
+
+ verify_project_packages (pp, cfgs);
}
// Configurations to sync.
@@ -1080,7 +1082,7 @@ namespace bdep
{
shared_ptr<configuration> pc;
- for (const shared_ptr<configuration>& c: cfgs)
+ for (const shared_ptr<configuration>& c: cfgs.first)
{
if (find_if (c->packages.begin (),
c->packages.end (),
@@ -1099,9 +1101,7 @@ namespace bdep
}
}
- if (pc == nullptr)
- fail << "package " << p.name << " is not initialized in any "
- << "configuration";
+ assert (pc != nullptr); // Wouldn't be here otherwise.
dist_dirs.push_back (dir_path (pc->path) /= p.name.string ());
diff --git a/tests/ci.testscript b/tests/ci.testscript
index ab3f33a..4f1a883 100644
--- a/tests/ci.testscript
+++ b/tests/ci.testscript
@@ -939,7 +939,7 @@ windows = ($cxx.target.class == 'windows')
# While at it, test that we fail for uninitialized package.
#
$* -d prj/prj 2>>EOE != 0;
- error: package prj is not initialized in any configuration
+ error: package prj is not initialized in any default configuration(s)
EOE
$init -C @cfg2 --config-type host -d prj/prj &prj-cfg2/***;