lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 26dd8aa: Work around a 'wine' defect


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 26dd8aa: Work around a 'wine' defect
Date: Wed, 28 Apr 2021 12:02:05 -0400 (EDT)

branch: master
commit 26dd8aa5c0b40f0e51f74238af2e2f33211d1f0c
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Work around a 'wine' defect
    
    'path_utility_test' is subject to a 'wine' defect:
      wine-4.0.3: works
      wine-5.0.3: fails
      wine-stable_6.0.0: works
    as discussed here:
      https://lists.nongnu.org/archive/html/lmi/2021-04/msg00062.html
    
    Arguably this commit took too much work. OTOH, arguably it should be
    more elaborate: e.g., it could test which version of 'wine' is used.
    Considerations:
     - Neither CI builds (on a remote server) nor the (local) nychthemeral
       test can be broken.
     - Adding running_under_wine() to 'msw_workarounds.?pp' seemed like a
       good idea, but would have required adding numerous extra object
       files to this unit test's recipe. That's not just inconvenient:
       it's pollution.
     - This won't be the last 'wine' breakage, so a robust if brutal OAOO
       approach is favored.
---
 Makefile.am           |  4 ++++
 objects.make          |  1 +
 path_utility_test.cpp | 18 +++++++++++++-----
 wine_workarounds.cpp  | 40 ++++++++++++++++++++++++++++++++++++++++
 wine_workarounds.hpp  | 31 +++++++++++++++++++++++++++++++
 5 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 417fb81..c52d6b6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -940,6 +940,9 @@ numeric_io_test_LDADD = \
   libtest_common.la \
   $(BOOST_LIBS)
 
+path_utility_test_SOURCES = \
+    path_utility_test.cpp \
+    wine_workarounds.cpp
 path_utility_test_LDADD = \
   libtest_common.la \
   $(BOOST_LIBS)
@@ -1323,6 +1326,7 @@ noinst_HEADERS = \
     version.hpp \
     view_ex.hpp \
     view_ex.tpp \
+    wine_workarounds.hpp \
     wx_checks.hpp \
     wx_new.hpp \
     wx_table_generator.hpp \
diff --git a/objects.make b/objects.make
index 4bae197..02047a3 100644
--- a/objects.make
+++ b/objects.make
@@ -917,6 +917,7 @@ path_utility_test$(EXEEXT): \
   null_stream.o \
   path_utility.o \
   path_utility_test.o \
+  wine_workarounds.o \
 
 premium_tax_test$(EXEEXT): \
   $(boost_filesystem_objects) \
diff --git a/path_utility_test.cpp b/path_utility_test.cpp
index c224b0e..b4e340d 100644
--- a/path_utility_test.cpp
+++ b/path_utility_test.cpp
@@ -26,6 +26,7 @@
 #include "miscellany.hpp"
 #include "platform_dependent.hpp"       // access()
 #include "test_tools.hpp"
+#include "wine_workarounds.hpp"         // running_under_wine()
 
 #include <boost/filesystem/convenience.hpp> // basename()
 #include <boost/filesystem/exception.hpp>
@@ -301,11 +302,18 @@ void test_unique_filepath_with_ludicrous_filenames()
     // called by unique_filepath() here, adding that extension to ".."
     // yields "...", which is forbidden by msw, but allowed (although
     // of course discouraged) by posix.
-    LMI_TEST_THROW
-        (unique_filepath(fs::path(".."), "..")
-        ,fs::filesystem_error
-        ,""
-        );
+    if(running_under_wine())
+        {
+        std::cout << "TEST SKIPPED DUE TO wine-5.0.3 DEFECT" << std::endl;
+        }
+    else
+        {
+        LMI_TEST_THROW
+            (unique_filepath(fs::path(".."), "..")
+            ,fs::filesystem_error
+            ,""
+            );
+        }
 #endif // defined LMI_MSW
 }
 
diff --git a/wine_workarounds.cpp b/wine_workarounds.cpp
new file mode 100644
index 0000000..e8642bb
--- /dev/null
+++ b/wine_workarounds.cpp
@@ -0,0 +1,40 @@
+// Work around 'wine' defects.
+//
+// Copyright (C) 2021 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// https://savannah.nongnu.org/projects/lmi
+// email: <gchicares@sbcglobal.net>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+#include "pchfile_wx.hpp"
+
+#include "wine_workarounds.hpp"
+
+#if defined LMI_MSW
+
+#include <windows.h>
+
+bool running_under_wine()
+{
+    HMODULE module = ::GetModuleHandleA("ntdll.dll");
+    return module && GetProcAddress(module, "wine_get_version");
+}
+
+#else  // !defined LMI_MSW
+
+bool running_under_wine() {return false;}
+
+#endif // !defined LMI_MSW
diff --git a/wine_workarounds.hpp b/wine_workarounds.hpp
new file mode 100644
index 0000000..548f6f2
--- /dev/null
+++ b/wine_workarounds.hpp
@@ -0,0 +1,31 @@
+// Work around 'wine' defects.
+//
+// Copyright (C) 2021 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// https://savannah.nongnu.org/projects/lmi
+// email: <gchicares@sbcglobal.net>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+#ifndef wine_workarounds_hpp
+#define wine_workarounds_hpp
+
+#include "config.hpp"
+
+#include "so_attributes.hpp"
+
+LMI_SO bool running_under_wine();
+
+#endif // wine_workarounds_hpp



reply via email to

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