diff options
Diffstat (limited to 'tests/load/driver.cxx')
-rw-r--r-- | tests/load/driver.cxx | 159 |
1 files changed, 98 insertions, 61 deletions
diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx index 8192827..0f2c8de 100644 --- a/tests/load/driver.cxx +++ b/tests/load/driver.cxx @@ -3,15 +3,14 @@ #include <iostream> #include <exception> -#include <algorithm> // sort(), find() #include <odb/session.hxx> #include <odb/transaction.hxx> #include <odb/pgsql/database.hxx> -#include <libbutl/process.mxx> -#include <libbutl/filesystem.mxx> +#include <libbutl/process.hxx> +#include <libbutl/filesystem.hxx> #include <libbrep/types.hxx> #include <libbrep/utility.hxx> @@ -19,6 +18,9 @@ #include <libbrep/package.hxx> #include <libbrep/package-odb.hxx> +#undef NDEBUG +#include <cassert> + using std::cerr; using std::endl; @@ -27,7 +29,6 @@ using namespace butl; using namespace brep; using labels = small_vector<string, 5>; -using req_alts = small_vector<string, 1>; static const path packages ("packages.manifest"); static const path repositories ("repositories.manifest"); @@ -37,7 +38,7 @@ check_location (shared_ptr<package>& p) { if (p->internal ()) return p->location && *p->location == - path (p->name.string () + "-" + p->version.string () + ".tar.gz"); + path (p->name.string () + '-' + p->version.string () + ".tar.gz"); else return !p->location; } @@ -56,7 +57,7 @@ check_external (const package& p) !p.internal () && p.other_repositories.size () > 0 && p.priority == priority () && - p.changes.empty () && + !p.changes && p.license_alternatives.empty () && p.dependencies.empty () && p.requirements.empty () && @@ -210,7 +211,7 @@ dep (const char* n, optional<version_constraint> c) static inline version dep_ver (const char* v) { - return version (v, false /* fold_zero_revision */); + return version (v, version::none); } static void @@ -267,7 +268,7 @@ test_git_repos (const cstrings& loader_args, assert (p->dependencies.size () == 1); assert (p->dependencies[0].size () == 1); - assert (p->dependencies[0][0] == + assert (p->dependencies[0][0][0] == dep ("libmisc", version_constraint ( dep_ver ("1.0"), false, dep_ver ("1.0"), false))); @@ -383,7 +384,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpvxy->other_repositories.empty ()); assert (fpvxy->priority == priority::low); - assert (fpvxy->changes.empty ()); + assert (!fpvxy->changes); assert (fpvxy->license_alternatives.size () == 1); assert (fpvxy->license_alternatives[0].size () == 1); @@ -395,7 +396,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (fpvxy)); assert (fpvxy->sha256sum && *fpvxy->sha256sum == - "c994fd49f051ab7fb25f3a4e68ca878e484c5d3c2cb132b37d41224b0621b618"); + "c25e5cae2f72664a3961c3ef88a82e67150c4bcc2a5e1fb4d250e621c5574187"); assert (fpvxy->buildable); @@ -419,7 +420,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv1->other_repositories[1].load () == cr); assert (fpv1->priority == priority::low); - assert (fpv1->changes.empty ()); + assert (!fpv1->changes); assert (fpv1->license_alternatives.size () == 1); assert (fpv1->license_alternatives[0].size () == 1); @@ -431,7 +432,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (fpv1)); assert (fpv1->sha256sum && *fpv1->sha256sum == - "e89c6d746f8b1ea3ec58d294946d2f683d133438d2ac8c88549ba24c19627e76"); + "7382152bac5b4ce10215a5ecd6c94c490d0efc007031d3b03f407d068b74e624"); assert (fpv1->buildable); @@ -453,7 +454,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv2->internal_repository.load () == sr); assert (fpv2->other_repositories.empty ()); assert (fpv2->priority == priority::low); - assert (fpv2->changes.empty ()); + assert (!fpv2->changes); assert (fpv2->license_alternatives.size () == 1); assert (fpv2->license_alternatives[0].size () == 1); @@ -463,12 +464,12 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv2->dependencies[0].size () == 1); assert (fpv2->dependencies[1].size () == 1); - assert (fpv2->dependencies[0][0] == + assert (fpv2->dependencies[0][0][0] == dep ("libbar", version_constraint ( nullopt, true, dep_ver ("2.4.0"), false))); - assert (fpv2->dependencies[1][0] == + assert (fpv2->dependencies[1][0][0] == dep ("libexp", version_constraint ( dep_ver ("+2-1.2"), false, dep_ver ("+2-1.2"), false))); @@ -476,7 +477,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (fpv2)); assert (fpv2->sha256sum && *fpv2->sha256sum == - "088068ea3d69542a153f829cf836013374763148fba0a43d8047974f58b5efd7"); + "75d2a7d3eec62d63afd3d3a84d91bd02b05ecb16cd0907d5b0db1fc654e3753f"); assert (!fpv2->buildable); @@ -499,7 +500,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv2a->internal_repository.load () == sr); assert (fpv2a->other_repositories.empty ()); assert (fpv2a->priority == priority::security); - assert (fpv2a->changes.empty ()); + assert (!fpv2a->changes); assert (fpv2a->license_alternatives.size () == 1); assert (fpv2a->license_alternatives[0].size () == 1); @@ -510,27 +511,27 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv2a->dependencies[1].size () == 1); assert (fpv2a->dependencies[2].size () == 2); - assert (fpv2a->dependencies[0][0] == + assert (fpv2a->dependencies[0][0][0] == dep ("libmisc", version_constraint ( dep_ver ("0.1"), false, dep_ver ("2.0.0-"), true))); - assert (fpv2a->dependencies[0][1] == + assert (fpv2a->dependencies[0][1][0] == dep ("libmisc", version_constraint ( dep_ver ("2.0"), false, dep_ver ("5.0"), false))); - assert (fpv2a->dependencies[1][0] == + assert (fpv2a->dependencies[1][0][0] == dep ("libgenx", version_constraint ( dep_ver ("0.2"), true, dep_ver ("3.0"), true))); - assert (fpv2a->dependencies[2][0] == + assert (fpv2a->dependencies[2][0][0] == dep ("libexpat", version_constraint ( nullopt, true, dep_ver ("5.2"), true))); - assert (fpv2a->dependencies[2][1] == + assert (fpv2a->dependencies[2][1][0] == dep ("libexpat", version_constraint ( dep_ver ("1"), true, dep_ver ("5.1"), false))); @@ -540,7 +541,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (fpv2a)); assert (fpv2a->sha256sum && *fpv2a->sha256sum == - "f5d3e9e6e8f9621a638b1375d31f0eb50e6279d8066170b25da21e84198cfd82"); + "71321f6616036380ac5c9c5dc81efa04b23577ef9dc18f1ce413587bb57677c9"); assert (!fpv2a->buildable); @@ -562,7 +563,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv3->other_repositories.empty ()); assert (fpv3->priority == priority::medium); - assert (fpv3->changes.empty ()); + assert (!fpv3->changes); assert (fpv3->license_alternatives.size () == 1); assert (fpv3->license_alternatives[0].size () == 1); @@ -570,7 +571,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv3->dependencies.size () == 1); assert (fpv3->dependencies[0].size () == 1); - assert (fpv3->dependencies[0][0] == + assert (fpv3->dependencies[0][0][0] == dep ("libmisc", version_constraint ( dep_ver ("2.0.0"), false, nullopt, true))); @@ -578,7 +579,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (fpv3)); assert (fpv3->sha256sum && *fpv3->sha256sum == - "f2ebecac6cac8addd7c623bc1becf055e76b13a0d2dd385832b92c38c58956d8"); + "24c53899bd4dbfdde6a727e07724984bfb4ca7f20142291c40e30304f15434c3"); assert (!fpv3->buildable); @@ -590,7 +591,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv4->summary == "The Foo Library"); assert (fpv4->keywords == labels ({"c++", "foo"})); - assert (*fpv4->description == "Very good foo library."); + assert (fpv4->description->text == "Very good foo library."); assert (fpv4->url && fpv4->url->string () == "http://www.example.com/foo/"); assert (!fpv4->package_url); assert (fpv4->email && *fpv4->email == "foo-users@example.com"); @@ -599,7 +600,10 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv4->internal_repository.load () == sr); assert (fpv4->other_repositories.empty ()); assert (fpv4->priority == priority::low); - assert (fpv4->changes == "some changes 1\n\nsome changes 2"); + + assert (fpv4->changes && + fpv4->changes->text == "some changes 1\n\nsome changes 2" && + fpv4->changes->type == text_type::plain); assert (fpv4->license_alternatives.size () == 1); assert (fpv4->license_alternatives[0].comment == @@ -609,7 +613,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv4->dependencies.size () == 1); assert (fpv4->dependencies[0].size () == 1); - assert (fpv4->dependencies[0][0] == + assert (fpv4->dependencies[0][0][0] == dep ("libmisc", version_constraint ( dep_ver ("2.0.0"), false, nullopt, true))); @@ -617,7 +621,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (fpv4)); assert (fpv4->sha256sum && *fpv4->sha256sum == - "aa1606323bfc59b70de642629dc5d8318cc5348e3646f90ed89406d975db1e1d"); + "98f80ca0cd1c053fd45ab37f72a6a31f1a0304747c636822df8d573420284642"); assert (!fpv4->buildable); @@ -685,7 +689,7 @@ test_pkg_repos (const cstrings& loader_args, assert (xpv->internal_repository.load () == mr); assert (xpv->other_repositories.empty ()); assert (xpv->priority == priority::low); - assert (xpv->changes.empty ()); + assert (!xpv->changes); assert (xpv->license_alternatives.size () == 1); assert (xpv->license_alternatives[0].size () == 1); @@ -693,20 +697,20 @@ test_pkg_repos (const cstrings& loader_args, assert (xpv->dependencies.size () == 2); assert (xpv->dependencies[0].size () == 1); - assert (xpv->dependencies[0][0] == + assert (xpv->dependencies[0][0][0] == dep ("libexpat", version_constraint ( dep_ver ("2.0.0"), false, nullopt, true))); assert (xpv->dependencies[1].size () == 1); - assert (xpv->dependencies[1][0] == dep ("libgenx", nullopt)); + assert (xpv->dependencies[1][0][0] == dep ("libgenx", nullopt)); assert (xpv->requirements.empty ()); assert (check_location (xpv)); assert (xpv->sha256sum && *xpv->sha256sum == - "1833906dd93ccc0cda832d6a1b3ef9ed7877bb9958b46d9b2666033d4a7919c9"); + "aa52d5b49ee1bad825cd6bca554f72636e8451f93c74f9a443bafce3c2bf82c0"); assert (xpv->buildable); @@ -722,12 +726,28 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->topics == labels ({"math library", "math API", "libbaz fork"})); assert (fpv5->keywords == labels ({"c++", "foo", "math", "best"})); - assert (*fpv5->description == + + assert (fpv5->description->text == "A modern C++ library with easy to use linear algebra and lot " "of optimization\ntools.\n\nThere are over 100 functions in " "total with an extensive test suite. The API is\nsimilar to " - "~~mathlab~~ **MATLAB**.\n\nUseful for conversion of research " - "code into production environments."); + "~~mathlab~~ **MATLAB**.[^mathlab]\n\nUseful for conversion of " + "research code into production environments.\n" + "[^mathlab]: MATLAB Capabilities: TODO"); + + assert (fpv5->description->type == text_type::github_mark); + + assert (fpv5->package_description->text == + "This project builds and defines the build2 package for the " + "libfoo library.\n\n" + "A modern C++ library with easy to use linear algebra and lot " + "of optimization\ntools.\n\nThere are over 100 functions in " + "total with an extensive test suite. The API is\nsimilar to " + "~~mathlab~~ **MATLAB**.[^mathlab]\n\nUseful for conversion of " + "research code into production environments.\n" + "[^mathlab]: MATLAB Capabilities: TODO"); + + assert (fpv5->package_description->type == text_type::github_mark); assert (fpv5->url && fpv5->url->string () == "http://www.example.com/foo/"); @@ -753,14 +773,16 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->priority.comment == "Critical bug fixes, performance improvement."); - const char ch[] = R"DLM(1.2.4+1 + const char ch[] = R"DLM(**1.2.4+1** * applied patch for critical bug-219 * regenerated documentation -1.2.4 +**1.2.4** * test suite extended significantly)DLM"; - assert (fpv5->changes == ch); + assert (fpv5->changes && + fpv5->changes->text == ch && + fpv5->changes->type == text_type::github_mark); assert (fpv5->license_alternatives.size () == 2); assert (fpv5->license_alternatives[0].comment == @@ -778,12 +800,12 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->dependencies[0].comment == "Crashes with 1.1.0-2.3.0."); - assert (fpv5->dependencies[0][0] == + assert (fpv5->dependencies[0][0][0] == dep ("libmisc", version_constraint ( nullopt, true, dep_ver ("1.1"), true))); - assert (fpv5->dependencies[0][1] == + assert (fpv5->dependencies[0][1][0] == dep ("libmisc", version_constraint ( dep_ver ("2.3.0+0"), true, nullopt, true))); @@ -791,7 +813,7 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->dependencies[1].size () == 1); assert (fpv5->dependencies[1].comment.empty ()); - assert (fpv5->dependencies[1][0] == + assert (fpv5->dependencies[1][0][0] == dep ("libexp", version_constraint ( dep_ver ("1.0"), false, nullopt, true))); @@ -799,33 +821,48 @@ test_pkg_repos (const cstrings& loader_args, assert (fpv5->dependencies[2].size () == 2); assert (fpv5->dependencies[2].comment == "The newer the better."); - assert (fpv5->dependencies[2][0] == dep ("libstudxml", nullopt)); - assert (fpv5->dependencies[2][1] == dep ("libexpat", nullopt)); + assert (fpv5->dependencies[2][0][0] == dep ("libstudxml", nullopt)); + assert (fpv5->dependencies[2][1][0] == dep ("libexpat", nullopt)); requirements& fpvr5 (fpv5->requirements); - assert (fpvr5.size () == 4); + assert (fpvr5.size () == 8); - assert (fpvr5[0] == req_alts ({"linux", "windows", "macosx"})); - assert (!fpvr5[0].conditional); + assert (fpvr5[0][0][0] == "linux"); + assert (fpvr5[0][1][0] == "windows"); + assert (fpvr5[0][2][0] == "macosx"); assert (fpvr5[0].comment == "Symbian support is coming."); - assert (fpvr5[1] == req_alts ({"c++11"})); - assert (!fpvr5[1].conditional); + assert (fpvr5[1][0][0] == "c++11"); assert (fpvr5[1].comment.empty ()); - assert (fpvr5[2].empty ()); - assert (fpvr5[2].conditional); + assert (fpvr5[2][0][0] == ""); + assert (fpvr5[2][0].enable && *fpvr5[2][0].enable == ""); assert (fpvr5[2].comment == "libc++ standard library if using Clang on Mac OS X."); - assert (fpvr5[3] == req_alts ({"vc++ >= 12.0"})); - assert (fpvr5[3].conditional); - assert (fpvr5[3].comment == "Only if using VC++ on Windows."); + assert (fpvr5[3][0][0] == ""); + assert (!fpvr5[3][0].enable); + assert (fpvr5[3].comment == "X11 libs."); + + assert (fpvr5[4][0][0] == ""); + assert (fpvr5[4][0].enable && *fpvr5[4][0].enable == "$windows"); + assert (fpvr5[4].comment == "Only 64-bit."); + + assert (fpvr5[5][0][0] == "x86_64"); + assert (fpvr5[5][0].enable && *fpvr5[5][0].enable == ""); + assert (fpvr5[5].comment == "Only if on Windows."); + + assert (fpvr5[6][0][0] == "vc++ >= 12.0"); + assert (fpvr5[6][0].enable && *fpvr5[6][0].enable == "windows"); + assert (fpvr5[6].buildtime); + assert (fpvr5[6].comment == "Only if using VC++ on Windows."); + + assert (fpvr5[7][0][0] == "host"); assert (check_location (fpv5)); assert (fpv5->sha256sum && *fpv5->sha256sum == - "c02b6033107387e05f48aa62ee6498152c967deb0e91a62f1e618fe9fd1bc644"); + "ffce9d3e3ca9899d3fd6da1f6b93c07cce2c3f6b7004948b59757dae420f801b"); assert (fpv5->buildable); @@ -841,7 +878,7 @@ test_pkg_repos (const cstrings& loader_args, assert (epv->project == "mathLab"); assert (epv->summary == "The exponent"); assert (epv->keywords == labels ({"mathlab", "c++", "exponent"})); - assert (epv->description && *epv->description == + assert (epv->description && epv->description->text == "The exponent math function."); assert (epv->url && epv->url->string () == "http://exp.example.com"); assert (!epv->package_url); @@ -852,7 +889,7 @@ test_pkg_repos (const cstrings& loader_args, assert (epv->internal_repository.load () == mr); assert (epv->other_repositories.empty ()); assert (epv->priority == priority (priority::low)); - assert (epv->changes.empty ()); + assert (!epv->changes); assert (epv->license_alternatives.size () == 1); assert (epv->license_alternatives[0].size () == 1); @@ -860,10 +897,10 @@ test_pkg_repos (const cstrings& loader_args, assert (epv->dependencies.size () == 2); assert (epv->dependencies[0].size () == 1); - assert (epv->dependencies[0][0] == dep ("libmisc", nullopt)); + assert (epv->dependencies[0][0][0] == dep ("libmisc", nullopt)); assert (epv->dependencies[1].size () == 1); - assert (epv->dependencies[1][0] == + assert (epv->dependencies[1][0][0] == dep ("libpq", version_constraint ( dep_ver ("9.0.0"), false, nullopt, true))); @@ -884,7 +921,7 @@ test_pkg_repos (const cstrings& loader_args, assert (check_location (epv)); assert (epv->sha256sum && *epv->sha256sum == - "317c8c6f45d9dfdfdef3a823411920cecd51729c7c4f58f9a0b0bbd681c07bd6"); + "d90cfe583890cd0c05cdfc204e69dd3b986c2da49851f7a87fa0ca870788ff79"); // Verify libpq package version. // |