[libcxx-commits] [PATCH] D120478: [libcxx] [test] Make filesystem tests not rely on libc++ internals

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 1 12:47:24 PST 2022


mstorsjo updated this revision to Diff 412205.
mstorsjo added a comment.
Herald added a subscriber: arichardson.

Reinstate `-DNOMINMAX` instead of using libc++ specifics in `filesystem_test_helper.h`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120478/new/

https://reviews.llvm.org/D120478

Files:
  libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
  libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
  libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
  libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
  libcxx/test/support/filesystem_test_helper.h
  libcxx/utils/libcxx/test/config.py


Index: libcxx/utils/libcxx/test/config.py
===================================================================
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -245,6 +245,10 @@
             # Build the tests in the same configuration as libcxx itself,
             # to avoid mismatches if linked statically.
             self.cxx.compile_flags += ['-D_CRT_STDIO_ISO_WIDE_SPECIFIERS']
+            # Required so that tests using min/max don't fail on Windows,
+            # and so that those tests don't have to be changed to tolerate
+            # this insanity.
+            self.cxx.compile_flags += ['-DNOMINMAX']
         additional_flags = self.get_lit_conf('test_compiler_flags')
         if additional_flags:
             self.cxx.compile_flags += shlex.split(additional_flags)
Index: libcxx/test/support/filesystem_test_helper.h
===================================================================
--- libcxx/test/support/filesystem_test_helper.h
+++ libcxx/test/support/filesystem_test_helper.h
@@ -31,9 +31,6 @@
 # include <sys/un.h>
 #endif
 
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
 namespace utils {
 #ifdef _WIN32
     inline int mkdir(const char* path, int mode) { (void)mode; return ::_mkdir(path); }
@@ -736,6 +733,4 @@
   return fs::path();
 }
 
-_LIBCPP_POP_MACROS
-
 #endif /* FILESYSTEM_TEST_HELPER_H */
Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -22,9 +22,6 @@
 // void last_write_time(const path& p, file_time_type new_type,
 //                      std::error_code& ec) noexcept;
 
-// Disable min() and max() macros in <windows.h> on Windows.
-// ADDITIONAL_COMPILE_FLAGS: -DNOMINMAX
-
 #include "filesystem_include.h"
 #include <chrono>
 #include <cstdio>
Index: libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
@@ -19,9 +19,6 @@
 // file_time_type last_write_time() const;
 // file_time_type last_write_time(error_code const&) const noexcept;
 
-// Disable min() and max() macros in <windows.h> on Windows.
-// ADDITIONAL_COMPILE_FLAGS: -DNOMINMAX
-
 #include "filesystem_include.h"
 #include <type_traits>
 #include <cassert>
Index: libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
===================================================================
--- libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
+++ libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
@@ -5,7 +5,7 @@
 
 config.substitutions.append(('%{flags}', '--driver-mode=g++'))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS'
+    '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX'
 ))
 config.substitutions.append(('%{link_flags}',
     '-nostdlib -L %{lib} -llibc++ -lmsvcrt -lmsvcprt -loldnames'
Index: libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
===================================================================
--- libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
+++ libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
@@ -5,7 +5,7 @@
 
 config.substitutions.append(('%{flags}', '--driver-mode=g++'))
 config.substitutions.append(('%{compile_flags}',
-    '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS'
+    '-nostdinc++ -isystem %{include} -isystem %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX'
 ))
 config.substitutions.append(('%{link_flags}',
     '-nostdlib -L %{lib} -lc++ -lmsvcrt -lmsvcprt -loldnames'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120478.412205.patch
Type: text/x-patch
Size: 4511 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220301/2225856d/attachment.bin>


More information about the libcxx-commits mailing list