aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-06-20 00:21:24 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-06-20 12:45:19 +0300
commitfc90de96c43a2c2c73a54f15655f2bf4eae9a28e (patch)
tree36f34b32efeec4f2ab24bf09f8127b299f7d85da
parentf58adbc887abd4f467b483be953ecce7794255fc (diff)
Make bbot worker to set operation warning status
-rw-r--r--bbot/worker.cxx58
1 files changed, 50 insertions, 8 deletions
diff --git a/bbot/worker.cxx b/bbot/worker.cxx
index 82dc318..3e0def5 100644
--- a/bbot/worker.cxx
+++ b/bbot/worker.cxx
@@ -8,6 +8,7 @@
# include <stdlib.h> // getenv(), _putenv()
#endif
+#include <regex>
#include <iostream>
#include <libbutl/pager.hxx>
@@ -55,9 +56,17 @@ catch (const system_error& e)
fail << "unable to change current directory to " << d << ": " << e << endf;
}
+using regexes = vector<regex>;
+
+// If warn_detect argument is not NULL, match lines read from the command's
+// stderr against the regular expressions and return the warning result
+// status (instead of success) in case of a match.
+//
template <typename... A>
static result_status
-run_bpkg (tracer& t, string& log, const string& cmd, A&&... a)
+run_bpkg (tracer& t,
+ string& log, const regexes& warn_detect,
+ const string& cmd, A&&... a)
{
try
{
@@ -87,6 +96,8 @@ run_bpkg (tracer& t, string& log, const string& cmd, A&&... a)
pipe.out.close ();
+ result_status r (result_status::success);
+
// Log the diagnostics.
//
{
@@ -97,11 +108,26 @@ run_bpkg (tracer& t, string& log, const string& cmd, A&&... a)
getline (is, l);
log += l;
log += '\n';
+
+ // Match the log line with the warning-detecting regular expressions
+ // until the first match.
+ //
+ if (r != result_status::warning)
+ {
+ for (const auto& re: warn_detect)
+ {
+ if (regex_search (l, re))
+ {
+ r = result_status::warning;
+ break;
+ }
+ }
+ }
}
}
if (pr.wait ())
- return result_status::success;
+ return r;
log += "bpkg " + cmd;
const process_exit& e (*pr.exit);
@@ -169,6 +195,22 @@ build (size_t argc, const char* argv[])
for (;;) // The "breakout" loop.
{
+ // Regular expressions that detect different forms of build2 toolchain
+ // warnings. Accidently (or not), they also cover GCC and Clang warnings
+ // (for the English locale).
+ //
+ // The expressions will be matched multiple times, so let's make the
+ // matching faster, with the potential cost of making regular expressions
+ // creation slower.
+ //
+ regex::flag_type f (regex_constants::optimize); // ECMAScript is implied.
+
+ regexes wre ({
+ regex ("^warning: ", f),
+ regex ("^.+: warning: ", f),
+ regex ("^.+:\\d+: warning: ", f),
+ regex ("^.+:\\d+:\\d+: warning: ", f)});
+
// Configure.
//
{
@@ -182,7 +224,7 @@ build (size_t argc, const char* argv[])
//
dir_path dir (tm.target ? tm.target->string () : tm.machine);
- r.status |= run_bpkg (trace, r.log,
+ r.status |= run_bpkg (trace, r.log, wre,
"create",
"-d", dir.string (),
"--wipe",
@@ -196,7 +238,7 @@ build (size_t argc, const char* argv[])
// bpkg add <repository-url>
//
- r.status |= run_bpkg (trace, r.log, "add", tm.repository.string ());
+ r.status |= run_bpkg (trace, r.log, wre, "add", tm.repository.string ());
if (!r.status)
break;
@@ -217,14 +259,14 @@ build (size_t argc, const char* argv[])
}
}
- r.status |= run_bpkg (trace, r.log, "fetch", ts, t);
+ r.status |= run_bpkg (trace, r.log, wre, "fetch", ts, t);
if (!r.status)
break;
// bpkg build --configure-only <package-name>/<package-version>
//
- r.status |= run_bpkg (trace, r.log,
+ r.status |= run_bpkg (trace, r.log, wre,
"build",
"--configure-only",
"--yes",
@@ -243,7 +285,7 @@ build (size_t argc, const char* argv[])
// bpkg update <package-name>
//
- r.status |= run_bpkg (trace, r.log, "update", tm.name);
+ r.status |= run_bpkg (trace, r.log, wre, "update", tm.name);
if (!r.status)
break;
@@ -258,7 +300,7 @@ build (size_t argc, const char* argv[])
// bpkg test <package-name>
//
- r.status |= run_bpkg (trace, r.log, "test", tm.name);
+ r.status |= run_bpkg (trace, r.log, wre, "test", tm.name);
if (!r.status)
break;