aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-12-09 15:10:56 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-12-11 14:31:39 +0300
commit32f153664e7b6cadfb518b83e12b9768a150d709 (patch)
tree706d683404d412e29e4cbd4640ce8b2780689c65 /libbuild2
parentec16a07c4bc3f3552ba5b4d09d3c5c375fb19e35 (diff)
Prefix pseudo-builtin diagnostincs messages with their names
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/build/script/script.cxx5
-rw-r--r--libbuild2/script/run.cxx16
-rw-r--r--libbuild2/script/timeout.cxx7
-rw-r--r--libbuild2/script/timeout.hxx6
-rw-r--r--libbuild2/script/timeout.ixx7
-rw-r--r--libbuild2/test/script/script.cxx14
6 files changed, 34 insertions, 21 deletions
diff --git a/libbuild2/build/script/script.cxx b/libbuild2/build/script/script.cxx
index e003b6a..14dd9e1 100644
--- a/libbuild2/build/script/script.cxx
+++ b/libbuild2/build/script/script.cxx
@@ -253,8 +253,9 @@ namespace build2
set_timeout (const string& t, bool success, const location& l)
{
fragment_deadline =
- to_deadline (parse_deadline (t, "buildscript timeout", l),
- success);
+ to_deadline (
+ parse_deadline (t, "buildscript timeout", "timeout: ", l),
+ success);
}
optional<deadline> environment::
diff --git a/libbuild2/script/run.cxx b/libbuild2/script/run.cxx
index 90ddc4d..b1bc888 100644
--- a/libbuild2/script/run.cxx
+++ b/libbuild2/script/run.cxx
@@ -782,12 +782,12 @@ namespace build2
timeout_options ops (scan);
if (!scan.more ())
- fail (ll) << "missing timeout";
+ fail (ll) << "timeout: missing timeout";
string a (scan.next ());
if (scan.more ())
- fail (ll) << "unexpected argument '" << scan.next () << "'";
+ fail (ll) << "timeout: unexpected argument '" << scan.next () << "'";
env.set_timeout (a, ops.success (), ll);
}
@@ -820,7 +820,7 @@ namespace build2
const string& s (*i++);
if (i != e)
- fail (ll) << "unexpected argument '" << *i << "'";
+ fail (ll) << "exit: unexpected argument '" << *i << "'";
error (ll) << s;
throw exit (false);
@@ -861,23 +861,23 @@ namespace build2
set_options ops (scan);
if (ops.whitespace () && ops.newline ())
- fail (ll) << "both -n|--newline and -w|--whitespace specified";
+ fail (ll) << "set: both -n|--newline and -w|--whitespace specified";
if (!scan.more ())
- fail (ll) << "missing variable name";
+ fail (ll) << "set: missing variable name";
string a (scan.next ()); // Either attributes or variable name.
const string* ats (!scan.more () ? nullptr : &a);
string vname (!scan.more () ? move (a) : scan.next ());
if (scan.more ())
- fail (ll) << "unexpected argument '" << scan.next () << "'";
+ fail (ll) << "set: unexpected argument '" << scan.next () << "'";
if (ats != nullptr && ats->empty ())
- fail (ll) << "empty variable attributes";
+ fail (ll) << "set: empty variable attributes";
if (vname.empty ())
- fail (ll) << "empty variable name";
+ fail (ll) << "set: empty variable name";
// Read out the stream content into a string while keeping an eye on
// the deadline. Then parse it according to the split mode.
diff --git a/libbuild2/script/timeout.cxx b/libbuild2/script/timeout.cxx
index a44e1bb..63cc61a 100644
--- a/libbuild2/script/timeout.cxx
+++ b/libbuild2/script/timeout.cxx
@@ -12,7 +12,10 @@ using namespace std;
namespace build2
{
optional<duration>
- parse_timeout (const string& s, const char* what, const location& l)
+ parse_timeout (const string& s,
+ const char* what,
+ const char* prefix,
+ const location& l)
{
if (optional<uint64_t> n = parse_number (s))
{
@@ -21,6 +24,6 @@ namespace build2
: optional<duration> ();
}
else
- fail (l) << "invalid " << what << " '" << s << "'" << endf;
+ fail (l) << prefix << "invalid " << what << " '" << s << "'" << endf;
}
}
diff --git a/libbuild2/script/timeout.hxx b/libbuild2/script/timeout.hxx
index 9991ad6..4ab43a5 100644
--- a/libbuild2/script/timeout.hxx
+++ b/libbuild2/script/timeout.hxx
@@ -10,12 +10,13 @@
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.
+ // zero and nullopt otherwise. Issue diagnostics with an optional prefix and
+ // fail if the argument is not a valid timeout.
//
optional<duration>
parse_timeout (const string&,
const char* what,
+ const char* prefix = "",
const location& = location ());
// As above, but return the timepoint which is away from now by the
@@ -24,6 +25,7 @@ namespace build2
optional<timestamp>
parse_deadline (const string&,
const char* what,
+ const char* prefix = "",
const location& = location ());
// Return the earlier timeout/deadline of two values, if any is present.
diff --git a/libbuild2/script/timeout.ixx b/libbuild2/script/timeout.ixx
index 755af17..e31ed07 100644
--- a/libbuild2/script/timeout.ixx
+++ b/libbuild2/script/timeout.ixx
@@ -4,9 +4,12 @@
namespace build2
{
inline optional<timestamp>
- parse_deadline (const string& s, const char* what, const location& l)
+ parse_deadline (const string& s,
+ const char* what,
+ const char* prefix,
+ const location& l)
{
- if (optional<duration> t = parse_timeout (s, what, l))
+ if (optional<duration> t = parse_timeout (s, what, prefix, l))
return system_clock::now () + *t;
else
return nullopt;
diff --git a/libbuild2/test/script/script.cxx b/libbuild2/test/script/script.cxx
index cb367bc..b539c71 100644
--- a/libbuild2/test/script/script.cxx
+++ b/libbuild2/test/script/script.cxx
@@ -480,6 +480,7 @@ namespace build2
: "testscript timeout");
const char* tt ("test timeout");
+ const char* pf ("timeout: ");
size_t p (t.find ('/'));
if (p != string::npos)
@@ -491,15 +492,17 @@ namespace build2
if (p != 0)
group_deadline =
- to_deadline (parse_deadline (string (t, 0, p), gt, l),
+ to_deadline (parse_deadline (string (t, 0, p), gt, pf, l),
success);
if (p != t.size () - 1)
test_timeout =
- to_timeout (parse_timeout (string (t, p + 1), tt, l), success);
+ to_timeout (parse_timeout (string (t, p + 1), tt, pf, l),
+ success);
}
else
- group_deadline = to_deadline (parse_deadline (t, gt, l), success);
+ group_deadline = to_deadline (parse_deadline (t, gt, pf, l),
+ success);
}
optional<deadline> group::
@@ -516,8 +519,9 @@ namespace build2
set_timeout (const string& t, bool success, const location& l)
{
fragment_deadline =
- to_deadline (parse_deadline (t, "test fragment timeout", l),
- success);
+ to_deadline (
+ parse_deadline (t, "test fragment timeout", "timeout: ", l),
+ success);
}
optional<deadline> test::