aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbbot/manifest.cxx44
-rw-r--r--libbbot/manifest.hxx13
-rw-r--r--tests/manifest/result.test2
-rw-r--r--tests/manifest/task.test2
4 files changed, 43 insertions, 18 deletions
diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx
index 3a31f55..7da3dd4 100644
--- a/libbbot/manifest.cxx
+++ b/libbbot/manifest.cxx
@@ -455,10 +455,14 @@ namespace bbot
if (!name.empty ())
bad_name ("task package name redefinition");
- if (v.empty ())
- bad_value ("empty task package name");
-
- name = move (v);
+ try
+ {
+ name = package_name (move (v));
+ }
+ catch (const invalid_argument& e)
+ {
+ bad_value (string ("invalid task package name: ") + e.what ());
+ }
}
else if (n == "version")
{
@@ -584,7 +588,15 @@ namespace bbot
// values are valid?
//
s.next ("", "1"); // Start of manifest.
- s.next ("name", name);
+
+ auto bad_value ([&s](const string& d) {
+ throw serialization (s.name (), d);});
+
+ if (name.empty ())
+ bad_value ("empty task package name");
+
+ s.next ("name", name.string ());
+
s.next ("version", version.string ());
s.next ("repository", repository.string ());
@@ -857,10 +869,14 @@ namespace bbot
if (!name.empty ())
bad_name ("result package name redefinition");
- if (v.empty ())
- bad_value ("empty result package name");
-
- name = move (v);
+ try
+ {
+ name = package_name (move (v));
+ }
+ catch (const invalid_argument& e)
+ {
+ bad_value (string ("invalid result package name: ") + e.what ());
+ }
}
else if (n == "version")
{
@@ -973,7 +989,15 @@ namespace bbot
// values are valid?
//
s.next ("", "1"); // Start of manifest.
- s.next ("name", name);
+
+ auto bad_value ([&s](const string& d) {
+ throw serialization (s.name (), d);});
+
+ if (name.empty ())
+ bad_value ("empty result package name");
+
+ s.next ("name", name.string ());
+
s.next ("version", version.string ());
s.next ("status", to_string (status));
diff --git a/libbbot/manifest.hxx b/libbbot/manifest.hxx
index fcb1056..163c75e 100644
--- a/libbbot/manifest.hxx
+++ b/libbbot/manifest.hxx
@@ -14,7 +14,8 @@
#include <libbutl/standard-version.mxx>
#include <libbutl/manifest-forward.hxx>
-#include <libbpkg/manifest.hxx> // version, repository_location
+#include <libbpkg/manifest.hxx> // version, repository_location
+#include <libbpkg/package-name.hxx>
#include <libbbot/export.hxx>
#include <libbbot/version.hxx>
@@ -107,8 +108,8 @@ namespace bbot
public:
// Package to build.
//
- std::string name;
- bpkg::version version;
+ bpkg::package_name name;
+ bpkg::version version;
bpkg::repository_location repository; // Remote or absolute.
// The SHA256 repositories certificates fingerprints to trust. The special
@@ -139,7 +140,7 @@ namespace bbot
strings
unquoted_warning_regex () const;
- task_manifest (std::string nm,
+ task_manifest (bpkg::package_name nm,
bpkg::version vr,
bpkg::repository_location rl,
strings tr,
@@ -264,7 +265,7 @@ namespace bbot
// by the worker to signal abnormal termination before being able to
// obtain the package name/version.
//
- std::string name;
+ bpkg::package_name name;
bpkg::version version;
result_status status;
@@ -275,7 +276,7 @@ namespace bbot
//
operation_results results;
- result_manifest (std::string n,
+ result_manifest (bpkg::package_name n,
bpkg::version v,
result_status s,
operation_results r)
diff --git a/tests/manifest/result.test b/tests/manifest/result.test
index 2735e53..54f60ed 100644
--- a/tests/manifest/result.test
+++ b/tests/manifest/result.test
@@ -114,7 +114,7 @@ test.options += -r
{
: name-empty
:
- $* <<EOI 2>'stdin:2:6: error: empty result package name' == 1
+ $* <<EOI 2>'stdin:2:6: error: invalid result package name: length is less than two characters' == 1
: 1
name:
EOI
diff --git a/tests/manifest/task.test b/tests/manifest/task.test
index c78ce19..a835918 100644
--- a/tests/manifest/task.test
+++ b/tests/manifest/task.test
@@ -142,7 +142,7 @@ test.options += -t
{
: name-empty
:
- $* <<EOI 2>'stdin:2:6: error: empty task package name' == 1
+ $* <<EOI 2>'stdin:2:6: error: invalid task package name: length is less than two characters' == 1
: 1
name:
EOI