From 2aa6e85b395f82d80322895b118975dde4d0af69 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 27 May 2024 21:18:52 +0300 Subject: Fix publish and ci commands diagnostics when package is not initialized in default configuration (GH issue #294) --- bdep/ci.cxx | 18 +++++++++--------- bdep/publish.cxx | 12 ++++++------ tests/ci.testscript | 2 +- 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 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& c: cfgs) + for (const shared_ptr& 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& c: cfgs) + for (const shared_ptr& 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 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 pc; - for (const shared_ptr& c: cfgs) + for (const shared_ptr& 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/***; -- cgit v1.1