diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-11-01 15:06:41 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-11-01 15:07:21 +0300 |
commit | 818a3883a45e8242eee919806828a3ed801d52e1 (patch) | |
tree | 507dd8ebce32cbdae5c95bc7787340958479c679 /bbot/worker/worker.cxx | |
parent | 41ce54dea27dfc92bf0d2eb5c563c4abd5b57efa (diff) |
Change worker current directory to package directory for test operation
Note that this is not uncommon for ported to build2 third-party packages to
expect that tests should run in the project root directory.
Diffstat (limited to 'bbot/worker/worker.cxx')
-rw-r--r-- | bbot/worker/worker.cxx | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index b32dbed..1b567b3 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -52,16 +52,29 @@ namespace bbot } static dir_path -change_wd (const dir_path& d, bool create = false) +change_wd (tracer& t, string* log, const dir_path& d, bool create = false) try { if (create) + { + if (verb >= 3) + t << "mkdir -p " << d; + + if (log != nullptr) + *log += "mkdir -p " + d.representation () + '\n'; + try_mkdir_p (d); + } dir_path r (dir_path::current_directory ()); - dir_path::current_directory (d); + if (verb >= 3) + t << "cd " << d; + + if (log != nullptr) + *log += "cd " + d.representation () + '\n'; + dir_path::current_directory (d); return r; } catch (const system_error& e) @@ -472,7 +485,7 @@ build (size_t argc, const char* argv[]) if (!r.status) break; - rwd = change_wd (build_dir); + rwd = change_wd (trace, &r.log, build_dir); // bpkg add <config-args> <env-config-args> <repository-url> // @@ -564,6 +577,14 @@ build (size_t argc, const char* argv[]) { operation_result& r (add_result ("test")); + // Lets change the working directory to the package directory to help + // ported to build2 third-party packages a bit. Note that this is not + // uncommon for them to expect that tests should run in the project root + // directory. + // + dir_path d (tm.name.string () + '-' + tm.version.string ()); + dir_path rwd (change_wd (trace, &r.log, d)); + // bpkg test <config-args> <env-config-args> <package-name> // // bpkg.test.test @@ -571,6 +592,7 @@ build (size_t argc, const char* argv[]) r.status |= run_bpkg ( trace, r.log, wre, "test", + "-d", "..", step_args (config_args, step_id::bpkg_test_test), step_args (env_args, step_id::bpkg_test_test), tm.name.string ()); @@ -579,6 +601,8 @@ build (size_t argc, const char* argv[]) break; rm.status |= r.status; + + change_wd (trace, &r.log, rwd); } // Install the package, optionally test the installation and uninstall @@ -637,7 +661,7 @@ build (size_t argc, const char* argv[]) { operation_result& r (add_result ("test-installed")); - change_wd (rwd); + change_wd (trace, &r.log, rwd); string mods; // build2 create meta-operation parameters. @@ -722,7 +746,7 @@ build (size_t argc, const char* argv[]) rm.status |= r.status; - change_wd (build_dir); + change_wd (trace, &r.log, build_dir); } // Uninstall. @@ -756,7 +780,7 @@ build (size_t argc, const char* argv[]) assert (rm.status == result_status::abort); if (!rwd.empty ()) - change_wd (rwd); + change_wd (trace, nullptr /* log */, rwd); // Upload the result. // @@ -954,6 +978,8 @@ int bbot:: main (int argc, char* argv[]) try { + tracer trace ("main"); + // This is a little hack to make our baseutils for Windows work when called // with absolute path. In a nutshell, MSYS2's exec*p() doesn't search in the // parent's executable directory, only in PATH. And since we are running @@ -1051,7 +1077,10 @@ try // Sort out the build directory. // if (ops.build_specified ()) - change_wd (ops.build (), true); // Create if does not exist. + change_wd (trace, + nullptr /* log */, + ops.build (), + true /* create */); // Sort out the environment directory. // |