diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-10-10 17:22:46 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-11-06 19:32:09 +0300 |
commit | f41599c8e9435f3dfec60b872c2b4ae31177efdd (patch) | |
tree | 088f8d9bf906e4a2ed734e034699163c9ccc7306 /libbuild2/script/timeout.hxx | |
parent | ac76a4fd2afff48a0d5db84592babe5cabef3a2c (diff) |
Add support for test timeouts
Diffstat (limited to 'libbuild2/script/timeout.hxx')
-rw-r--r-- | libbuild2/script/timeout.hxx | 52 |
1 files changed, 52 insertions, 0 deletions
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 <libbuild2/types.hxx> +#include <libbuild2/utility.hxx> + +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<duration> + 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<timestamp> + 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 <typename T> + T + earlier (const T&, const T&); + + template <typename T> + T + earlier (const optional<T>&, const T&); + + template <typename T> + T + earlier (const T&, const optional<T>&); + + template <typename T> + optional<T> + earlier (const optional<T>&, const optional<T>&); +} + +#include <libbuild2/script/timeout.ixx> + +#endif // LIBBUILD2_SCRIPT_TIMEOUT_HXX |