From 9a1351808c7443a65f876d2b7808ebdea7d9c814 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 21 May 2016 17:16:13 +0300 Subject: Port to MinGW --- tests/manifest-roundtrip/buildfile | 4 +- tests/manifest-roundtrip/driver.cxx | 8 ++- tests/manifest/buildfile | 6 ++- tests/manifest/driver.cxx | 6 +++ tests/package-version/driver.cxx | 2 + tests/repository-location/driver.cxx | 99 +++++++++++++++++++++++++++++++++--- 6 files changed, 115 insertions(+), 10 deletions(-) (limited to 'tests') 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 #include #include +#include // stdout_mode() + #include #include 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 #include #include +#include // stdout_mode() + #include #include #include 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 #include // invalid_argument +#include + #include 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. // -- cgit v1.1