aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-11-01 15:06:41 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-11-01 15:07:21 +0300
commit818a3883a45e8242eee919806828a3ed801d52e1 (patch)
tree507dd8ebce32cbdae5c95bc7787340958479c679
parent41ce54dea27dfc92bf0d2eb5c563c4abd5b57efa (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.
-rw-r--r--bbot/worker/worker.cxx43
-rw-r--r--tests/integration/testscript2
2 files changed, 37 insertions, 8 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.
//
diff --git a/tests/integration/testscript b/tests/integration/testscript
index 43f77a2..7d7d7d9 100644
--- a/tests/integration/testscript
+++ b/tests/integration/testscript
@@ -52,7 +52,7 @@ pkg = libhello
ver = 1.0.0
#rep_url = https://build2.org/pkg/1/hello/stable
#rfp = FF:DF:7D:38:67:4E:C3:82:65:7E:EE:1F:D4:80:EC:56:C4:33:5B:65:3F:9B:29:9A:30:56:B9:77:B9:F2:01:94
-rep_url = https://hello.stage.build2.org/1/stable/
+rep_url = https://stage.build2.org/1
rep_type = pkg
rfp = yes