diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-11-01 14:52:16 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-11-01 15:23:16 +0300 |
commit | 0076593f8dfaf5ed15cfd42c963bde4e038d42bd (patch) | |
tree | e4bd68f42f597c0c5804a1bf45388b90bcb348ff | |
parent | 16e8126b586aa83f13e02eaa34a0789da4549594 (diff) |
Make use of --package-cwd bpkg-pkg-test option
-rw-r--r-- | bbot/worker/worker.cxx | 123 | ||||
-rw-r--r-- | tests/integration/testscript | 2 |
2 files changed, 5 insertions, 120 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index cb47651..70dbac2 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -278,66 +278,6 @@ run_b (tracer& t, verbosity, buildspec, forward<A> (a)...); } -// Run a program and return its output as a string if it prints exactly one -// line and exits with zero code and fail otherwise. -// -template <typename... A> -static string -cmd_line (tracer& t, const string& name, const process_env& pe, A&&... a) -{ - try - { - fdpipe pipe (fdopen_pipe ()); // Text mode seems appropriate. - - process pr ( - process_start_callback (t, - fdnull () /* stdin */, - pipe, /* stdout */ - 2 /* stderr */, - pe, - forward<A> (a)...)); - - pipe.out.close (); - - ifdstream is (move (pipe.in), fdstream_mode::skip); - - optional<string> r; - if (is.peek () != ifdstream::traits_type::eof ()) - { - string s; - getline (is, s); - - if (!is.eof () && is.peek () == ifdstream::traits_type::eof ()) - { - r = move (s); - - if (verb >= 3) - t << *r; - } - } - - is.close (); - - if (pr.wait ()) - { - if (r) - return move (*r); - - fail << "invalid " << name << " output"; - } - - fail << name << ' ' << *pr.exit << endf; - } - catch (const process_error& e) - { - fail << "unable to execute " << name << ": " << e << endf; - } - catch (const io_error& e) - { - fail << "unable to read " << name << " stdout: " << e << endf; - } -} - static int bbot:: build (size_t argc, const char* argv[]) { @@ -828,54 +768,9 @@ build (size_t argc, const char* argv[]) // Note that we assume that the package supports the test operation // since this is its main purpose. // - // 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. - // - // To determine the package directory name we need to obtain the - // configured package version. Parsing the bpkg-pkg-status output - // seems to be the easiest way to accomplish this. - // - version ver; - { - string status (cmd_line (trace, - "bpkg-pkg-status", - "bpkg", "status", "--no-hold", pkg)); - - // Get the version offset in the status line. - // - string prefix (pkg + " configured "); - size_t p (prefix.size ()); - - // Make sure the status line prefix matches our expectations. - // - if (status.compare (0, p, prefix) != 0) - fail << "unexpected " << pkg << " status: " << status; - - // Extract the package version from the status line. - // - size_t n (status.find (' ', p)); - string v (status, p, n != string::npos ? n - p : n); - - try - { - ver = version (v); - } - catch (const invalid_argument& e) - { - fail << "invalid " << pkg << " version '" << v << "' in " - << "package status: " << e << - info << "status: " << status; - } - } - - // Finally, change the working directory to the package directory - // and run the tests. + // Use --package-cwd to help ported to build2 third-party packages a + // bit (see bpkg-pkg-test(1) for details). // - dir_path prj_dir (pkg + '-' + ver.string ()); - dir_path owd (change_wd (trace, &r.log, prj_dir)); - // bpkg test <env-config-args> <config-args> <package-name> // // bpkg.test.test @@ -885,15 +780,13 @@ build (size_t argc, const char* argv[]) trace, r.log, wre, "-v", "test", - "-d", "..", + "--package-cwd", step_args (env_args, step_id::bpkg_test_test), step_args (config_args, step_id::bpkg_test_test), pkg); if (!r.status) return false; - - change_wd (trace, &r.log, owd); } return true; @@ -907,12 +800,6 @@ build (size_t argc, const char* argv[]) // if (internal_tests) { - // Lets change the working directory to the package directory to help - // ported to build2 third-party packages a bit (see above for - // details). - // - dir_path owd (change_wd (trace, &r.log, prj_dir)); - // bpkg test <env-config-args> <config-args> <package-name> // // bpkg.test.test @@ -921,15 +808,13 @@ build (size_t argc, const char* argv[]) trace, r.log, wre, "-v", "test", - "-d", "..", + "--package-cwd", // See above for details. step_args (env_args, step_id::bpkg_test_test), step_args (config_args, step_id::bpkg_test_test), tm.name.string ()); if (!r.status) break; - - change_wd (trace, &r.log, owd); } // Run external tests. diff --git a/tests/integration/testscript b/tests/integration/testscript index 2e7deb2..d06b931 100644 --- a/tests/integration/testscript +++ b/tests/integration/testscript @@ -137,6 +137,6 @@ a = $0 chmod ugo+x $env; sleep $wait; $w --verbose 3 --startup --tftp-host $tftp --environments $~ \ - &build/*** &?build-installed/*** &?build-tests-installed/*** \ + &build/*** &?build-installed/*** &?build-installed-bpkg/*** \ &task.manifest 2>| } |