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.hxx | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 libbuild2/script/timeout.hxx (limited to 'libbuild2/script/timeout.hxx') diff --git a/libbuild2/script/timeout.hxx b/libbuild2/script/timeout.hxx new file mode 100644 index 0000000..9991ad6 --- /dev/null +++ b/libbuild2/script/timeout.hxx @@ -0,0 +1,52 @@ +// file : libbuild2/script/timeout.hxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#ifndef LIBBUILD2_SCRIPT_TIMEOUT_HXX +#define LIBBUILD2_SCRIPT_TIMEOUT_HXX + +#include +#include + +namespace build2 +{ + // Parse the specified in seconds timeout returning it if the value is not + // zero and nullopt otherwise. Issue diagnostics and fail if the argument is + // not a valid timeout. + // + optional + parse_timeout (const string&, + const char* what, + const location& = location ()); + + // As above, but return the timepoint which is away from now by the + // specified timeout. + // + optional + parse_deadline (const string&, + const char* what, + const location& = location ()); + + // Return the earlier timeout/deadline of two values, if any is present. + // + // Note that earlier(nullopt, v) and earlier(v, nullopt) return v. + // + template + T + earlier (const T&, const T&); + + template + T + earlier (const optional&, const T&); + + template + T + earlier (const T&, const optional&); + + template + optional + earlier (const optional&, const optional&); +} + +#include + +#endif // LIBBUILD2_SCRIPT_TIMEOUT_HXX -- cgit v1.1