aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/build/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/build/script/script.cxx
parentac76a4fd2afff48a0d5db84592babe5cabef3a2c (diff)
Add support for test timeouts
Diffstat (limited to 'libbuild2/build/script/script.cxx')
-rw-r--r--libbuild2/build/script/script.cxx28
1 files changed, 26 insertions, 2 deletions
diff --git a/libbuild2/build/script/script.cxx b/libbuild2/build/script/script.cxx
index 3485f54..c6b57c3 100644
--- a/libbuild2/build/script/script.cxx
+++ b/libbuild2/build/script/script.cxx
@@ -7,6 +7,8 @@
#include <libbuild2/target.hxx>
+#include <libbuild2/script/timeout.hxx>
+
#include <libbuild2/build/script/parser.hxx>
using namespace std;
@@ -17,12 +19,17 @@ namespace build2
{
namespace script
{
+ using build2::script::to_deadline;
+
// environment
//
static const optional<string> wd_name ("current directory");
environment::
- environment (action a, const target_type& t, bool temp)
+ environment (action a,
+ const target_type& t,
+ bool temp,
+ const optional<timestamp>& dl)
: build2::script::environment (
t.ctx,
cast<target_triplet> (t.ctx.global_scope["build.host"]),
@@ -32,7 +39,8 @@ namespace build2
redirect (redirect_type::merge, 2),
redirect (redirect_type::pass)),
target (t),
- vars (context, false /* global */)
+ vars (context, false /* global */),
+ script_deadline (to_deadline (dl, false /* success */))
{
// Set special variables.
//
@@ -58,8 +66,10 @@ namespace build2
//
names ns;
for (const target_type* pt: t.prerequisite_targets[a])
+ {
if (pt != nullptr)
pt->as_name (ns);
+ }
assign (var_pool.insert ("<")) = move (ns);
}
@@ -231,6 +241,20 @@ namespace build2
return r;
}
+
+ void environment::
+ set_timeout (const string& t, bool success, const location& l)
+ {
+ fragment_deadline =
+ to_deadline (parse_deadline (t, "buildscript timeout", l),
+ success);
+ }
+
+ optional<deadline> environment::
+ effective_deadline ()
+ {
+ return earlier (script_deadline, fragment_deadline);
+ }
}
}
}