diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-30 20:25:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-08 18:26:00 +0200 |
commit | a8bbc544cac714378e18f85b5f18d2988a752c5f (patch) | |
tree | 52c4268fa90fdd1132e0ebb14daa6e6f1aea6ca2 /tests | |
parent | dd0f7ec5e776c25cbb0b6715bf62d52a9965f9b1 (diff) |
Support package dependency version range
Diffstat (limited to 'tests')
-rw-r--r-- | tests/loader/1/stable/packages | 3 | ||||
-rw-r--r-- | tests/loader/driver.cxx | 89 |
2 files changed, 80 insertions, 12 deletions
diff --git a/tests/loader/1/stable/packages b/tests/loader/1/stable/packages index 1a385c3..afa168a 100644 --- a/tests/loader/1/stable/packages +++ b/tests/loader/1/stable/packages @@ -27,6 +27,9 @@ license: MIT tags: c++, foo url: http://www.example.com/foo/ email: foo-users@example.com +depends: libmisc [0.1 2.0-) | libmisc [2.0 5.0] +depends: libgenx (0.2 3.0) +depends: libexpat < 5.2 | libexpat (1 5.1] location: libfoo-1.2.2-alpha.1.tar.gz : name: libfoo diff --git a/tests/loader/driver.cxx b/tests/loader/driver.cxx index 51f2ed8..eea3d0c 100644 --- a/tests/loader/driver.cxx +++ b/tests/loader/driver.cxx @@ -25,12 +25,30 @@ using namespace odb::core; using namespace butl; using namespace brep; +// @@ Rather add this to optional in libbutl. See: +// +// http://en.cppreference.com/w/cpp/experimental/optional/operator_cmp + +template <typename T> +static inline auto +operator== (const optional<T>& a, const optional<T>& b) -> decltype (*a == *b) +{ + return !a == !b && (!a || *a == *b); +} + +// @@ Add it to libbrep rather? +// +static inline bool +operator== (const dependency_constraint& a, const dependency_constraint& b) +{ + return a.min_version == b.min_version && a.max_version == b.max_version && + a.min_open == b.min_open && a.max_open == b.max_open; +} + static inline bool operator== (const dependency& a, const dependency& b) { - return a.name () == b.name () && !a.constraint == !b.constraint && - (!a.constraint || (a.constraint->operation == b.constraint->operation && - a.constraint->version == b.constraint->version)); + return a.name () == b.name () && a.constraint == b.constraint; } static bool @@ -216,13 +234,15 @@ main (int argc, char* argv[]) dep ( "libbar", optional<dependency_constraint> ( - dependency_constraint{comparison::le, version ("2.4.0")}))); + dependency_constraint ( + nullopt, true, version ("2.4.0"), false)))); assert (fpv2->dependencies[1][0] == dep ( "libexp", optional<dependency_constraint> ( - dependency_constraint{comparison::eq, version ("1~1.2")}))); + dependency_constraint ( + version ("1~1.2"), false, version ("1~1.2"), false)))); // libfoo-1.2.2-alpha.1 // @@ -243,7 +263,46 @@ main (int argc, char* argv[]) assert (fpv2a->license_alternatives[0].size () == 1); assert (fpv2a->license_alternatives[0][0] == "MIT"); - assert (fpv2a->dependencies.empty ()); + assert (fpv2a->dependencies.size () == 3); + assert (fpv2a->dependencies[0].size () == 2); + assert (fpv2a->dependencies[1].size () == 1); + assert (fpv2a->dependencies[2].size () == 2); + + assert (fpv2a->dependencies[0][0] == + dep ( + "libmisc", + optional<dependency_constraint> ( + dependency_constraint ( + version ("0.1"), false, version ("2.0.0-"), true)))); + + assert (fpv2a->dependencies[0][1] == + dep ( + "libmisc", + optional<dependency_constraint> ( + dependency_constraint ( + version ("2.0"), false, version ("5.0"), false)))); + + assert (fpv2a->dependencies[1][0] == + dep ( + "libgenx", + optional<dependency_constraint> ( + dependency_constraint ( + version ("0.2"), true, version ("3.0"), true)))); + + assert (fpv2a->dependencies[2][0] == + dep ( + "libexpat", + optional<dependency_constraint> ( + dependency_constraint ( + nullopt, true, version ("5.2"), true)))); + + assert (fpv2a->dependencies[2][1] == + dep ( + "libexpat", + optional<dependency_constraint> ( + dependency_constraint ( + version ("1"), true, version ("5.1"), false)))); + assert (fpv2a->requirements.empty ()); // libfoo-1.2.3-4 @@ -272,7 +331,8 @@ main (int argc, char* argv[]) dep ( "libmisc", optional<dependency_constraint> ( - dependency_constraint{comparison::ge, version ("2.0.0")}))); + dependency_constraint ( + version ("2.0.0"), false, nullopt, true)))); // libfoo-1.2.4 // @@ -301,7 +361,8 @@ main (int argc, char* argv[]) dep ( "libmisc", optional<dependency_constraint> ( - dependency_constraint{comparison::ge, version ("2.0.0")}))); + dependency_constraint ( + version ("2.0.0"), false, nullopt, true)))); // Verify 'math' repository. // @@ -373,7 +434,8 @@ main (int argc, char* argv[]) dep ( "libexpat", optional<dependency_constraint> ( - dependency_constraint{comparison::ge, version ("2.0.0")}))); + dependency_constraint ( + version ("2.0.0"), false, nullopt, true)))); assert (xpv->dependencies[1].size () == 1); assert (xpv->dependencies[1][0] == dep ("libgenx", nullopt)); @@ -436,13 +498,15 @@ main (int argc, char* argv[]) dep ( "libmisc", optional<dependency_constraint> ( - dependency_constraint{comparison::lt, version ("1.1")}))); + dependency_constraint ( + nullopt, true, version ("1.1"), true)))); assert (fpv5->dependencies[0][1] == dep ( "libmisc", optional<dependency_constraint> ( - dependency_constraint{comparison::gt, version ("2.3.0")}))); + dependency_constraint ( + version ("2.3.0"), true, nullopt, true)))); assert (fpv5->dependencies[1].size () == 1); assert (fpv5->dependencies[1].comment.empty ()); @@ -450,7 +514,8 @@ main (int argc, char* argv[]) assert (fpv5->dependencies[1][0] == dep ("libexp", optional<dependency_constraint> ( - dependency_constraint{comparison::ge, version ("1.0")}))); + dependency_constraint ( + version ("1.0"), false, nullopt, true)))); assert (fpv5->dependencies[2].size () == 2); assert (fpv5->dependencies[2].comment == "The newer the better."); |