diff options
-rw-r--r-- | libbbot/manifest.cxx | 39 | ||||
-rw-r--r-- | libbbot/manifest.hxx | 27 | ||||
-rw-r--r-- | tests/manifest/machine-header.test | 11 |
3 files changed, 52 insertions, 25 deletions
diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx index c52f3e3..06399f2 100644 --- a/libbbot/manifest.cxx +++ b/libbbot/manifest.cxx @@ -105,8 +105,8 @@ namespace bbot // machine_header_manifest // machine_header_manifest:: - machine_header_manifest (parser& p, bool iu) - : machine_header_manifest (p, p.next (), iu) + machine_header_manifest (parser& p, unknown_name_mode m) + : machine_header_manifest (p, p.next (), m) { // Make sure this is the end. // @@ -117,7 +117,10 @@ namespace bbot } machine_header_manifest:: - machine_header_manifest (parser& p, name_value nv, bool iu) + machine_header_manifest (parser& p, + name_value nv, + unknown_name_mode m, + name_value* e) { auto bad_name = [&p, &nv] (const string& d) { @@ -172,8 +175,18 @@ namespace bbot summary = move (v); } - else if (!iu) - bad_name ("unknown name '" + n + "' in machine header manifest"); + else + { + switch (m) + { + case unknown_name_mode::skip: continue; + case unknown_name_mode::fail: + bad_name ("unknown name '" + n + "' in machine header manifest"); + case unknown_name_mode::stop: break; // Bail out from the loop. + } + + break; + } } // Verify all non-optional values were specified. @@ -186,10 +199,13 @@ namespace bbot if (summary.empty ()) bad_value ("no machine summary specified"); + + if (e != nullptr) + *e = move (nv); } void machine_header_manifest:: - serialize (serializer& s) const + serialize (serializer& s, bool end_of_manifest) const { // @@ Should we check that all non-optional values are specified and all // values are valid? @@ -198,7 +214,9 @@ namespace bbot s.next ("id", id); s.next ("name", name); s.next ("summary", summary); - s.next ("", ""); // End of manifest. + + if (end_of_manifest) + s.next ("", ""); // End of manifest. } // task_request_manifest @@ -296,7 +314,12 @@ namespace bbot // Parse machine header manifests. // for (nv = p.next (); !nv.empty (); nv = p.next ()) - machines.emplace_back (machine_header_manifest (p, nv, iu)); + machines.emplace_back ( + machine_header_manifest (p, + nv, + iu + ? unknown_name_mode::skip + : unknown_name_mode::fail)); if (machines.empty ()) bad_value ("no task request machines specified"); diff --git a/libbbot/manifest.hxx b/libbbot/manifest.hxx index a42eeea..4ae8b26 100644 --- a/libbbot/manifest.hxx +++ b/libbbot/manifest.hxx @@ -34,15 +34,30 @@ namespace bbot : id (std::move (i)), name (std::move (n)), summary (std::move (s)) {} public: + machine_header_manifest () = default; // VC export. - machine_header_manifest (butl::manifest_parser&, - bool ignore_unknown = false); - machine_header_manifest (butl::manifest_parser&, - butl::manifest_name_value start, - bool ignore_unknown = false); + + machine_header_manifest ( + butl::manifest_parser&, + butl::unknown_name_mode = butl::unknown_name_mode::fail); + + machine_header_manifest ( + butl::manifest_parser&, + butl::manifest_name_value start, + butl::unknown_name_mode = butl::unknown_name_mode::fail, + butl::manifest_name_value* end = nullptr); + + // Wrapper-ctor. Primarily for use in template functions parameterized + // with the manifest type. + // + machine_header_manifest (butl::manifest_parser& p, bool ignore_unknown) + : machine_header_manifest (p, + ignore_unknown + ? butl::unknown_name_mode::skip + : butl::unknown_name_mode::fail) {} void - serialize (butl::manifest_serializer&) const; + serialize (butl::manifest_serializer&, bool end_of_manifest = true) const; }; using machine_header_manifests = std::vector<machine_header_manifest>; diff --git a/tests/manifest/machine-header.test b/tests/manifest/machine-header.test index f5f3c94..c70be7f 100644 --- a/tests/manifest/machine-header.test +++ b/tests/manifest/machine-header.test @@ -9,17 +9,6 @@ test.options += -m : Roundtrip the machine header manifest. : { - : kvm - : - $* <<EOF >>EOF - : 1 - id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - name: windows_10-msvc_14 - summary: Windows 10 build 1607 with VC 14 update 3 - EOF - - : nspawn - : $* <<EOF >>EOF : 1 id: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 |