From d712f69f5f769c5eaada3c1f76419abfb7b6f7ed Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 10 Feb 2020 22:09:59 +0300 Subject: Add builtins support for $process.run*() functions --- libbuild2/test/script/runner.cxx | 53 ++++++++-------------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) (limited to 'libbuild2/test/script') 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 #include -#include // fdopen_mode, fdnull(), fddup() +#include // fdopen_mode, fddup() #include // path_search() #include @@ -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; -- cgit v1.1