aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script/script.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-10-10 17:22:46 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-11-06 19:32:09 +0300
commitf41599c8e9435f3dfec60b872c2b4ae31177efdd (patch)
tree088f8d9bf906e4a2ed734e034699163c9ccc7306 /libbuild2/script/script.cxx
parentac76a4fd2afff48a0d5db84592babe5cabef3a2c (diff)
Add support for test timeouts
Diffstat (limited to 'libbuild2/script/script.cxx')
-rw-r--r--libbuild2/script/script.cxx26
1 files changed, 16 insertions, 10 deletions
diff --git a/libbuild2/script/script.cxx b/libbuild2/script/script.cxx
index 6ee702e..f540687 100644
--- a/libbuild2/script/script.cxx
+++ b/libbuild2/script/script.cxx
@@ -3,6 +3,7 @@
#include <libbuild2/script/script.hxx>
+#include <chrono>
#include <sstream>
#include <cstring> // strchr()
@@ -408,13 +409,20 @@ namespace build2
if ((m & command_to_stream::header) == command_to_stream::header)
{
- // Print the env builtin arguments, if any environment variable
- // (un)sets are present.
+ // Print the env builtin if any of its options/arguments are present.
//
- if (!c.variables.empty ())
+ if (!c.variables.empty () || c.timeout)
{
o << "env";
+ // Timeout.
+ //
+ if (c.timeout)
+ o << " -t "
+ << chrono::duration_cast<chrono::seconds> (*c.timeout).count ();
+
+ // Variable unsets/sets.
+ //
auto b (c.variables.begin ()), i (b), e (c.variables.end ());
// Print a variable name or assignment to the stream, quoting it if
@@ -456,8 +464,7 @@ namespace build2
//
// Print the variable unsets as the -u options until a variable set
// is encountered (contains '=') or the end of the variable list is
- // reached. In the former case, to avoid a potential ambiguity add
- // the '-' separator, if there are any options.
+ // reached.
//
// Note that we rely on the fact that unsets come first, which is
// guaranteed by parser::parse_env_builtin().
@@ -471,16 +478,15 @@ namespace build2
o << " -u "; print (v, true /* name*/);
}
else // Variable set.
- {
- if (i != b)
- o << " -";
-
break;
- }
}
// Variable sets.
//
+ // Note that we don't add the '-' separator since we always use the
+ // `-* <value>` option notation and so there can't be any ambiguity
+ // with a variable set.
+ //
for (; i != e; ++i)
{
o << ' '; print (*i, false /* name */);