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/script/timeout.cxx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 libbuild2/script/timeout.cxx (limited to 'libbuild2/script/timeout.cxx') diff --git a/libbuild2/script/timeout.cxx b/libbuild2/script/timeout.cxx new file mode 100644 index 0000000..a44e1bb --- /dev/null +++ b/libbuild2/script/timeout.cxx @@ -0,0 +1,26 @@ +// file : libbuild2/script/timeout.cxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#include + +#include + +#include + +using namespace std; + +namespace build2 +{ + optional + parse_timeout (const string& s, const char* what, const location& l) + { + if (optional n = parse_number (s)) + { + return *n != 0 + ? chrono::duration_cast (chrono::seconds (*n)) + : optional (); + } + else + fail (l) << "invalid " << what << " '" << s << "'" << endf; + } +} -- cgit v1.1