aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-02-10 22:09:59 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-02-12 16:49:44 +0300
commitd712f69f5f769c5eaada3c1f76419abfb7b6f7ed (patch)
treea7b36e3e87ce5ef71610f864645dbd7bc339a997 /libbuild2/test/script
parent5524dcb9a9b10a65e450458eb76c84451a283ccc (diff)
Add builtins support for $process.run*() functions
Diffstat (limited to 'libbuild2/test/script')
-rw-r--r--libbuild2/test/script/runner.cxx53
1 files changed, 10 insertions, 43 deletions
diff --git a/libbuild2/test/script/runner.cxx b/libbuild2/test/script/runner.cxx
index 535919c..b006f3e 100644
--- a/libbuild2/test/script/runner.cxx
+++ b/libbuild2/test/script/runner.cxx
@@ -7,7 +7,7 @@
#include <libbutl/regex.mxx>
#include <libbutl/builtin.mxx>
-#include <libbutl/fdstream.mxx> // fdopen_mode, fdnull(), fddup()
+#include <libbutl/fdstream.mxx> // fdopen_mode, fddup()
#include <libbutl/filesystem.mxx> // path_search()
#include <libbutl/path-pattern.mxx>
@@ -1352,15 +1352,7 @@ namespace build2
//
case redirect_type::null:
{
- try
- {
- ifd = fdnull ();
- }
- catch (const io_error& e)
- {
- fail (ll) << "unable to write to null device: " << e;
- }
-
+ ifd = open_dev_null ();
break;
}
@@ -1388,7 +1380,6 @@ namespace build2
open_stdin ();
break;
}
-
case redirect_type::trace:
case redirect_type::merge:
case redirect_type::here_str_regex:
@@ -1445,7 +1436,6 @@ namespace build2
fdopen_mode m (fdopen_mode::out | fdopen_mode::create);
- auto_fd fd;
redirect_type rt (r.type != redirect_type::trace
? r.type
: verb < 2
@@ -1457,36 +1447,19 @@ namespace build2
{
try
{
- fd = fddup (dfd);
+ return fddup (dfd);
}
catch (const io_error& e)
{
fail (ll) << "unable to duplicate " << what << ": " << e;
}
-
- return fd;
}
- case redirect_type::null:
- {
- try
- {
- fd = fdnull ();
- }
- catch (const io_error& e)
- {
- fail (ll) << "unable to write to null device: " << e;
- }
-
- return fd;
- }
+ case redirect_type::null: return open_dev_null ();
- case redirect_type::merge:
- {
- // Duplicate the paired file descriptor later.
- //
- return fd; // nullfd
- }
+ // Duplicate the paired file descriptor later.
+ //
+ case redirect_type::merge: return nullfd;
case redirect_type::file:
{
@@ -1521,6 +1494,8 @@ namespace build2
case redirect_type::here_doc_ref: assert (false); break;
}
+ auto_fd fd;
+
try
{
fd = fdopen (p, m);
@@ -1562,15 +1537,7 @@ namespace build2
else
{
assert (out.type == redirect_type::none); // No redirect expected.
-
- try
- {
- ofd = fdopen_pipe ();
- }
- catch (const io_error& e)
- {
- fail (ll) << "unable to open pipe: " << e;
- }
+ ofd = open_pipe ();
}
path esp;