summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-03-26 05:46:57 +0000
committerEric Fiselier <eric@efcs.ca>2018-03-26 05:46:57 +0000
commit19aae8fe2f2a5dfaaa7b6f2631f3f86801fc832d (patch)
treea27358ca3b9ff71131d520763aa4cf86cb934efb /libcxx/test/support
parent6f28d3c954e31c48d6c67950acc24380d92ea843 (diff)
downloadbcm5719-llvm-19aae8fe2f2a5dfaaa7b6f2631f3f86801fc832d.tar.gz
bcm5719-llvm-19aae8fe2f2a5dfaaa7b6f2631f3f86801fc832d.zip
Make filesystem tests generic between experimental and std versions.
As I move towards implementing std::filesystem, there is a need to make the existing tests run against both the std and experimental versions. Additionally, it's helpful to allow running the tests against other implementations of filesystem. This patch converts the test to easily target either. First, it adds a filesystem_include.hpp header which is soley responsible for selecting and including the correct implementation. Second, it converts existing tests to use this header instead of including filesystem directly. llvm-svn: 328475
Diffstat (limited to 'libcxx/test/support')
-rw-r--r--libcxx/test/support/filesystem_include.hpp18
-rw-r--r--libcxx/test/support/filesystem_test_helper.hpp3
2 files changed, 19 insertions, 2 deletions
diff --git a/libcxx/test/support/filesystem_include.hpp b/libcxx/test/support/filesystem_include.hpp
new file mode 100644
index 00000000000..228e710f3a1
--- /dev/null
+++ b/libcxx/test/support/filesystem_include.hpp
@@ -0,0 +1,18 @@
+#ifndef TEST_SUPPORT_FILESYSTEM_INCLUDE_HPP
+#define TEST_SUPPORT_FILESYSTEM_INCLUDE_HPP
+
+#include <ciso646>
+// Test against std::filesystem for STL's other than libc++
+#ifndef _LIBCPP_VERSION
+#define TEST_INCLUDE_STD_FILESYSTEM
+#endif
+
+#ifdef TEST_INCLUDE_STD_FILESYSTEM
+#include <filesystem>
+namespace fs = std::filesystem;
+#else
+#include <experimental/filesystem>
+namespace fs = std::experimental::filesystem;
+#endif
+
+#endif
diff --git a/libcxx/test/support/filesystem_test_helper.hpp b/libcxx/test/support/filesystem_test_helper.hpp
index 755be90351f..622a60d1c96 100644
--- a/libcxx/test/support/filesystem_test_helper.hpp
+++ b/libcxx/test/support/filesystem_test_helper.hpp
@@ -1,7 +1,7 @@
#ifndef FILESYSTEM_TEST_HELPER_HPP
#define FILESYSTEM_TEST_HELPER_HPP
-#include <experimental/filesystem>
+#include "filesystem_include.hpp"
#include <cassert>
#include <cstdio> // for printf
#include <string>
@@ -9,7 +9,6 @@
#include <random>
#include <chrono>
-namespace fs = std::experimental::filesystem;
// static test helpers
OpenPOWER on IntegriCloud