aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test/init.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/test/init.cxx
parentac76a4fd2afff48a0d5db84592babe5cabef3a2c (diff)
Add support for test timeouts
Diffstat (limited to 'libbuild2/test/init.cxx')
-rw-r--r--libbuild2/test/init.cxx38
1 files changed, 36 insertions, 2 deletions
diff --git a/libbuild2/test/init.cxx b/libbuild2/test/init.cxx
index aaacdc6..0a47842 100644
--- a/libbuild2/test/init.cxx
+++ b/libbuild2/test/init.cxx
@@ -10,6 +10,8 @@
#include <libbuild2/config/utility.hxx>
+#include <libbuild2/script/timeout.hxx>
+
#include <libbuild2/test/module.hxx>
#include <libbuild2/test/target.hxx>
#include <libbuild2/test/operation.hxx>
@@ -44,8 +46,8 @@ namespace build2
//
// Specified as <target>@<path-id> pairs with both sides being
// optional. The variable is untyped (we want a list of name-pairs),
- // overridable, and with global visibiility. The target is relative
- // (in essence a prerequisite) which is resolved from the (root) scope
+ // overridable, and with global visibility. The target is relative (in
+ // essence a prerequisite) which is resolved from the (root) scope
// where the config.test value is defined.
//
vp.insert ("config.test"),
@@ -55,6 +57,11 @@ namespace build2
//
vp.insert<name_pair> ("config.test.output"),
+ // Test operation and individual test execution timeouts (see the
+ // manual for semantics).
+ //
+ vp.insert<string> ("config.test.timeout"),
+
// The test variable is a name which can be a path (with the
// true/false special values) or a target name.
//
@@ -189,6 +196,33 @@ namespace build2
else fail << "invalid config.test.output before value '" << b << "'";
}
+ // config.test.timeout
+ //
+ if (lookup l = lookup_config (rs, m.config_test_timeout))
+ {
+ const string& t (cast<string> (l));
+
+ const char* ot ("config.test.timeout test operation timeout value");
+ const char* tt ("config.test.timeout test timeout value");
+
+ size_t p (t.find ('/'));
+ if (p != string::npos)
+ {
+ // Note: either of the timeouts can be omitted but not both.
+ //
+ if (t.size () == 1)
+ fail << "invalid config.test.timeout value '" << t << "'";
+
+ if (p != 0)
+ m.operation_timeout = parse_timeout (string (t, 0, p), ot);
+
+ if (p != t.size () - 1)
+ m.test_timeout = parse_timeout (string (t, p + 1), tt);
+ }
+ else
+ m.test_timeout = parse_timeout (t, ot);
+ }
+
//@@ TODO: Need ability to specify extra diff options (e.g.,
// --strip-trailing-cr, now hardcoded).
//