From 0575ec4e2084c553fa56e3d645233b118936a2d5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 30 Apr 2019 20:26:36 +0300 Subject: Add support for description-type package manifest value --- tests/manifest/driver.cxx | 103 +++++++------ tests/manifest/testscript | 357 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 394 insertions(+), 66 deletions(-) (limited to 'tests/manifest') diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx index 5f8a0f5..6ef6193 100644 --- a/tests/manifest/driver.cxx +++ b/tests/manifest/driver.cxx @@ -20,7 +20,7 @@ using namespace bpkg; // Usages: // // argv[0] (-pp|-dp|-gp|-pr|-dr|-gr|-s) -// argv[0] [-c] -p +// argv[0] -p -c -i // argv[0] -ec // // In the first form read and parse manifest list from stdin and serialize it @@ -35,8 +35,12 @@ using namespace bpkg; // -s parse signature manifest // // In the second form read and parse the package manifest from stdin and -// serialize it to stdout. Complete the dependency constraints if -c is -// specified. Note: -c, if specified, should go before -p on the command line. +// serialize it to stdout. +// +// -c complete the dependency constraints +// -i ignore unknown +// +// Note: the above options should go after -p on the command line. // // In the third form read and parse dependency constraints from stdin and // roundtrip them to stdout together with their effective constraints, @@ -45,18 +49,8 @@ using namespace bpkg; int main (int argc, char* argv[]) { - assert (argc <= 3); - string opt (argv[1]); - - bool complete_depends (opt == "-c"); - - if (complete_depends) - { - opt = argv[2]; - assert (opt == "-p"); - } - - assert ((opt == "-ec" || complete_depends) == (argc == 3)); + assert (argc >= 2); + string mode (argv[1]); cout.exceptions (ios_base::failbit | ios_base::badbit); @@ -65,8 +59,49 @@ main (int argc, char* argv[]) try { - if (opt == "-ec") + if (mode == "-p") { + bool complete_depends (false); + bool ignore_unknown (false); + + for (int i (2); i != argc; ++i) + { + string o (argv[i]); + + if (o == "-c") + complete_depends = true; + else if (o == "-i") + ignore_unknown = true; + else + assert (false); + } + + cin.exceptions (ios_base::failbit | ios_base::badbit); + + package_manifest ( + p, + [] (version& v) + { + // Emulate populating the snapshot information for the latest + // snapshot. + // + if (butl::optional sv = + parse_standard_version (v.string ())) + { + if (sv->latest_snapshot ()) + { + sv->snapshot_sn = 123; + v = version (sv->string ()); + } + } + }, + ignore_unknown, + complete_depends).serialize (s); + } + else if (mode == "-ec") + { + assert (argc == 3); + version v (argv[2]); cin.exceptions (ios_base::badbit); @@ -84,41 +119,23 @@ main (int argc, char* argv[]) } else { + assert (argc == 2); + cin.exceptions (ios_base::failbit | ios_base::badbit); - if (opt == "-p") - package_manifest ( - p, - [] (version& v) - { - // Emulate populating the snapshot information for the latest - // snapshot. - // - if (butl::optional sv = - parse_standard_version (v.string ())) - { - if (sv->latest_snapshot ()) - { - sv->snapshot_sn = 123; - v = version (sv->string ()); - } - } - }, - false /* ignore_unknown */, - complete_depends).serialize (s); - else if (opt == "-pp") + if (mode == "-pp") pkg_package_manifests (p).serialize (s); - else if (opt == "-dp") + else if (mode == "-dp") dir_package_manifests (p).serialize (s); - else if (opt == "-gp") + else if (mode == "-gp") git_package_manifests (p).serialize (s); - else if (opt == "-pr") + else if (mode == "-pr") pkg_repository_manifests (p).serialize (s); - else if (opt == "-dr") + else if (mode == "-dr") dir_repository_manifests (p).serialize (s); - else if (opt == "-gr") + else if (mode == "-gr") git_repository_manifests (p).serialize (s); - else if (opt == "-s") + else if (mode == "-s") signature_manifest (p).serialize (s); else assert (false); diff --git a/tests/manifest/testscript b/tests/manifest/testscript index 99f0132..acf9d3b 100644 --- a/tests/manifest/testscript +++ b/tests/manifest/testscript @@ -100,7 +100,7 @@ : dependency-constraint-version : - $* -c -p <'stdin:6:10: error: invalid dependency constraint: min version is greater than max version' != 0 + $* -p -c <'stdin:6:10: error: invalid dependency constraint: min version is greater than max version' != 0 : 1 name: foo version: 2.0.0 @@ -117,12 +117,37 @@ : manifest : { + test.options += -p + + : invalid + : + { + : description-file + : + $* <>~%EOE% != 0 + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description-file: /README + EOI + %( + stdin:6:19: error: package description-file path is absolute + %| + stdin:6:19: error: invalid package description file: invalid filesystem path + %) + EOE + } + : complete : { + test.options += -c + : final : - $* -c -p <>EOO + $* <>EOO : 1 name: foo version: 2.0.0 @@ -140,7 +165,7 @@ : non-standard : - $* -c -p <>EOO + $* <>EOO : 1 name: foo version: 2.0.0-x @@ -158,7 +183,7 @@ : non-standard-shortcut : - $* -c -p <>EOE != 0 + $* <>EOE != 0 : 1 name: foo version: 2.0.0-x @@ -171,7 +196,7 @@ : latest-snapshot : - $* -c -p <>EOO + $* <>EOO : 1 name: foo version: 2.0.0-a.0.z @@ -192,7 +217,7 @@ : incomplete : - $* -p <>EOF + $* <>EOF : 1 name: foo version: 2.0.0 @@ -200,6 +225,308 @@ license: LGPLv2 depends: bar == $ | libbaz ~$ | libbox ^$ | libfox [1.0 $) EOF + + : description-type + : + { + : absent + : + $* <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + EOO + + : not-text + : + $* <>EOE != 0 + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: image/gif + EOI + stdin:7:19: error: invalid package description type: text type expected + EOE + + : deducing + : + { + : fail + : + $* <>EOE != 0 + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description-file: README.rtf + EOI + stdin:6:19: error: invalid package description file: unknown text type + EOE + + : ignore-unknown + : + $* -i <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description-file: README.rtf + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description-file: README.rtf + EOO + } + + : unknown + : + { + : fail + : + $* <>EOE != 0 + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdowns + EOI + stdin:7:19: error: invalid package description type: unknown text type + EOE + + : ignore + : + $* -i <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdowns + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdowns + EOO + } + + : plain + : + { + : valid + : + $* <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/plain + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/plain + EOO + + : invalid + : + $* <>EOE != 0 + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/plain; + EOI + stdin:7:19: error: invalid package description type: missing '=' + EOE + } + + : markdown + : + { + : default + : + $* <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown + EOO + + : gfm + : + $* <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variant=GFM + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variant=GFM + EOO + + : common-mark + : + $* <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variant=CommonMark + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variant=CommonMark + EOO + + : invalid-variant + : + { + : fail + : + $* <>EOE != 0 + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variant=Original + EOI + stdin:7:19: error: invalid package description type: unknown text type + EOE + + : ignore + : + $* -i <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variant=Original + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variant=Original + EOO + } + + : invalid-parameter + : + { + : fail + : + $* <>EOE != 0 + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variants=GFM + EOI + stdin:7:19: error: invalid package description type: unknown text type + EOE + + : ignore + : + $* -i <>EOO + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variants=GFM + EOI + : 1 + name: libfoo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + description: libfoo is a very modern C++ XML parser. + description-type: text/markdown; variants=GFM + EOO + } + } + } + + : builds + : + { + : invalid + : + { + : empty + : + $* <"stdin:2:9: error: invalid package builds: class expression separator ':' expected" != 0 + : 1 + builds: default -gcc + EOI + } + } } : manifest-list @@ -219,6 +546,7 @@ license: BSD tags: c++, xml, parser, serializer, pull, streaming, modern description: libfoo is a very modern C++ XML parser. + description-type: text/plain changes: 1.2.3+2: applied upstream patch for critical bug bar changes: 1.2.3+1: applied upstream patch for critical bug foo url: http://www.example.org/projects/libfoo/; libfoo project page url @@ -323,23 +651,6 @@ fragment: ca602c2d46b0dca7a9ebc856871767b0ba6b74f3 EOF } - - : builds - : - { - : invalid - : - { - : empty - : - $* -pp <"stdin:4:9: error: invalid package builds: class expression separator ':' expected" != 0 - : 1 - sha256sum: a2b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - : - builds: default -gcc - EOI - } - } } : repositories -- cgit v1.1