From e6153b23d0824abdb324191e1622bfd4226dc38b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 May 2017 15:57:06 +0200 Subject: Soft-fail if result manifest is broken --- bbot/agent.cxx | 9 ++++++++- bbot/utility.hxx | 5 ++++- bbot/utility.txx | 27 +++++++++++++++++---------- 3 files changed, 29 insertions(+), 12 deletions(-) (limited to 'bbot') diff --git a/bbot/agent.cxx b/bbot/agent.cxx index 671f1c0..b2d09d1 100644 --- a/bbot/agent.cxx +++ b/bbot/agent.cxx @@ -691,7 +691,14 @@ try // Parse the result manifest. // - r = parse_manifest (rf, "result"); + try + { + r = parse_manifest (rf, "result", false); + } + catch (const failed&) + { + r.status = result_status::abnormal; // Soft-fail below. + } // If the build terminated abnormally, suspent the machine for // investigation (note that here we don't wait or return). diff --git a/bbot/utility.hxx b/bbot/utility.hxx index 73804a4..0506293 100644 --- a/bbot/utility.hxx +++ b/bbot/utility.hxx @@ -136,7 +136,10 @@ namespace bbot // template T - parse_manifest (const path&, const char* what, bool ignore_unknown = true); + parse_manifest (const path&, + const char* what, + bool fail_hard = true, + bool ignore_unknown = true); template T diff --git a/bbot/utility.txx b/bbot/utility.txx index 688eb9c..31f9cdf 100644 --- a/bbot/utility.txx +++ b/bbot/utility.txx @@ -155,26 +155,33 @@ namespace bbot // template T - parse_manifest (const path& f, const char* what, bool ignore_unknown) + parse_manifest (const path& f, const char* what, bool fh, bool iu) { using namespace butl; try { if (f.string () == "-") - return parse_manifest (std::cin, "stdin", what, ignore_unknown); + return parse_manifest (std::cin, "stdin", what, fh, iu); - if (!file_exists (f)) - fail << what << " manifest file " << f << " does not exist"; + if (file_exists (f)) + { + ifdstream ifs (f); + return parse_manifest (ifs, f.string (), what, fh, iu); + } - ifdstream ifs (f); - return parse_manifest (ifs, f.string (), what, true, ignore_unknown); + diag_record dr; if (fh) dr << fail; else dr << error; + + dr << what << " manifest file " << f << " does not exist"; } catch (const system_error& e) // EACCES, etc. { - fail << "unable to access " << what << " manifest " << f << ": " << e - << endf; + diag_record dr; if (fh) dr << fail; else dr << error; + + dr << "unable to access " << what << " manifest " << f << ": " << e; } + + throw failed (); } template @@ -183,14 +190,14 @@ namespace bbot const string& name, const char* what, bool fh, - bool ignore_unknown) + bool iu) { using namespace butl; try { manifest_parser p (is, name); - return T (p, ignore_unknown); + return T (p, iu); } catch (const manifest_parsing& e) { -- cgit v1.1