aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbot/manifest2
-rw-r--r--bbot/manifest.cxx30
-rw-r--r--tests/manifest/task-response.test39
3 files changed, 65 insertions, 6 deletions
diff --git a/bbot/manifest b/bbot/manifest
index 218282f..44e2662 100644
--- a/bbot/manifest
+++ b/bbot/manifest
@@ -131,7 +131,7 @@ namespace bbot
//
std::string session;
- // Challenge and task are absent if session is empty.
+ // Challenge, result url and task are absent if session is empty.
//
butl::optional<std::string> challenge;
butl::optional<std::string> result_url;
diff --git a/bbot/manifest.cxx b/bbot/manifest.cxx
index 35e472c..b183596 100644
--- a/bbot/manifest.cxx
+++ b/bbot/manifest.cxx
@@ -538,6 +538,16 @@ namespace bbot
challenge = move (v);
}
+ else if (n == "result-url")
+ {
+ if (result_url)
+ bad_name ("task response result url redefinition");
+
+ if (v.empty ())
+ bad_value ("empty task response result url");
+
+ result_url = move (v);
+ }
else if (!iu)
bad_name ("unknown name '" + n + "' in task response manifest");
}
@@ -550,16 +560,25 @@ namespace bbot
session = move (*sess);
- // If session is not empty then the challenge must present, otherwise it
- // shouldn't.
+ // If session is not empty then the challenge and the result url must
+ // present, otherwise they shouldn't.
//
if (!session.empty ())
{
if (!challenge)
bad_value ("no task response challenge specified");
+
+ if (!result_url)
+ bad_value ("no task response result url specified");
+ }
+ else
+ {
+ if (challenge)
+ bad_value ("unexpected task response challenge");
+
+ if (result_url)
+ bad_value ("unexpected task response result url");
}
- else if (challenge)
- bad_value ("unexpected task response challenge");
// If session is not empty then the task manifest must follow, otherwise it
// shouldn't.
@@ -595,6 +614,9 @@ namespace bbot
if (challenge)
s.next ("challenge", *challenge);
+ if (result_url)
+ s.next ("result-url", *result_url);
+
s.next ("", ""); // End of manifest.
if (task)
diff --git a/tests/manifest/task-response.test b/tests/manifest/task-response.test
index 472cca7..22bdded 100644
--- a/tests/manifest/task-response.test
+++ b/tests/manifest/task-response.test
@@ -15,6 +15,7 @@ test.options += -ts
: 1
session: abcd
challenge: xyz
+ result-url: https://cppget.org/?build-result
:
name: libfoo
version: 1.0
@@ -48,6 +49,14 @@ test.options += -ts
challenge: xyz
challenge: xyz
EOI
+
+ : result-url
+ :
+ $* <<EOI 2>'stdin:3:1: error: task response result url redefinition' == 1
+ : 1
+ result-url: https://cppget.org/?build-result
+ result-url: https://cppget.org/?build-result
+ EOI
}
: invalid
@@ -72,6 +81,25 @@ test.options += -ts
EOI
}
+ : result-url
+ :
+ {
+ : empty
+ :
+ $* <<EOI 2>'stdin:2:12: error: empty task response result url' == 1
+ : 1
+ result-url:
+ EOI
+
+ : redundant
+ :
+ $* <<EOI 2>'stdin:4:1: error: unexpected task response result url' == 1
+ : 1
+ session:
+ result-url: https://cppget.org/?build-result
+ EOI
+ }
+
: task-unexpected
:
$* <<EOI 2>'stdin:3:1: error: single task response manifest expected' == 1
@@ -104,11 +132,20 @@ EOI
session: abc
EOI
+ : result-url
+ :
+ $* <<EOI 2>'stdin:4:1: error: no task response result url specified' == 1
+ : 1
+ session: abc
+ challenge: xyz
+ EOI
+
: task
:
- $* <<EOI 2>'stdin:4:1: error: task manifest expected' == 1
+ $* <<EOI 2>'stdin:5:1: error: task manifest expected' == 1
: 1
session: abcd
challenge: xyz
+ result-url: https://cppget.org/?build-result
EOI
}