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/script.hxx | |
parent | ac76a4fd2afff48a0d5db84592babe5cabef3a2c (diff) |
Add support for test timeouts
Diffstat (limited to 'libbuild2/script/script.hxx')
-rw-r--r-- | libbuild2/script/script.hxx | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/libbuild2/script/script.hxx b/libbuild2/script/script.hxx index 4a62c77..ecd2c2b 100644 --- a/libbuild2/script/script.hxx +++ b/libbuild2/script/script.hxx @@ -308,8 +308,9 @@ namespace build2 // process_path program; - strings arguments; - environment_vars variables; + strings arguments; + environment_vars variables; // From env builtin. + optional<duration> timeout; // From env builtin. optional<redirect> in; optional<redirect> out; @@ -363,6 +364,37 @@ namespace build2 ostream& operator<< (ostream&, const command_expr&); + struct timeout + { + duration value; + bool success; + + timeout (duration d, bool s): value (d), success (s) {} + }; + + struct deadline + { + timestamp value; + bool success; + + deadline (timestamp t, bool s): value (t), success (s) {} + }; + + // If timestamps/durations are equal, the failure is less than the + // success. + // + bool + operator< (const deadline&, const deadline&); + + bool + operator< (const timeout&, const timeout&); + + optional<deadline> + to_deadline (const optional<timestamp>&, bool success); + + optional<timeout> + to_timeout (const optional<duration>&, bool success); + // Script execution environment. // class environment @@ -469,6 +501,23 @@ namespace build2 const string& attrs, const location&) = 0; + // Set the script execution timeout from the timeout builtin call. + // + // The builtin argument semantics is script implementation-dependent. If + // success is true then a process missing this deadline should not be + // considered as failed unless it didn't terminate gracefully and had to + // be killed. + // + virtual void + set_timeout (const string& arg, bool success, const location&) = 0; + + // Return the script execution deadline which can potentially rely on + // factors besides the latest timeout builtin call (variables, scoping, + // etc). + // + virtual optional<deadline> + effective_deadline () = 0; + // Create the temporary directory and set the temp_dir reference target // to its path. Must only be called if temp_dir is empty. // |