[libcxx-commits] [libcxx] bc8f007 - [libc++] Get rid of _LIBCPP_HAS_OPEN_WITH_WCHAR in the test suite
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 5 08:27:35 PDT 2022
Author: Louis Dionne
Date: 2022-10-05T11:27:24-04:00
New Revision: bc8f007fe045139dde244b2374b851f93cc7ed3c
URL: https://github.com/llvm/llvm-project/commit/bc8f007fe045139dde244b2374b851f93cc7ed3c
DIFF: https://github.com/llvm/llvm-project/commit/bc8f007fe045139dde244b2374b851f93cc7ed3c.diff
LOG: [libc++] Get rid of _LIBCPP_HAS_OPEN_WITH_WCHAR in the test suite
Differential Revision: https://reviews.llvm.org/D135163
Added:
libcxx/test/support/wide_temp_file.h
Modified:
libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp
libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp
libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp
libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp
libcxx/test/support/platform_support.h
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
index 1557a7c89abb..c78d4463ad5b 100644
--- a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
+++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
@@ -13,14 +13,16 @@
// explicit basic_fstream(const wchar_t* s, ios_base::openmode mode = ios_base::in | ios_base::out);
+// This extension is only provided on Windows.
+// REQUIRES: windows
+// UNSUPPORTED: no-wide-characters
+
#include <fstream>
#include <cassert>
#include "test_macros.h"
-#include "platform_support.h"
+#include "wide_temp_file.h"
-int main(int, char**)
-{
-#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+int main(int, char**) {
std::wstring temp = get_wide_temp_file_name();
{
std::fstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
@@ -42,7 +44,6 @@ int main(int, char**)
assert(x == 3.25);
}
_wremove(temp.c_str());
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
index c18ce9009835..315062053dd7 100644
--- a/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
+++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
@@ -13,14 +13,16 @@
// void open(const wchar_t* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+// This extension is only provided on Windows.
+// REQUIRES: windows
+// UNSUPPORTED: no-wide-characters
+
#include <fstream>
#include <cassert>
#include "test_macros.h"
-#include "platform_support.h"
+#include "wide_temp_file.h"
-int main(int, char**)
-{
-#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+int main(int, char**) {
std::wstring temp = get_wide_temp_file_name();
{
std::fstream fs;
@@ -48,7 +50,6 @@ int main(int, char**)
assert(x == 3.25);
}
_wremove(temp.c_str());
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp
index 1f6956e7a7e6..18e9b2910d87 100644
--- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp
+++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.cons/wchar_pointer.pass.cpp
@@ -13,6 +13,10 @@
// explicit basic_ifstream(const wchar_t* s, ios_base::openmode mode = ios_base::in);
+// This extension is only provided on Windows.
+// REQUIRES: windows
+// UNSUPPORTED: no-wide-characters
+
// FILE_DEPENDENCIES: test.dat
#include <fstream>
@@ -20,9 +24,7 @@
#include "test_macros.h"
-int main(int, char**)
-{
-#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+int main(int, char**) {
{
std::ifstream fs(L"test.dat");
double x = 0;
@@ -41,7 +43,6 @@ int main(int, char**)
// std::wifstream(const wchar_t*, std::ios_base::openmode) is tested in
// test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp
// which creates writable files.
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp
index 7d91b6d6d095..3fa8a29e2995 100644
--- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp
+++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ifstream.members/open_wchar_pointer.pass.cpp
@@ -13,6 +13,10 @@
// void open(const wchar_t* s, ios_base::openmode mode = ios_base::in);
+// This extension is only provided on Windows.
+// REQUIRES: windows
+// UNSUPPORTED: no-wide-characters
+
// FILE_DEPENDENCIES: test.dat
#include <fstream>
@@ -20,9 +24,7 @@
#include "test_macros.h"
-int main(int, char**)
-{
-#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+int main(int, char**) {
{
std::ifstream fs;
assert(!fs.is_open());
@@ -47,7 +49,6 @@ int main(int, char**)
fs >> c;
assert(c == L'r');
}
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp
index 15650b36686e..0d9cab8e6007 100644
--- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp
+++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.cons/wchar_pointer.pass.cpp
@@ -13,14 +13,16 @@
// explicit basic_ofstream(const wchar_t* s, ios_base::openmode mode = ios_base::out);
+// This extension is only provided on Windows.
+// REQUIRES: windows
+// UNSUPPORTED: no-wide-characters
+
#include <fstream>
#include <cassert>
#include "test_macros.h"
-#include "platform_support.h"
+#include "wide_temp_file.h"
-int main(int, char**)
-{
-#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+int main(int, char**) {
std::wstring temp = get_wide_temp_file_name();
{
std::ofstream fs(temp.c_str());
@@ -56,7 +58,6 @@ int main(int, char**)
assert(x == 3.25);
}
_wremove(temp.c_str());
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp
index d119ae624186..0bc803a64480 100644
--- a/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp
+++ b/libcxx/test/libcxx/input.output/file.streams/fstreams/ofstream.members/open_wchar_pointer.pass.cpp
@@ -13,14 +13,16 @@
// void open(const wchar_t* s, ios_base::openmode mode = ios_base::out);
+// This extension is only provided on Windows.
+// REQUIRES: windows
+// UNSUPPORTED: no-wide-characters
+
#include <fstream>
#include <cassert>
#include "test_macros.h"
-#include "platform_support.h"
+#include "wide_temp_file.h"
-int main(int, char**)
-{
-#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
+int main(int, char**) {
std::wstring temp = get_wide_temp_file_name();
{
std::ofstream fs;
@@ -56,7 +58,6 @@ int main(int, char**)
assert(c == L'a');
}
_wremove(temp.c_str());
-#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/support/platform_support.h b/libcxx/test/support/platform_support.h
index 0ea9bf0ea8ce..88ddf84eb20c 100644
--- a/libcxx/test/support/platform_support.h
+++ b/libcxx/test/support/platform_support.h
@@ -35,8 +35,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <codecvt>
-#include <locale>
#include <string>
#if defined(_WIN32)
# include <io.h> // _mktemp_s
@@ -85,17 +83,6 @@ std::string get_temp_file_name()
#endif
}
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
-inline
-std::wstring get_wide_temp_file_name()
-{
- return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> >().from_bytes(
- get_temp_file_name());
-}
-#endif // _LIBCPP_HAS_OPEN_WITH_WCHAR
-_LIBCPP_SUPPRESS_DEPRECATED_POP
-
#if defined(_CS_GNU_LIBC_VERSION)
inline bool glibc_version_less_than(char const* version) {
std::string test_version = std::string("glibc ") + version;
diff --git a/libcxx/test/support/wide_temp_file.h b/libcxx/test/support/wide_temp_file.h
new file mode 100644
index 000000000000..f5a65408c746
--- /dev/null
+++ b/libcxx/test/support/wide_temp_file.h
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_SUPPORT_WIDE_TEMP_FILE_H
+#define TEST_SUPPORT_WIDE_TEMP_FILE_H
+
+#include <codecvt>
+#include <locale>
+#include <string>
+
+#include "platform_support.h"
+#include "test_macros.h"
+
+TEST_DIAGNOSTIC_PUSH
+TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
+inline std::wstring get_wide_temp_file_name() {
+ return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> >().from_bytes(get_temp_file_name());
+}
+TEST_DIAGNOSTIC_POP
+
+#endif // TEST_SUPPORT_WIDE_TEMP_FILE_H
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 829fd1901363..582d9d5ef948 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -236,7 +236,7 @@ def _hasSuitableClangQuery(cfg):
when=lambda cfg, alts=alts: hasAnyLocale(cfg, alts)))
-# Add features representing the platform name: darwin, linux, windows, etc...
+# Add features representing the target platform name: darwin, linux, windows, etc...
DEFAULT_FEATURES += [
Feature(name='darwin', when=lambda cfg: '__APPLE__' in compilerMacros(cfg)),
Feature(name='windows', when=lambda cfg: '_WIN32' in compilerMacros(cfg)),
More information about the libcxx-commits
mailing list