lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [low priority] Failing unique_filepath() test on Linux


From: Vadim Zeitlin
Subject: Re: [lmi] [low priority] Failing unique_filepath() test on Linux
Date: Tue, 3 Mar 2015 16:50:14 +0100

On Sun, 01 Mar 2015 15:56:28 +0000 Greg Chicares <address@hidden> wrote:

GC> >  So the reason for the test failure is clear, but not so much the solution
GC> > to it. Disabling the tests under non-MSW platforms is an obvious option,
GC> 
GC> Sounds good. It's an msw-specific workaround, so test it only under msw.

 OK, here is the trivial patch fixing this test failure then:
---------------------------------- >8 --------------------------------------
diff --git a/path_utility_test.cpp b/path_utility_test.cpp
index eac5321..31350d1 100644
--- a/path_utility_test.cpp
+++ b/path_utility_test.cpp
@@ -169,6 +169,10 @@ void test_unique_filepath_with_normal_filenames()
     write_dummy_file(path1);
     BOOST_TEST_EQUAL(0, access(path1.string().c_str(), R_OK));

+    // MSW is the only supported platform under which files can't be deleted
+    // while they are still used, so the tests below only make sense for it and
+    // would be useless and wrong (i.e. would fail) on a POSIX system.
+#ifdef LMI_MSW
     // Open a file for writing, and leave it open, preventing it from
     // being erased and therefore forcing unique_filepath() to use a
     // different name. This behavior isn't guaranteed on toy OS's.
@@ -185,9 +189,11 @@ void test_unique_filepath_with_normal_filenames()

     keep_open.close();

-    BOOST_TEST(0 == std::remove(p));
-    BOOST_TEST(0 == std::remove(q));
-    BOOST_TEST(0 == std::remove(path2.string().c_str()));
+    BOOST_TEST_EQUAL(0, std::remove(path2.string().c_str()));
+#endif
+
+    BOOST_TEST_EQUAL(0, std::remove(p));
+    BOOST_TEST_EQUAL(0, std::remove(q));
 }

 void test_unique_filepath_with_ludicrous_filenames()
---------------------------------- >8 --------------------------------------

(I've also replaced BOOST_TEST() with BOOST_TEST_EQUAL() to get more
information in case of failure).

 However, even with this patch, this test still has a couple of problems
with newer Boost versions. First of all, for a long time change_extension()
was buggy, see https://svn.boost.org/trac/boost/ticket/5118
(replace_extension() is the function really used by the deprecated
change_extension() and, in fact, due to another bug in Boost.Filesystem v3
compatibility layer, change_extension is not available at all in newer
versions of Boost and I had to change the code to use replace_extension
just to compile). Because of this bug several tests fail when using 1.49,
but they pass when using 1.55 and I decided to not do anything about it: by
the time the version of Boost used in lmi will be upgraded, we are
definitely going to be able to require using 1.55 or later, so IMO it
doesn't make sense to work around the bugs in earlier versions.

 Second problem is that unique_filepath(fs::path(".."), "..") doesn't throw
an exception any more but just returns "....". I don't know if it's a bug
or not, but it doesn't seem to be one. Here I'd just remove the
corresponding test from test_unique_filepath_with_ludicrous_filenames(),
there doesn't seem to be any real point in testing this. But if you'd
prefer to keep it, we could use an explicit test for the Boost version to
make it work.

 I'll post a separate message about the other tests failures under Linux
later.

 Regards,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]