Replace deprecated leaf() with filename().
[dcpomatic.git] / test / zipper_test.cc
index 10ffd76a4fc5bbe3d7623e44895a73e02f9a9129..37e6176f0d322882df7694a9628f4b10c20d302a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
+
 /** @file  test/zipper_test.cc
- *  @brief Tests of Zipper class.
+ *  @brief Test Zipper class.
  *  @ingroup selfcontained
  */
 
-#include "lib/zipper.h"
+
 #include "lib/exceptions.h"
+#include "lib/zipper.h"
 #include "test.h"
+#include <dcp/filesystem.h>
 #include <dcp/util.h>
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
 
+
 /** Basic test of Zipper working normally */
 BOOST_AUTO_TEST_CASE (zipper_test1)
 {
@@ -41,8 +45,21 @@ BOOST_AUTO_TEST_CASE (zipper_test1)
        zipper.add ("bar.txt", "xxxxxxCCCCbbbbbbb1");
        zipper.close ();
 
+       /* Make sure we aren't in a UNC current working directory otherwise the use of cmd.exe
+        * in system() below will fail.
+        */
+       boost::filesystem::current_path(dcp::filesystem::unfix_long_path(boost::filesystem::current_path()));
+
        boost::filesystem::remove_all ("build/test/zipper_test1", ec);
+#ifdef DCPOMATIC_WINDOWS
+       /* unzip on windows crashes every so often (with a return code -1073740940, for some reason)
+        * so try using the built-in tar which can unzip things.
+        */
+       boost::filesystem::create_directories ("build/test/zipper_test1");
+       int const r = system ("tar -xf build\\test\\zipped.zip -C build\\test\\zipper_test1");
+#else
        int const r = system ("unzip build/test/zipped.zip -d build/test/zipper_test1");
+#endif
        BOOST_REQUIRE_EQUAL (r, 0);
 
        BOOST_CHECK_EQUAL (dcp::file_to_string("build/test/zipper_test1/foo.txt"), "1234567890");