diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | bpkg/manifest.cxx | 10 | ||||
-rw-r--r-- | tests/manifest-roundtrip/buildfile | 4 | ||||
-rw-r--r-- | tests/manifest-roundtrip/driver.cxx | 8 | ||||
-rw-r--r-- | tests/manifest/buildfile | 6 | ||||
-rw-r--r-- | tests/manifest/driver.cxx | 6 | ||||
-rw-r--r-- | tests/package-version/driver.cxx | 2 | ||||
-rw-r--r-- | tests/repository-location/driver.cxx | 99 |
8 files changed, 121 insertions, 15 deletions
@@ -4,4 +4,5 @@ *.d *.so *.a +*.exe core diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx index ff1c88f..ac6fafb 100644 --- a/bpkg/manifest.cxx +++ b/bpkg/manifest.cxx @@ -1704,10 +1704,10 @@ namespace bpkg // Canonical name <prefix>/<path> part. // - string cp ( - strip_path ( - path_, remote () ? strip_mode::component : strip_mode::path). - posix_string ()); + dir_path sp (strip_path ( + path_, remote () ? strip_mode::component : strip_mode::path)); + + string cp (sp.relative () ? sp.posix_string () : sp.string ()); // Note: allow empty paths (e.g., http://stable.cppget.org/1/). // @@ -1729,7 +1729,7 @@ namespace bpkg return std::string (); // Also function name. if (local ()) - return path_.string (); + return relative () ? path_.posix_string () : path_.string (); return to_string (proto_, host_, port_, path_); } diff --git a/tests/manifest-roundtrip/buildfile b/tests/manifest-roundtrip/buildfile index a830a01..793f955 100644 --- a/tests/manifest-roundtrip/buildfile +++ b/tests/manifest-roundtrip/buildfile @@ -2,7 +2,9 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -exe{driver}: cxx{driver} ../../bpkg/lib{bpkg} +import libs += libbutl%lib{butl} + +exe{driver}: cxx{driver} ../../bpkg/lib{bpkg} $libs exe{driver}: test.roundtrip = manifest include ../../bpkg/ diff --git a/tests/manifest-roundtrip/driver.cxx b/tests/manifest-roundtrip/driver.cxx index 917dc50..4f9a965 100644 --- a/tests/manifest-roundtrip/driver.cxx +++ b/tests/manifest-roundtrip/driver.cxx @@ -2,13 +2,17 @@ // copyright : Copyright (c) 2014-2016 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#include <cassert> #include <fstream> #include <iostream> +#include <butl/fdstream> // stdout_mode() + #include <bpkg/manifest-parser> #include <bpkg/manifest-serializer> using namespace std; +using namespace butl; using namespace bpkg; int @@ -24,9 +28,11 @@ main (int argc, char* argv[]) { ifstream ifs; ifs.exceptions (ifstream::badbit | ifstream::failbit); - ifs.open (argv[1], ifstream::in | ifstream::binary); + ifs.open (argv[1]); manifest_parser p (ifs, argv[1]); + + stdout_fdmode (fdtranslate::binary); // Write in binary mode. manifest_serializer s (cout, "stdout"); for (bool eom (true), eos (false); !eos; ) diff --git a/tests/manifest/buildfile b/tests/manifest/buildfile index c417a08..8f4b8f0 100644 --- a/tests/manifest/buildfile +++ b/tests/manifest/buildfile @@ -19,7 +19,11 @@ exe{sdriver}: obj{sdriver} exe{sdriver}: test.roundtrip = signature obj{pdriver rdriver sdriver}: cxx{driver} -exe{pdriver rdriver sdriver} obj{pdriver rdriver sdriver}: ../../bpkg/lib{bpkg} + +import libs += libbutl%lib{butl} + +exe{pdriver rdriver sdriver} obj{pdriver rdriver sdriver}: \ + ../../bpkg/lib{bpkg} $libs obj{pdriver}: cxx.poptions += -DTEST_PACKAGES obj{rdriver}: cxx.poptions += -DTEST_REPOSITORIES diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx index c153477..74e2166 100644 --- a/tests/manifest/driver.cxx +++ b/tests/manifest/driver.cxx @@ -2,14 +2,18 @@ // copyright : Copyright (c) 2014-2016 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#include <cassert> #include <fstream> #include <iostream> +#include <butl/fdstream> // stdout_mode() + #include <bpkg/manifest> #include <bpkg/manifest-parser> #include <bpkg/manifest-serializer> using namespace std; +using namespace butl; using namespace bpkg; int @@ -37,6 +41,8 @@ main (int argc, char* argv[]) signature_manifest ms (p); #endif + + stdout_fdmode (fdtranslate::binary); // Write in binary mode. manifest_serializer s (cout, "stdout"); ms.serialize (s); } diff --git a/tests/package-version/driver.cxx b/tests/package-version/driver.cxx index db1a55f..be300c4 100644 --- a/tests/package-version/driver.cxx +++ b/tests/package-version/driver.cxx @@ -9,6 +9,8 @@ #include <exception> #include <stdexcept> // invalid_argument +#include <butl/optional> + #include <bpkg/manifest> using namespace std; diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx index 58aa5ed..48b32fd 100644 --- a/tests/repository-location/driver.cxx +++ b/tests/repository-location/driver.cxx @@ -172,7 +172,7 @@ main (int argc, char* argv[]) assert (bad_url ("../.a", repository_location ( "http://stable.cppget.org/1/misc"))); - +#ifndef _WIN32 assert (bad_url ("../../..", repository_location ( "/var/1/misc"))); @@ -180,6 +180,15 @@ main (int argc, char* argv[]) assert (bad_url ("../../..", repository_location ( "/var/pkg/1/misc"))); +#else + assert (bad_url ("..\\..\\..", + repository_location ( + "c:\\var\\1\\misc"))); + + assert (bad_url ("..\\..\\..", + repository_location ( + "c:\\var\\pkg\\1\\misc"))); +#endif assert (bad_url ("../../..", repository_location ())); @@ -216,6 +225,7 @@ main (int argc, char* argv[]) assert (l.string () == "b/pkg/1/aa/bb"); assert (l.canonical_name ().empty ()); } +#ifndef _WIN32 { repository_location l ("/1/aa/bb", repository_location ()); assert (l.string () == "/1/aa/bb"); @@ -249,6 +259,48 @@ main (int argc, char* argv[]) assert (l.string () == "/a/c/pkg/1/bb"); assert (l.canonical_name () == "bb"); } +#else + { + repository_location l ("c:\\1\\aa\\bb", repository_location ()); + assert (l.string () == "c:\\1\\aa\\bb"); + assert (l.canonical_name () == "c:\\aa\\bb"); + } + { + repository_location l ("c:/1/aa/bb", repository_location ()); + assert (l.string () == "c:\\1\\aa\\bb"); + assert (l.canonical_name () == "c:\\aa\\bb"); + } + { + repository_location l ("c:\\pkg\\1\\aa\\bb", repository_location ()); + assert (l.string () == "c:\\pkg\\1\\aa\\bb"); + assert (l.canonical_name () == "aa/bb"); + } + { + repository_location l ("c:\\var\\pkg\\1\\example.org\\math\\testing", + repository_location ()); + assert (l.string () == "c:\\var\\pkg\\1\\example.org\\math\\testing"); + assert (l.canonical_name () == "example.org/math/testing"); + } + { + repository_location l ("c:\\var\\pkg\\example.org\\1\\math\\testing", + repository_location ()); + assert (l.string () == "c:\\var\\pkg\\example.org\\1\\math\\testing"); + + assert (l.canonical_name () == + "c:\\var\\pkg\\example.org\\math\\testing"); + } + { + repository_location l ("c:/a/b/../c/1/aa/../bb", repository_location ()); + assert (l.string () == "c:\\a\\c\\1\\bb"); + assert (l.canonical_name () == "c:\\a\\c\\bb"); + } + { + repository_location l ("c:/a/b/../c/pkg/1/aa/../bb", + repository_location ()); + assert (l.string () == "c:\\a\\c\\pkg\\1\\bb"); + assert (l.canonical_name () == "bb"); + } +#endif { repository_location l ("../c/../c/./1/aa/../bb", repository_location ()); @@ -378,6 +430,7 @@ main (int argc, char* argv[]) assert (l2.canonical_name () == "stable.cppget.org:444/math"); assert (l2.proto () == protocol::https); } +#ifndef _WIN32 { repository_location l1 ("/var/r1/1/misc"); repository_location l2 ("../../../r2/1/math", l1); @@ -403,6 +456,44 @@ main (int argc, char* argv[]) assert (l2.canonical_name () == "/var/test"); } { + repository_location l1 ("/var/1/stable"); + repository_location l2 ("/var/1/stable", repository_location ()); + assert (l1.string () == l2.string ()); + assert (l1.canonical_name () == l2.canonical_name ()); + } +#else + { + repository_location l1 ("c:/var/r1/1/misc"); + repository_location l2 ("../../../r2/1/math", l1); + assert (l2.string () == "c:\\var\\r2\\1\\math"); + assert (l2.canonical_name () == "c:\\var\\r2\\math"); + } + { + repository_location l1 ("c:/var/1/misc"); + repository_location l2 ("../math", l1); + assert (l2.string () == "c:\\var\\1\\math"); + assert (l2.canonical_name () == "c:\\var\\math"); + } + { + repository_location l1 ("c:/var/1/stable"); + repository_location l2 ("c:\\var\\1\\test", l1); + assert (l2.string () == "c:\\var\\1\\test"); + assert (l2.canonical_name () == "c:\\var\\test"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 ("c:/var/1/test", l1); + assert (l2.string () == "c:\\var\\1\\test"); + assert (l2.canonical_name () == "c:\\var\\test"); + } + { + repository_location l1 ("c:/var/1/stable"); + repository_location l2 ("c:/var/1/stable", repository_location ()); + assert (l1.string () == l2.string ()); + assert (l1.canonical_name () == l2.canonical_name ()); + } +#endif + { repository_location l1 ("http://www.cppget.org/1/stable"); repository_location l2 ("http://abc.com/1/test", l1); assert (l2.string () == "http://abc.com/1/test"); @@ -415,12 +506,6 @@ main (int argc, char* argv[]) assert (l1.string () == l2.string ()); assert (l1.canonical_name () == l2.canonical_name ()); } - { - repository_location l1 ("/var/1/stable"); - repository_location l2 ("/var/1/stable", repository_location ()); - assert (l1.string () == l2.string ()); - assert (l1.canonical_name () == l2.canonical_name ()); - } // Test valid web interface locations. // |