From f41599c8e9435f3dfec60b872c2b4ae31177efdd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 10 Oct 2020 17:22:46 +0300 Subject: Add support for test timeouts --- libbuild2/test/init.cxx | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'libbuild2/test/init.cxx') 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 +#include + #include #include #include @@ -44,8 +46,8 @@ namespace build2 // // Specified as @ 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 ("config.test.output"), + // Test operation and individual test execution timeouts (see the + // manual for semantics). + // + vp.insert ("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 (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). // -- cgit v1.1