aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-09-03 13:17:40 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-09-03 13:17:40 +0300
commite73b2b4a4ed4c814131782572c007f85fbf442a3 (patch)
treed9c316f9de2d765e4fbeb3767a4d934bc21b951d
parentb777434484dd9654936d81e914b7815526d56b8c (diff)
Add repository-type value to task manifest and rename repository value to repository-url
-rw-r--r--libbbot/manifest.cxx62
-rw-r--r--tests/manifest/task-response.test6
-rw-r--r--tests/manifest/task.test83
3 files changed, 115 insertions, 36 deletions
diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx
index c547198..cc8afb5 100644
--- a/libbbot/manifest.cxx
+++ b/libbbot/manifest.cxx
@@ -445,6 +445,13 @@ namespace bbot
// Parse the task manifest.
//
+ // The repository type value can go after the repository URL value. So we
+ // need to postpone creating the repository location until we went though
+ // all other values.
+ //
+ optional<name_value> repo_url;
+ optional<repository_type> repo_type;
+
for (nv = p.next (); !nv.empty (); nv = p.next ())
{
string& n (nv.name);
@@ -484,25 +491,28 @@ namespace bbot
if (version.release && version.release->empty ())
bad_value ("invalid task package version release");
}
- else if (n == "repository")
+ else if (n == "repository-url")
+ {
+ if (repo_url)
+ bad_name ("task repository URL redefinition");
+
+ if (v.empty ())
+ bad_value ("empty task repository URL");
+
+ repo_url = move (nv);
+ }
+ else if (n == "repository-type")
{
- if (!repository.empty ())
- bad_name ("task repository redefinition");
+ if (repo_type)
+ bad_name ("task repository type redefinition");
try
{
- // Call remote/absolute repository location constructor (throws
- // invalid_argument for relative location).
- //
- // @@ We probably need another name/value pair for the repository
- // type, that should be filled by bbot controller.
- //
- repository = repository_location (repository_url (v),
- repository_type::pkg);
+ repo_type = to_repository_type (v);
}
- catch (const invalid_argument& e)
+ catch (const invalid_argument&)
{
- bad_value (string ("invalid task repository: ") + e.what ());
+ bad_value ("invalid task repository type '" + v + "'");
}
}
else if (n == "trust")
@@ -568,14 +578,33 @@ namespace bbot
if (version.empty ())
bad_value ("no task package version specified");
- if (repository.empty ())
- bad_value ("no task repository specified");
+ if (!repo_url)
+ bad_value ("no task repository URL specified");
+
+ if (!repo_type)
+ bad_value ("no task repository type specified");
if (machine.empty ())
bad_value ("no task machine specified");
if (target.empty ())
bad_value ("no task target specified");
+
+ // Create the repository location.
+ //
+ try
+ {
+ // Call remote/absolute repository location constructor (throws
+ // invalid_argument for relative location).
+ //
+ repository = repository_location (repository_url (repo_url->value),
+ *repo_type);
+ }
+ catch (const invalid_argument& e)
+ {
+ nv = move (*repo_url); // Restore as bad_value() uses its line/column.
+ bad_value (string ("invalid task repository URL: ") + e.what ());
+ }
}
void task_manifest::
@@ -595,7 +624,8 @@ namespace bbot
s.next ("name", name.string ());
s.next ("version", version.string ());
- s.next ("repository", repository.string ());
+ s.next ("repository-url", repository.string ());
+ s.next ("repository-type", to_string (repository.type ()));
for (const auto& v: trust)
s.next ("trust", v);
diff --git a/tests/manifest/task-response.test b/tests/manifest/task-response.test
index f92e43f..c823160 100644
--- a/tests/manifest/task-response.test
+++ b/tests/manifest/task-response.test
@@ -22,7 +22,8 @@ test.options += -ts
:
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows_10-msvc_14
target: x86_64-microsoft-win32-msvc14.0
EOF
@@ -36,7 +37,8 @@ test.options += -ts
:
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows_10-msvc_14
target: x86_64-microsoft-win32-msvc14.0
EOF
diff --git a/tests/manifest/task.test b/tests/manifest/task.test
index a835918..e3f413e 100644
--- a/tests/manifest/task.test
+++ b/tests/manifest/task.test
@@ -15,7 +15,8 @@ test.options += -t
: 1
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
trust: AB:0D:3F:C1:B0:13:E4:0E:AD:4A:08:06:AE:F3:85:DB:E2:27:5F:83:11:47:A2:7\
8:64:3C:73:60:F8:66:3A:A4
machine: windows_10-msvc_14
@@ -30,7 +31,8 @@ test.options += -t
: 1
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows_10-msvc_14
target: x86_64-microsoft-win32-msvc14.0
EOF
@@ -44,7 +46,8 @@ test.options += -t
: 1
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows
target: x86_64-microsoft-win32-msvc14.0
config: abc=
@@ -56,7 +59,8 @@ test.options += -t
: 1
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows
target: x86_64-microsoft-win32-msvc14.0
config: abc='a "b '"d\e x y="
@@ -69,7 +73,8 @@ test.options += -t
: 1
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
trust: yes
machine: windows_10-msvc_14
target: x86_64-microsoft-win32-msvc14.0
@@ -98,10 +103,10 @@ test.options += -t
: repository
:
- $* <<EOI 2>'stdin:3:1: error: task repository redefinition' == 1
+ $* <<EOI 2>'stdin:3:1: error: task repository URL redefinition' == 1
: 1
- repository: http://pkg.example.org/1/math
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
EOI
: machine
@@ -165,6 +170,33 @@ test.options += -t
EOI
}
+ : repository
+ :
+ {
+ : url
+ :
+ $* <<EOI 2>>EOE == 1
+ : 1
+ name: libfoo
+ version: 1.0
+ repository-url: http://pkg.example.org/math
+ repository-type: pkg
+ machine: windows_10-msvc_14
+ target: x86_64-microsoft-win32-msvc14.0
+ EOI
+ stdin:4:17: error: invalid task repository URL: missing repository version
+ EOE
+
+ : type
+ :
+ $* <<EOI 2>>EOE == 1
+ : 1
+ repository-type: svn
+ EOI
+ stdin:2:18: error: invalid task repository type 'svn'
+ EOE
+ }
+
: machine-empty
:
$* <<EOI 2>'stdin:2:9: error: empty task machine' == 1
@@ -250,47 +282,62 @@ EOI
{
: name
:
- $* <<EOI 2>'stdin:5:1: error: no task package name specified' == 1
+ $* <<EOI 2>'stdin:6:1: error: no task package name specified' == 1
: 1
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows_10-msvc_14
EOI
: version
:
- $* <<EOI 2>'stdin:5:1: error: no task package version specified' == 1
+ $* <<EOI 2>'stdin:6:1: error: no task package version specified' == 1
: 1
name: libfoo
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows_10-msvc_14
EOI
- : repository
+ : repository-url
+ :
+ $* <<EOI 2>'stdin:6:1: error: no task repository URL specified' == 1
+ : 1
+ name: libfoo
+ version: 1.0
+ machine: windows_10-msvc_14
+ repository-type: git
+ EOI
+
+ : repository-type
:
- $* <<EOI 2>'stdin:5:1: error: no task repository specified' == 1
+ $* <<EOI 2>'stdin:6:1: error: no task repository type specified' == 1
: 1
name: libfoo
version: 1.0
+ repository-url: http://pkg.example.org/1/math
machine: windows_10-msvc_14
EOI
: machine
:
- $* <<EOI 2>'stdin:5:1: error: no task machine specified' == 1
+ $* <<EOI 2>'stdin:6:1: error: no task machine specified' == 1
: 1
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
EOI
: target
:
- $* <<EOI 2>'stdin:6:1: error: no task target specified' == 1
+ $* <<EOI 2>'stdin:7:1: error: no task target specified' == 1
: 1
name: libfoo
version: 1.0
- repository: http://pkg.example.org/1/math
+ repository-url: http://pkg.example.org/1/math
+ repository-type: pkg
machine: windows_10-msvc_14
EOI
}