aboutsummaryrefslogtreecommitdiff
path: root/bbot/worker/worker.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bbot/worker/worker.cxx')
-rw-r--r--bbot/worker/worker.cxx192
1 files changed, 140 insertions, 52 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index 3f7b941..ef86dd4 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -511,33 +511,43 @@ build (size_t argc, const char* argv[])
//
enum class step_id
{
- bpkg_configure_create,
+ bpkg_create,
bpkg_configure_add,
bpkg_configure_fetch,
bpkg_configure_build,
- bpkg_update_update,
- bpkg_test_test,
- bpkg_install_install,
+ bpkg_update,
+ bpkg_test,
+ bpkg_install,
b_test_installed_create,
b_test_installed_configure,
b_test_installed_test,
bpkg_test_installed_create,
- bpkg_uninstall_uninstall
+ bpkg_test_installed_configure_add,
+ bpkg_test_installed_configure_fetch,
+ bpkg_test_installed_configure_build,
+ bpkg_test_installed_update,
+ bpkg_test_installed_test,
+ bpkg_uninstall
};
const strings step_id_str {
- "bpkg.configure.create",
+ "bpkg.create",
"bpkg.configure.add",
"bpkg.configure.fetch",
"bpkg.configure.build",
- "bpkg.update.update",
- "bpkg.test.test",
- "bpkg.install.install",
+ "bpkg.update",
+ "bpkg.test",
+ "bpkg.install",
"b.test-installed.create",
"b.test-installed.configure",
"b.test-installed.test",
"bpkg.test-installed.create",
- "bpkg.uninstall.uninstall"};
+ "bpkg.test-installed.configure.add",
+ "bpkg.test-installed.configure.fetch",
+ "bpkg.test-installed.configure.build",
+ "bpkg.test-installed.update",
+ "bpkg.test-installed.test",
+ "bpkg.uninstall"};
// Split the argument into prefix (empty if not present) and unquoted
// value. Return nullopt if the prefix is invalid.
@@ -570,7 +580,7 @@ build (size_t argc, const char* argv[])
args.emplace (move (a));
else
{
- args.emplace ("bpkg.configure.create", a.second);
+ args.emplace ("bpkg.create", a.second);
args.emplace ("b.test-installed.create", a.second);
args.emplace ("bpkg.test-installed.create", move (a.second));
}
@@ -620,9 +630,10 @@ build (size_t argc, const char* argv[])
bool mod (v->second[0] != '-' && v->second.find ('=') == string::npos);
- if (mod && !v->first.empty () &&
- v->first != "bpkg.configure.create" &&
- v->first != "b.test-installed.create")
+ if (mod && !v->first.empty () &&
+ v->first != "bpkg.create" &&
+ v->first != "b.test-installed.create" &&
+ v->first != "bpkg.test-installed.create")
fail << "invalid module prefix in '" << a << "'";
add_arg (mod ? modules : env_args, move (*v));
@@ -632,10 +643,19 @@ build (size_t argc, const char* argv[])
// specific prefixes come last.
//
auto step_args = [&step_id_str] (const std::multimap<string, string>& args,
- step_id step) -> strings
+ step_id step,
+ optional<step_id> fallback = nullopt)
+ -> strings
{
strings r;
- const string& s (step_id_str[static_cast<size_t> (step)]);
+ const string& sid (step_id_str[static_cast<size_t> (step)]);
+
+ // If no arguments found for the step id, then use the fallback step id,
+ // if specified.
+ //
+ const string& s (args.find (sid) == args.end () && fallback
+ ? step_id_str[static_cast<size_t> (*fallback)]
+ : sid);
for (size_t n (0);; ++n)
{
@@ -656,12 +676,12 @@ build (size_t argc, const char* argv[])
// Search for config.install.root variable. If it is present and has a
// non-empty value, then test the package installation and uninstall. Note
- // that passing [null] value would be meaningless, so we don't recognize it
- // as a special one. While at it, cache the bpkg.configure.create args for
- // later use.
+ // that passing [null] value would be meaningless, so we don't recognize
+ // it as a special one. While at it, cache the bpkg.create args for later
+ // use.
//
dir_path install_root;
- strings cargs (step_args (config_args, step_id::bpkg_configure_create));
+ strings cargs (step_args (config_args, step_id::bpkg_create));
{
size_t n (19);
auto space = [] (char c) {return c == ' ' || c == '\t';};
@@ -814,6 +834,8 @@ build (size_t argc, const char* argv[])
return true;
};
+ // The main phase.
+ //
// If this is a build system module, perform a "pre-step" by building it
// in a separate configuration reproducing the one used to build build2
// itself. Note that the configuration and the environment options and
@@ -1043,7 +1065,7 @@ build (size_t argc, const char* argv[])
// bpkg create <env-modules> <env-config-args> <config-args>
//
- // bpkg.configure.create
+ // bpkg.create
//
{
// If the package is a build system module, then make sure it is
@@ -1055,8 +1077,8 @@ build (size_t argc, const char* argv[])
"create",
"-d", build_dir.string (),
"--wipe",
- step_args (modules, step_id::bpkg_configure_create),
- step_args (env_args, step_id::bpkg_configure_create),
+ step_args (modules, step_id::bpkg_create),
+ step_args (env_args, step_id::bpkg_create),
cargs,
module && !bootstrap ? module_import.c_str () : nullptr);
@@ -1143,14 +1165,14 @@ build (size_t argc, const char* argv[])
// bpkg update <env-config-args> <config-args> <package-name>
//
- // bpkg.update.update
+ // bpkg.update
//
r.status |= run_bpkg (
trace, r.log, wre,
"-v",
"update",
- step_args (env_args, step_id::bpkg_update_update),
- step_args (config_args, step_id::bpkg_update_update),
+ step_args (env_args, step_id::bpkg_update),
+ step_args (config_args, step_id::bpkg_update),
pkg);
if (!r.status)
@@ -1211,6 +1233,11 @@ build (size_t argc, const char* argv[])
// override and/or set the environment variables for bpkg processes.
// Return true if all operations for all packages succeed.
//
+ // Pass true as the installed argument to use the test installed phase
+ // step ids (bpkg.test-installed.*), falling back to the main phase step
+ // ids (bpkg.*) when no environment/configuration arguments are specified
+ // for them.
+ //
// Pass true as the sys_dep argument to configure the dependent package as
// a system dependency, which is normally required for testing modules and
// installed dependents. Note that bpkg configures the dependent package
@@ -1222,10 +1249,22 @@ build (size_t argc, const char* argv[])
&redist]
(operation_result& r,
const dir_path& dist_root,
+ bool installed,
bool sys_dep,
const char* import = nullptr,
const small_vector<string, 1>& envvars = {})
{
+ auto args = [installed, &step_args] (
+ const std::multimap<string, string>& args,
+ step_id main_step,
+ step_id test_installed_step)
+ {
+ return installed
+ ? step_args (args, test_installed_step, main_step)
+ : step_args (args, main_step);
+
+ };
+
for (const test_dependency& td: pm.tests)
{
const string& pkg (td.name.string ());
@@ -1245,8 +1284,15 @@ build (size_t argc, const char* argv[])
"--configure-only",
"--checkout-root", dist_root,
"--yes",
- step_args (env_args, step_id::bpkg_configure_build),
- step_args (config_args, step_id::bpkg_configure_build),
+
+ args (env_args,
+ step_id::bpkg_configure_build,
+ step_id::bpkg_test_installed_configure_build),
+
+ args (config_args,
+ step_id::bpkg_configure_build,
+ step_id::bpkg_test_installed_configure_build),
+
import,
"--",
td.string (),
@@ -1297,8 +1343,15 @@ build (size_t argc, const char* argv[])
trace, r.log, wre,
"-v",
"update",
- step_args (env_args, step_id::bpkg_update_update),
- step_args (config_args, step_id::bpkg_update_update),
+
+ args (env_args,
+ step_id::bpkg_update,
+ step_id::bpkg_test_installed_update),
+
+ args (config_args,
+ step_id::bpkg_update,
+ step_id::bpkg_test_installed_update),
+
import,
pkg);
@@ -1320,8 +1373,15 @@ build (size_t argc, const char* argv[])
"-v",
"test",
"--package-cwd", // See above for details.
- step_args (env_args, step_id::bpkg_test_test),
- step_args (config_args, step_id::bpkg_test_test),
+
+ args (env_args,
+ step_id::bpkg_test,
+ step_id::bpkg_test_installed_test),
+
+ args (config_args,
+ step_id::bpkg_test,
+ step_id::bpkg_test_installed_test),
+
import,
pkg);
@@ -1351,15 +1411,15 @@ build (size_t argc, const char* argv[])
{
// bpkg test <env-config-args> <config-args> <package-name>
//
- // bpkg.test.test
+ // bpkg.test
//
r.status |= run_bpkg (
trace, r.log, wre,
"-v",
"test",
"--package-cwd", // See above for details.
- step_args (env_args, step_id::bpkg_test_test),
- step_args (config_args, step_id::bpkg_test_test),
+ step_args (env_args, step_id::bpkg_test),
+ step_args (config_args, step_id::bpkg_test),
pkg);
if (!r.status)
@@ -1376,6 +1436,7 @@ build (size_t argc, const char* argv[])
if (external_tests &&
!test (r,
dist_root,
+ false /* installed */,
module,
bootstrap ? module_import.c_str () : nullptr))
break;
@@ -1416,14 +1477,14 @@ build (size_t argc, const char* argv[])
// bpkg install <env-config-args> <config-args> <package-name>
//
- // bpkg.install.install
+ // bpkg.install
//
r.status |= run_bpkg (
trace, r.log, wre,
"-v",
"install",
- step_args (env_args, step_id::bpkg_install_install),
- step_args (config_args, step_id::bpkg_install_install),
+ step_args (env_args, step_id::bpkg_install),
+ step_args (config_args, step_id::bpkg_install),
pkg);
if (!r.status)
@@ -1432,7 +1493,7 @@ build (size_t argc, const char* argv[])
rm.status |= r.status;
}
- // Test installed.
+ // The test installed phase.
//
// Make sure that the installed package executables are properly imported
// when configuring and running tests, unless we are testing the build
@@ -1585,7 +1646,7 @@ build (size_t argc, const char* argv[])
//
// bpkg create <env-modules> <env-config-args> <config-args>
//
- // bpkg.test-installed.create
+ // bpkg.test-installed.create (fallback to bpkg.create)
//
dir_path config_dir ("build-installed-bpkg");
@@ -1595,9 +1656,18 @@ build (size_t argc, const char* argv[])
"create",
"-d", config_dir.string (),
"--wipe",
- step_args (modules, step_id::bpkg_test_installed_create),
- step_args (env_args, step_id::bpkg_test_installed_create),
- step_args (config_args, step_id::bpkg_test_installed_create));
+
+ step_args (modules,
+ step_id::bpkg_test_installed_create,
+ step_id::bpkg_create),
+
+ step_args (env_args,
+ step_id::bpkg_test_installed_create,
+ step_id::bpkg_create),
+
+ step_args (config_args,
+ step_id::bpkg_test_installed_create,
+ step_id::bpkg_create));
if (!r.status)
break;
@@ -1606,14 +1676,21 @@ build (size_t argc, const char* argv[])
// bpkg add <env-config-args> <config-args> <repository-url>
//
- // bpkg.configure.add
+ // bpkg.test-installed.configure.add (fallback to bpkg.configure.add)
//
r.status |= run_bpkg (
trace, r.log, wre,
"-v",
"add",
- step_args (env_args, step_id::bpkg_configure_add),
- step_args (config_args, step_id::bpkg_configure_add),
+
+ step_args (env_args,
+ step_id::bpkg_test_installed_configure_add,
+ step_id::bpkg_configure_add),
+
+ step_args (config_args,
+ step_id::bpkg_test_installed_configure_add,
+ step_id::bpkg_configure_add),
+
repo);
if (!r.status)
@@ -1621,14 +1698,22 @@ build (size_t argc, const char* argv[])
// bpkg fetch <env-config-args> <config-args> <trust-options>
//
- // bpkg.configure.fetch
+ // bpkg.test-installed.configure.fetch (fallback to
+ // bpkg.configure.fetch)
//
r.status |= run_bpkg (
trace, r.log, wre,
"-v",
"fetch",
- step_args (env_args, step_id::bpkg_configure_fetch),
- step_args (config_args, step_id::bpkg_configure_fetch),
+
+ step_args (env_args,
+ step_id::bpkg_test_installed_configure_fetch,
+ step_id::bpkg_configure_fetch),
+
+ step_args (config_args,
+ step_id::bpkg_test_installed_configure_fetch,
+ step_id::bpkg_configure_fetch),
+
trust_ops);
if (!r.status)
@@ -1638,6 +1723,7 @@ build (size_t argc, const char* argv[])
//
if (!test (r,
rwd / dir_path ("dist-installed"),
+ true /* installed */,
true /* sys_dep */,
nullptr /* import */,
envvars))
@@ -1647,6 +1733,8 @@ build (size_t argc, const char* argv[])
rm.status |= r.status;
}
+ // Back to the main phase.
+ //
// Uninstall.
//
{
@@ -1656,14 +1744,14 @@ build (size_t argc, const char* argv[])
// bpkg uninstall <env-config-args> <config-args> <package-name>
//
- // bpkg.uninstall.uninstall
+ // bpkg.uninstall
//
r.status |= run_bpkg (
trace, r.log, wre,
"-v",
"uninstall",
- step_args (env_args, step_id::bpkg_uninstall_uninstall),
- step_args (config_args, step_id::bpkg_uninstall_uninstall),
+ step_args (env_args, step_id::bpkg_uninstall),
+ step_args (config_args, step_id::bpkg_uninstall),
pkg);
if (!r.status)