[libcxx-commits] [libcxx] 5e3ab8f - Revert "[libc++] [test] Generate static_test_env on the fly"
Sergej Jaskiewicz via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 6 13:13:42 PDT 2020
Author: Sergej Jaskiewicz
Date: 2020-05-06T23:13:24+03:00
New Revision: 5e3ab8f2299f4aef78a2fce01096e40563b22b44
URL: https://github.com/llvm/llvm-project/commit/5e3ab8f2299f4aef78a2fce01096e40563b22b44
DIFF: https://github.com/llvm/llvm-project/commit/5e3ab8f2299f4aef78a2fce01096e40563b22b44.diff
LOG: Revert "[libc++] [test] Generate static_test_env on the fly"
This reverts commit 52cc8bac7780dbfb90dcc8cfe24696618eeaa06e.
As the discussion in https://reviews.llvm.org/D78200 continues, I will
revert this until we figure out what to do.
Added:
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/bad_symlink
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/afile3
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/dir3/file5
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/file4
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/symlink_to_dir3
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file1
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file2
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/empty_file
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/non_empty_file
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_dir
libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_empty_file
Modified:
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.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/status.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp
libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.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.relative/relative.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
libcxx/test/support/filesystem_test_helper.h
Removed:
################################################################################
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/bad_symlink b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/bad_symlink
new file mode 120000
index 000000000000..76646beed5ed
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/bad_symlink
@@ -0,0 +1 @@
+dne
\ No newline at end of file
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/afile3 b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/afile3
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/dir3/file5 b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/dir3/file5
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/file4 b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/file4
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/symlink_to_dir3 b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/symlink_to_dir3
new file mode 120000
index 000000000000..397913952621
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/symlink_to_dir3
@@ -0,0 +1 @@
+dir3
\ No newline at end of file
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file1 b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file1
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file2 b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file2
new file mode 100644
index 000000000000..44834e586734
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file2
@@ -0,0 +1 @@
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\ No newline at end of file
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/empty_file b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/empty_file
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/non_empty_file b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/non_empty_file
new file mode 100644
index 000000000000..44834e586734
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/non_empty_file
@@ -0,0 +1 @@
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\ No newline at end of file
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_dir b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_dir
new file mode 120000
index 000000000000..df490f837a85
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_dir
@@ -0,0 +1 @@
+dir1
\ No newline at end of file
diff --git a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_empty_file b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_empty_file
new file mode 120000
index 000000000000..b79b689fc85a
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_empty_file
@@ -0,0 +1 @@
+empty_file
\ No newline at end of file
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
index f7c3e442707d..850be12e839c 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -45,7 +46,6 @@ TEST_CASE(path_ctor) {
}
TEST_CASE(path_ec_ctor) {
- static_test_env static_env;
using namespace fs;
{
static_assert(
@@ -61,8 +61,8 @@ TEST_CASE(path_ec_ctor) {
}
{
std::error_code ec = GetTestEC();
- const directory_entry e(static_env.File, ec);
- TEST_CHECK(e.path() == static_env.File);
+ const directory_entry e(StaticEnv::File, ec);
+ TEST_CHECK(e.path() == StaticEnv::File);
TEST_CHECK(!ec);
}
{
@@ -121,28 +121,26 @@ TEST_CASE(path_ctor_calls_refresh) {
TEST_CASE(path_ctor_dne) {
using namespace fs;
- static_test_env static_env;
-
{
std::error_code ec = GetTestEC();
- directory_entry ent(static_env.DNE, ec);
+ directory_entry ent(StaticEnv::DNE, ec);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- TEST_CHECK(ent.path() == static_env.DNE);
+ TEST_CHECK(ent.path() == StaticEnv::DNE);
}
// don't report dead symlinks as an error.
{
std::error_code ec = GetTestEC();
- directory_entry ent(static_env.BadSymlink, ec);
+ directory_entry ent(StaticEnv::BadSymlink, ec);
TEST_CHECK(!ec);
- TEST_CHECK(ent.path() == static_env.BadSymlink);
+ TEST_CHECK(ent.path() == StaticEnv::BadSymlink);
}
// DNE does not cause the constructor to throw
{
- directory_entry ent(static_env.DNE);
- TEST_CHECK(ent.path() == static_env.DNE);
+ directory_entry ent(StaticEnv::DNE);
+ TEST_CHECK(ent.path() == StaticEnv::DNE);
- directory_entry ent_two(static_env.BadSymlink);
- TEST_CHECK(ent_two.path() == static_env.BadSymlink);
+ directory_entry ent_two(StaticEnv::BadSymlink);
+ TEST_CHECK(ent_two.path() == StaticEnv::BadSymlink);
}
}
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
index 0f3624bd65a5..2a2146be1b84 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -53,7 +54,6 @@ TEST_CASE(test_replace_filename_method) {
TEST_CASE(test_replace_filename_ec_method) {
using namespace fs;
- static_test_env static_env;
{
directory_entry e;
path replace;
@@ -76,9 +76,9 @@ TEST_CASE(test_replace_filename_ec_method) {
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
}
{
- const path p = static_env.EmptyFile;
- const path expect = static_env.NonEmptyFile;
- const path replace = static_env.NonEmptyFile.filename();
+ const path p = StaticEnv::EmptyFile;
+ const path expect = StaticEnv::NonEmptyFile;
+ const path replace = StaticEnv::NonEmptyFile.filename();
TEST_REQUIRE(expect.parent_path() == p.parent_path());
directory_entry e(p);
TEST_CHECK(e.path() == p);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
index ad4cc43c95d9..8ff1b46b3b99 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -111,7 +112,6 @@ TEST_CASE(not_regular_file) {
TEST_CASE(error_reporting) {
using namespace fs;
- static_test_env static_env;
scoped_test_env env;
const path dir = env.create_dir("dir");
@@ -127,15 +127,15 @@ TEST_CASE(error_reporting) {
directory_entry ent;
std::error_code ec = GetTestEC();
- ent.assign(static_env.DNE, ec);
- TEST_REQUIRE(ent.path() == static_env.DNE);
+ ent.assign(StaticEnv::DNE, ec);
+ TEST_REQUIRE(ent.path() == StaticEnv::DNE);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
TEST_CHECK(ent.file_size(ec) == uintmax_t(-1));
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- ExceptionChecker Checker(static_env.DNE,
+ ExceptionChecker Checker(StaticEnv::DNE,
std::errc::no_such_file_or_directory,
"directory_entry::file_size");
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.file_size());
@@ -145,20 +145,20 @@ TEST_CASE(error_reporting) {
directory_entry ent;
std::error_code ec = GetTestEC();
- uintmax_t expect_bad = file_size(static_env.BadSymlink, ec);
+ uintmax_t expect_bad = file_size(StaticEnv::BadSymlink, ec);
TEST_CHECK(expect_bad == uintmax_t(-1));
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
- ent.assign(static_env.BadSymlink, ec);
- TEST_REQUIRE(ent.path() == static_env.BadSymlink);
+ ent.assign(StaticEnv::BadSymlink, ec);
+ TEST_REQUIRE(ent.path() == StaticEnv::BadSymlink);
TEST_CHECK(!ec);
ec = GetTestEC();
TEST_CHECK(ent.file_size(ec) == expect_bad);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- ExceptionChecker Checker(static_env.BadSymlink,
+ ExceptionChecker Checker(StaticEnv::BadSymlink,
std::errc::no_such_file_or_directory,
"directory_entry::file_size");
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.file_size());
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
index b3bfa5e7eeac..f5a44b76a8b0 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
@@ -149,8 +149,8 @@ TEST_CASE(test_with_ec_dne) {
using fs::directory_entry;
using fs::file_status;
using fs::path;
- static_test_env static_env;
- for (auto p : {static_env.DNE, static_env.BadSymlink}) {
+
+ for (auto p : {StaticEnv::DNE, StaticEnv::BadSymlink}) {
directory_entry e(p);
std::error_code status_ec = GetTestEC();
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
index 8090bd77da72..d9958a6c5f03 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -109,7 +110,6 @@ TEST_CASE(not_regular_file) {
TEST_CASE(error_reporting) {
using namespace fs;
- static_test_env static_env;
scoped_test_env env;
const path dir = env.create_dir("dir");
@@ -125,16 +125,16 @@ TEST_CASE(error_reporting) {
directory_entry ent;
std::error_code ec = GetTestEC();
- ent.assign(static_env.DNE, ec);
+ ent.assign(StaticEnv::DNE, ec);
TEST_CHECK(ec);
- TEST_REQUIRE(ent.path() == static_env.DNE);
+ TEST_REQUIRE(ent.path() == StaticEnv::DNE);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
TEST_CHECK(ent.hard_link_count(ec) == uintmax_t(-1));
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- ExceptionChecker Checker(static_env.DNE,
+ ExceptionChecker Checker(StaticEnv::DNE,
std::errc::no_such_file_or_directory,
"directory_entry::hard_link_count");
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.hard_link_count());
@@ -144,20 +144,20 @@ TEST_CASE(error_reporting) {
directory_entry ent;
std::error_code ec = GetTestEC();
- uintmax_t expect_bad = hard_link_count(static_env.BadSymlink, ec);
+ uintmax_t expect_bad = hard_link_count(StaticEnv::BadSymlink, ec);
TEST_CHECK(expect_bad == uintmax_t(-1));
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
- ent.assign(static_env.BadSymlink, ec);
- TEST_REQUIRE(ent.path() == static_env.BadSymlink);
+ ent.assign(StaticEnv::BadSymlink, ec);
+ TEST_REQUIRE(ent.path() == StaticEnv::BadSymlink);
TEST_CHECK(!ec);
ec = GetTestEC();
TEST_CHECK(ent.hard_link_count(ec) == expect_bad);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- ExceptionChecker Checker(static_env.BadSymlink,
+ ExceptionChecker Checker(StaticEnv::BadSymlink,
std::errc::no_such_file_or_directory,
"directory_entry::hard_link_count");
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.hard_link_count());
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
index 98949ea06e0c..de6c36c218f2 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -83,7 +84,6 @@ TEST_CASE(basic) {
TEST_CASE(error_reporting) {
using namespace fs;
- static_test_env static_env;
scoped_test_env env;
const path dir = env.create_dir("dir");
@@ -99,15 +99,15 @@ TEST_CASE(error_reporting) {
directory_entry ent;
std::error_code ec = GetTestEC();
- ent.assign(static_env.DNE, ec);
- TEST_REQUIRE(ent.path() == static_env.DNE);
+ ent.assign(StaticEnv::DNE, ec);
+ TEST_REQUIRE(ent.path() == StaticEnv::DNE);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
TEST_CHECK(ent.last_write_time(ec) == file_time_type::min());
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- ExceptionChecker Checker(static_env.DNE,
+ ExceptionChecker Checker(StaticEnv::DNE,
std::errc::no_such_file_or_directory,
"directory_entry::last_write_time");
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.last_write_time());
@@ -117,20 +117,20 @@ TEST_CASE(error_reporting) {
directory_entry ent;
std::error_code ec = GetTestEC();
- file_time_type expect_bad = last_write_time(static_env.BadSymlink, ec);
+ file_time_type expect_bad = last_write_time(StaticEnv::BadSymlink, ec);
TEST_CHECK(expect_bad == file_time_type::min());
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
- ent.assign(static_env.BadSymlink, ec);
- TEST_REQUIRE(ent.path() == static_env.BadSymlink);
+ ent.assign(StaticEnv::BadSymlink, ec);
+ TEST_REQUIRE(ent.path() == StaticEnv::BadSymlink);
TEST_CHECK(!ec);
ec = GetTestEC();
TEST_CHECK(ent.last_write_time(ec) == expect_bad);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- ExceptionChecker Checker(static_env.BadSymlink,
+ ExceptionChecker Checker(StaticEnv::BadSymlink,
std::errc::no_such_file_or_directory,
"directory_entry::last_write_time");
TEST_CHECK_THROW_RESULT(filesystem_error, Checker, ent.last_write_time());
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp
index 796d47bfb525..8ea1fdbcbe6e 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/status.pass.cpp
@@ -28,7 +28,6 @@ TEST_SUITE(directory_entry_status_testsuite)
TEST_CASE(test_basic) {
using namespace fs;
- static_test_env static_env;
{
const fs::directory_entry e("foo");
std::error_code ec;
@@ -37,8 +36,8 @@ TEST_CASE(test_basic) {
static_assert(noexcept(e.status()) == false, "");
static_assert(noexcept(e.status(ec)) == true, "");
}
- path TestCases[] = {static_env.File, static_env.Dir, static_env.SymlinkToFile,
- static_env.DNE};
+ path TestCases[] = {StaticEnv::File, StaticEnv::Dir, StaticEnv::SymlinkToFile,
+ StaticEnv::DNE};
for (const auto& p : TestCases) {
const directory_entry e(p);
std::error_code pec = GetTestEC(), eec = GetTestEC(1);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp
index c8dd6c133539..cff19bc583ff 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/symlink_status.pass.cpp
@@ -28,7 +28,6 @@ TEST_SUITE(directory_entry_obs_suite)
TEST_CASE(test_signature) {
using namespace fs;
- static_test_env static_env;
{
const directory_entry e("foo");
std::error_code ec;
@@ -37,8 +36,8 @@ TEST_CASE(test_signature) {
static_assert(noexcept(e.symlink_status()) == false, "");
static_assert(noexcept(e.symlink_status(ec)) == true, "");
}
- path TestCases[] = {static_env.File, static_env.Dir, static_env.SymlinkToFile,
- static_env.DNE};
+ path TestCases[] = {StaticEnv::File, StaticEnv::Dir, StaticEnv::SymlinkToFile,
+ StaticEnv::DNE};
for (const auto& p : TestCases) {
const directory_entry e(p);
std::error_code pec = GetTestEC(), eec = GetTestEC(1);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp
index 5b7d709d9aec..d01854c1e403 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -42,8 +43,7 @@ TEST_CASE(test_copy_end_iterator)
TEST_CASE(test_copy_valid_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const directory_iterator endIt{};
const directory_iterator it(testDir);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp
index 920ded9523da..8d3324079105 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/copy_assign.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -35,8 +36,7 @@ TEST_CASE(test_assignment_signature)
TEST_CASE(test_copy_to_end_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const directory_iterator from(testDir);
TEST_REQUIRE(from != directory_iterator{});
@@ -52,8 +52,7 @@ TEST_CASE(test_copy_to_end_iterator)
TEST_CASE(test_copy_from_end_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const directory_iterator from{};
@@ -67,8 +66,7 @@ TEST_CASE(test_copy_from_end_iterator)
TEST_CASE(test_copy_valid_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const directory_iterator endIt{};
directory_iterator it_obj(testDir);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
index 206e7860f487..a06c4a64c7ff 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -59,12 +60,11 @@ TEST_CASE(test_constructor_signatures)
TEST_CASE(test_construction_from_bad_path)
{
- static_test_env static_env;
std::error_code ec;
directory_options opts = directory_options::none;
const directory_iterator endIt;
- const path testPaths[] = { static_env.DNE, static_env.BadSymlink };
+ const path testPaths[] = { StaticEnv::DNE, StaticEnv::BadSymlink };
for (path const& testPath : testPaths)
{
{
@@ -169,10 +169,9 @@ TEST_CASE(test_open_on_empty_directory_equals_end)
TEST_CASE(test_open_on_directory_succeeds)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- std::set<path> dir_contents(static_env.DirIterationList.begin(),
- static_env.DirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
+ std::end( StaticEnv::DirIterationList));
const directory_iterator endIt{};
{
@@ -191,8 +190,7 @@ TEST_CASE(test_open_on_directory_succeeds)
TEST_CASE(test_open_on_file_fails)
{
- static_test_env static_env;
- const path testFile = static_env.File;
+ const path testFile = StaticEnv::File;
const directory_iterator endIt{};
{
std::error_code ec;
@@ -227,10 +225,9 @@ TEST_CASE(test_open_on_dot_dir)
TEST_CASE(test_open_on_symlink)
{
- static_test_env static_env;
- const path symlinkToDir = static_env.SymlinkToDir;
+ const path symlinkToDir = StaticEnv::SymlinkToDir;
std::set<path> dir_contents;
- for (path const& p : static_env.DirIterationList) {
+ for (path const& p : StaticEnv::DirIterationList) {
dir_contents.insert(p.filename());
}
const directory_iterator endIt{};
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
index f1f9a27a45f0..c527013237ac 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/increment.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -43,10 +44,9 @@ TEST_CASE(test_increment_signatures)
TEST_CASE(test_prefix_increment)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- const std::set<path> dir_contents(static_env.DirIterationList.begin(),
- static_env.DirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ const std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
+ std::end( StaticEnv::DirIterationList));
const directory_iterator endIt{};
std::error_code ec;
@@ -67,10 +67,9 @@ TEST_CASE(test_prefix_increment)
TEST_CASE(test_postfix_increment)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- const std::set<path> dir_contents(static_env.DirIterationList.begin(),
- static_env.DirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ const std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
+ std::end( StaticEnv::DirIterationList));
const directory_iterator endIt{};
std::error_code ec;
@@ -92,10 +91,9 @@ TEST_CASE(test_postfix_increment)
TEST_CASE(test_increment_method)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- const std::set<path> dir_contents(static_env.DirIterationList.begin(),
- static_env.DirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ const std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
+ std::end( StaticEnv::DirIterationList));
const directory_iterator endIt{};
std::error_code ec;
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp
index 8b17383fe6c1..c4d0e23b46f8 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -45,8 +46,7 @@ TEST_CASE(test_move_end_iterator)
TEST_CASE(test_move_valid_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const directory_iterator endIt{};
directory_iterator it(testDir);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp
index 93fa67b4230e..bf737146d585 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/move_assign.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -41,8 +42,7 @@ TEST_CASE(test_assignment_signature)
TEST_CASE(test_move_to_end_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
directory_iterator from(testDir);
TEST_REQUIRE(from != directory_iterator{});
@@ -57,8 +57,7 @@ TEST_CASE(test_move_to_end_iterator)
TEST_CASE(test_move_from_end_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
directory_iterator from{};
@@ -72,8 +71,7 @@ TEST_CASE(test_move_from_end_iterator)
TEST_CASE(test_move_valid_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const directory_iterator endIt{};
directory_iterator it(testDir);
@@ -103,10 +101,9 @@ TEST_CASE(test_returns_reference_to_self)
TEST_CASE(test_self_move)
{
- static_test_env static_env;
// Create two non-equal iterators that have exactly the same state.
- directory_iterator it(static_env.Dir);
- directory_iterator it2(static_env.Dir);
+ directory_iterator it(StaticEnv::Dir);
+ directory_iterator it2(StaticEnv::Dir);
++it; ++it2;
TEST_CHECK(it != it2);
TEST_CHECK(*it2 == *it);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
index c80458eeab8b..5b1205edc6db 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.nonmembers/begin_end.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -42,10 +43,9 @@ TEST_CASE(test_function_signatures)
TEST_CASE(test_ranged_for_loop)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- std::set<path> dir_contents(static_env.DirIterationList.begin(),
- static_env.DirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
+ std::end( StaticEnv::DirIterationList));
std::error_code ec;
directory_iterator it(testDir, ec);
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp
index 09a53e46e263..bff2a18dd70a 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -43,8 +44,7 @@ TEST_CASE(test_copy_end_iterator)
TEST_CASE(test_copy_valid_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const recursive_directory_iterator endIt{};
// build 'it' up with "interesting" non-default state so we can test
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
index e03e9f3880b8..d7468a21c4ed 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -27,7 +28,7 @@ using namespace fs;
TEST_SUITE(recursive_directory_iterator_copy_assign_tests)
-recursive_directory_iterator createInterestingIterator(const static_test_env &static_env)
+recursive_directory_iterator createInterestingIterator()
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -35,7 +36,7 @@ recursive_directory_iterator createInterestingIterator(const static_test_env &st
// it.depth() == 1
// it.recursion_pending() == true
{
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::skip_permission_denied);
@@ -50,7 +51,7 @@ recursive_directory_iterator createInterestingIterator(const static_test_env &st
}
-recursive_directory_iterator createDifferentInterestingIterator(const static_test_env &static_env)
+recursive_directory_iterator createDifferentInterestingIterator()
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -58,7 +59,7 @@ recursive_directory_iterator createDifferentInterestingIterator(const static_tes
// it.depth() == 2
// it.recursion_pending() == false
{
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::follow_directory_symlink);
@@ -78,10 +79,9 @@ TEST_CASE(test_assignment_signature) {
TEST_CASE(test_copy_to_end_iterator)
{
- static_test_env static_env;
const recursive_directory_iterator endIt;
- const recursive_directory_iterator from = createInterestingIterator(static_env);
+ const recursive_directory_iterator from = createInterestingIterator();
const path entry = *from;
recursive_directory_iterator to;
@@ -96,9 +96,8 @@ TEST_CASE(test_copy_to_end_iterator)
TEST_CASE(test_copy_from_end_iterator)
{
- static_test_env static_env;
const recursive_directory_iterator from;
- recursive_directory_iterator to = createInterestingIterator(static_env);
+ recursive_directory_iterator to = createInterestingIterator();
to = from;
TEST_REQUIRE(to == from);
@@ -107,13 +106,12 @@ TEST_CASE(test_copy_from_end_iterator)
TEST_CASE(test_copy_valid_iterator)
{
- static_test_env static_env;
const recursive_directory_iterator endIt;
- const recursive_directory_iterator it = createInterestingIterator(static_env);
+ const recursive_directory_iterator it = createInterestingIterator();
const path entry = *it;
- recursive_directory_iterator it2 = createDifferentInterestingIterator(static_env);
+ recursive_directory_iterator it2 = createDifferentInterestingIterator();
TEST_REQUIRE(it2 != it);
TEST_CHECK(it2.options() != it.options());
TEST_CHECK(it2.depth() != it.depth());
@@ -138,10 +136,9 @@ TEST_CASE(test_returns_reference_to_self)
TEST_CASE(test_self_copy)
{
- static_test_env static_env;
// Create two non-equal iterators that have exactly the same state.
- recursive_directory_iterator it = createInterestingIterator(static_env);
- recursive_directory_iterator it2 = createInterestingIterator(static_env);
+ recursive_directory_iterator it = createInterestingIterator();
+ recursive_directory_iterator it2 = createInterestingIterator();
TEST_CHECK(it != it2);
TEST_CHECK(it2.options() == it.options());
TEST_CHECK(it2.depth() == it.depth());
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
index 40f89df4e81a..177edb46e058 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -60,12 +61,11 @@ TEST_CASE(test_constructor_signatures)
TEST_CASE(test_construction_from_bad_path)
{
- static_test_env static_env;
std::error_code ec;
directory_options opts = directory_options::none;
const RDI endIt;
- const path testPaths[] = { static_env.DNE, static_env.BadSymlink };
+ const path testPaths[] = { StaticEnv::DNE, StaticEnv::BadSymlink };
for (path const& testPath : testPaths)
{
{
@@ -171,10 +171,9 @@ TEST_CASE(test_open_on_empty_directory_equals_end)
TEST_CASE(test_open_on_directory_succeeds)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- std::set<path> dir_contents(static_env.DirIterationList.begin(),
- static_env.DirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
+ std::end( StaticEnv::DirIterationList));
const RDI endIt{};
{
@@ -193,8 +192,7 @@ TEST_CASE(test_open_on_directory_succeeds)
TEST_CASE(test_open_on_file_fails)
{
- static_test_env static_env;
- const path testFile = static_env.File;
+ const path testFile = StaticEnv::File;
const RDI endIt{};
{
std::error_code ec;
@@ -209,9 +207,8 @@ TEST_CASE(test_open_on_file_fails)
TEST_CASE(test_options_post_conditions)
{
- static_test_env static_env;
- const path goodDir = static_env.Dir;
- const path badDir = static_env.DNE;
+ const path goodDir = StaticEnv::Dir;
+ const path badDir = StaticEnv::DNE;
{
std::error_code ec;
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp
index bd12ec888566..da6c10a88cc9 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/depth.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -29,10 +30,9 @@ TEST_SUITE(recursive_directory_iterator_depth_tests)
TEST_CASE(test_depth)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- const path DirDepth1 = static_env.Dir2;
- const path DirDepth2 = static_env.Dir3;
+ const path testDir = StaticEnv::Dir;
+ const path DirDepth1 = StaticEnv::Dir2;
+ const path DirDepth2 = StaticEnv::Dir3;
const recursive_directory_iterator endIt{};
std::error_code ec;
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp
index 568563984dd4..5d29b7e32f60 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/disable_recursion_pending.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -31,8 +32,7 @@ TEST_SUITE(recursive_directory_iterator_disable_recursion_pending_tests)
// in the 'recursion_pending()' tests.
TEST_CASE(basic_test)
{
- static_test_env static_env;
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
TEST_REQUIRE(it.recursion_pending() == true);
it.disable_recursion_pending();
TEST_CHECK(it.recursion_pending() == false);
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
index 3c0127e2a318..1c7650543396 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/increment.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -42,10 +43,9 @@ TEST_CASE(test_increment_signatures)
TEST_CASE(test_prefix_increment)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- const std::set<path> dir_contents(static_env.RecDirIterationList.begin(),
- static_env.RecDirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ const std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
+ std::end( StaticEnv::RecDirIterationList));
const recursive_directory_iterator endIt{};
std::error_code ec;
@@ -66,10 +66,9 @@ TEST_CASE(test_prefix_increment)
TEST_CASE(test_postfix_increment)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- const std::set<path> dir_contents(static_env.RecDirIterationList.begin(),
- static_env.RecDirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ const std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
+ std::end( StaticEnv::RecDirIterationList));
const recursive_directory_iterator endIt{};
std::error_code ec;
@@ -90,10 +89,9 @@ TEST_CASE(test_postfix_increment)
TEST_CASE(test_increment_method)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- const std::set<path> dir_contents(static_env.RecDirIterationList.begin(),
- static_env.RecDirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ const std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
+ std::end( StaticEnv::RecDirIterationList));
const recursive_directory_iterator endIt{};
std::error_code ec;
@@ -115,11 +113,10 @@ TEST_CASE(test_increment_method)
TEST_CASE(test_follow_symlinks)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- auto const& IterList = static_env.RecDirFollowSymlinksIterationList;
+ const path testDir = StaticEnv::Dir;
+ auto const& IterList = StaticEnv::RecDirFollowSymlinksIterationList;
- const std::set<path> dir_contents(IterList.begin(), IterList.end());
+ const std::set<path> dir_contents(std::begin(IterList), std::end(IterList));
const recursive_directory_iterator endIt{};
std::error_code ec;
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp
index a944478284e6..d709012bef8c 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -45,8 +46,7 @@ TEST_CASE(test_move_end_iterator)
TEST_CASE(test_move_valid_iterator)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const recursive_directory_iterator endIt{};
// build 'it' up with "interesting" non-default state so we can test
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp
index 3dc2bb758b89..2dee77c71731 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/move_assign.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -33,7 +34,7 @@ using namespace fs;
TEST_SUITE(recursive_directory_iterator_move_assign_tests)
-recursive_directory_iterator createInterestingIterator(const static_test_env &static_env)
+recursive_directory_iterator createInterestingIterator()
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -41,7 +42,7 @@ recursive_directory_iterator createInterestingIterator(const static_test_env &st
// it.depth() == 1
// it.recursion_pending() == true
{
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::skip_permission_denied);
@@ -55,7 +56,7 @@ recursive_directory_iterator createInterestingIterator(const static_test_env &st
return it;
}
-recursive_directory_iterator createDifferentInterestingIterator(const static_test_env &static_env)
+recursive_directory_iterator createDifferentInterestingIterator()
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -63,7 +64,7 @@ recursive_directory_iterator createDifferentInterestingIterator(const static_tes
// it.depth() == 2
// it.recursion_pending() == false
{
- const path testDir = static_env.Dir;
+ const path testDir = StaticEnv::Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::follow_directory_symlink);
@@ -86,10 +87,9 @@ TEST_CASE(test_assignment_signature)
TEST_CASE(test_move_to_end_iterator)
{
- static_test_env static_env;
const recursive_directory_iterator endIt;
- recursive_directory_iterator from = createInterestingIterator(static_env);
+ recursive_directory_iterator from = createInterestingIterator();
const recursive_directory_iterator from_copy(from);
const path entry = *from;
@@ -106,9 +106,8 @@ TEST_CASE(test_move_to_end_iterator)
TEST_CASE(test_move_from_end_iterator)
{
- static_test_env static_env;
recursive_directory_iterator from;
- recursive_directory_iterator to = createInterestingIterator(static_env);
+ recursive_directory_iterator to = createInterestingIterator();
to = std::move(from);
TEST_REQUIRE(to == from);
@@ -117,14 +116,13 @@ TEST_CASE(test_move_from_end_iterator)
TEST_CASE(test_move_valid_iterator)
{
- static_test_env static_env;
const recursive_directory_iterator endIt;
- recursive_directory_iterator it = createInterestingIterator(static_env);
+ recursive_directory_iterator it = createInterestingIterator();
const recursive_directory_iterator it_copy(it);
const path entry = *it;
- recursive_directory_iterator it2 = createDifferentInterestingIterator(static_env);
+ recursive_directory_iterator it2 = createDifferentInterestingIterator();
const recursive_directory_iterator it2_copy(it2);
TEST_REQUIRE(it2 != it);
TEST_CHECK(it2.options() != it.options());
@@ -151,10 +149,9 @@ TEST_CASE(test_returns_reference_to_self)
TEST_CASE(test_self_move)
{
- static_test_env static_env;
// Create two non-equal iterators that have exactly the same state.
- recursive_directory_iterator it = createInterestingIterator(static_env);
- recursive_directory_iterator it2 = createInterestingIterator(static_env);
+ recursive_directory_iterator it = createInterestingIterator();
+ recursive_directory_iterator it2 = createInterestingIterator();
TEST_CHECK(it != it2);
TEST_CHECK(it2.options() == it.options());
TEST_CHECK(it2.depth() == it.depth());
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp
index 2d4edc97c549..c6ecdae56db3 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/pop.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -39,17 +40,16 @@ TEST_CASE(signature_tests)
// seen files at each depth to determine the new depth after a 'pop()' operation.
TEST_CASE(test_depth)
{
- static_test_env static_env;
const recursive_directory_iterator endIt{};
- auto& DE0 = static_env.DirIterationList;
- std::set<path> notSeenDepth0(DE0.begin(), DE0.end());
+ auto& DE0 = StaticEnv::DirIterationList;
+ std::set<path> notSeenDepth0(std::begin(DE0), std::end(DE0));
- auto& DE1 = static_env.DirIterationListDepth1;
- std::set<path> notSeenDepth1(DE1.begin(), DE1.end());
+ auto& DE1 = StaticEnv::DirIterationListDepth1;
+ std::set<path> notSeenDepth1(std::begin(DE1), std::end(DE1));
std::error_code ec;
- recursive_directory_iterator it(static_env.Dir, ec);
+ recursive_directory_iterator it(StaticEnv::Dir, ec);
TEST_REQUIRE(it != endIt);
TEST_CHECK(it.depth() == 0);
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
index 731766e262b3..6bb7b939554a 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -29,16 +30,14 @@ TEST_SUITE(recursive_directory_iterator_recursion_pending_tests)
TEST_CASE(initial_value_test)
{
- static_test_env static_env;
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
TEST_REQUIRE(it.recursion_pending() == true);
}
TEST_CASE(value_after_copy_construction_and_assignment_test)
{
- static_test_env static_env;
- recursive_directory_iterator rec_pending_it(static_env.Dir);
- recursive_directory_iterator no_rec_pending_it(static_env.Dir);
+ recursive_directory_iterator rec_pending_it(StaticEnv::Dir);
+ recursive_directory_iterator no_rec_pending_it(StaticEnv::Dir);
no_rec_pending_it.disable_recursion_pending();
{ // copy construction
@@ -51,14 +50,14 @@ TEST_CASE(value_after_copy_construction_and_assignment_test)
TEST_CHECK(it2.recursion_pending() == false);
}
{ // copy assignment
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
it.disable_recursion_pending();
it = rec_pending_it;
TEST_CHECK(it.recursion_pending() == true);
it.disable_recursion_pending();
TEST_REQUIRE(rec_pending_it.recursion_pending() == true);
- recursive_directory_iterator it2(static_env.Dir);
+ recursive_directory_iterator it2(StaticEnv::Dir);
it2 = no_rec_pending_it;
TEST_CHECK(it2.recursion_pending() == false);
}
@@ -69,9 +68,8 @@ TEST_CASE(value_after_copy_construction_and_assignment_test)
TEST_CASE(value_after_move_construction_and_assignment_test)
{
- static_test_env static_env;
- recursive_directory_iterator rec_pending_it(static_env.Dir);
- recursive_directory_iterator no_rec_pending_it(static_env.Dir);
+ recursive_directory_iterator rec_pending_it(StaticEnv::Dir);
+ recursive_directory_iterator no_rec_pending_it(StaticEnv::Dir);
no_rec_pending_it.disable_recursion_pending();
{ // move construction
@@ -84,13 +82,13 @@ TEST_CASE(value_after_move_construction_and_assignment_test)
TEST_CHECK(it2.recursion_pending() == false);
}
{ // copy assignment
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
it.disable_recursion_pending();
recursive_directory_iterator it_cp(rec_pending_it);
it = std::move(it_cp);
TEST_CHECK(it.recursion_pending() == true);
- recursive_directory_iterator it2(static_env.Dir);
+ recursive_directory_iterator it2(StaticEnv::Dir);
recursive_directory_iterator it_cp2(no_rec_pending_it);
it2 = std::move(it_cp2);
TEST_CHECK(it2.recursion_pending() == false);
@@ -101,10 +99,9 @@ TEST_CASE(value_after_move_construction_and_assignment_test)
TEST_CASE(increment_resets_value)
{
- static_test_env static_env;
const recursive_directory_iterator endIt;
{
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
it.disable_recursion_pending();
TEST_CHECK(it.recursion_pending() == false);
++it;
@@ -112,7 +109,7 @@ TEST_CASE(increment_resets_value)
TEST_CHECK(it.depth() == 0);
}
{
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
it.disable_recursion_pending();
TEST_CHECK(it.recursion_pending() == false);
it++;
@@ -120,7 +117,7 @@ TEST_CASE(increment_resets_value)
TEST_CHECK(it.depth() == 0);
}
{
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
it.disable_recursion_pending();
TEST_CHECK(it.recursion_pending() == false);
std::error_code ec;
@@ -132,13 +129,12 @@ TEST_CASE(increment_resets_value)
TEST_CASE(pop_does_not_reset_value)
{
- static_test_env static_env;
const recursive_directory_iterator endIt;
- auto& DE0 = static_env.DirIterationList;
- std::set<path> notSeenDepth0(DE0.begin(), DE0.end());
+ auto& DE0 = StaticEnv::DirIterationList;
+ std::set<path> notSeenDepth0(std::begin(DE0), std::end(DE0));
- recursive_directory_iterator it(static_env.Dir);
+ recursive_directory_iterator it(StaticEnv::Dir);
TEST_REQUIRE(it != endIt);
while (it.depth() == 0) {
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
index 1a076f3a3ed5..24eaf84c2931 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.nonmembers/begin_end.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -42,10 +43,9 @@ TEST_CASE(test_function_signatures)
TEST_CASE(test_ranged_for_loop)
{
- static_test_env static_env;
- const path testDir = static_env.Dir;
- std::set<path> dir_contents(static_env.RecDirIterationList.begin(),
- static_env.RecDirIterationList.end());
+ const path testDir = StaticEnv::Dir;
+ std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
+ std::end( StaticEnv::RecDirIterationList));
std::error_code ec;
recursive_directory_iterator it(testDir, ec);
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp
index bc3f581b828e..de2fa54aca48 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.canonical/canonical.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -23,6 +24,15 @@
using namespace fs;
+struct CWDGuard {
+ path OldCWD;
+ CWDGuard() : OldCWD(fs::current_path()) { }
+ ~CWDGuard() { fs::current_path(OldCWD); }
+
+ CWDGuard(CWDGuard const&) = delete;
+ CWDGuard& operator=(CWDGuard const&) = delete;
+};
+
TEST_SUITE(filesystem_canonical_path_test_suite)
TEST_CASE(signature_test)
@@ -37,32 +47,29 @@ TEST_CASE(signature_test)
// Each scope tests one of the cases.
TEST_CASE(test_canonical)
{
- static_test_env static_env;
CWDGuard guard;
// has_root_name() && has_root_directory()
- const path Root = static_env.Root;
+ const path Root = StaticEnv::Root;
const path RootName = Root.filename();
- const path DirName = static_env.Dir.filename();
- const path SymlinkName = static_env.SymlinkToFile.filename();
+ const path DirName = StaticEnv::Dir.filename();
+ const path SymlinkName = StaticEnv::SymlinkToFile.filename();
struct TestCase {
path p;
path expect;
path base;
- TestCase(path p1, path e, path b)
+ TestCase(path p1, path e, path b = StaticEnv::Root)
: p(p1), expect(e), base(b) {}
};
const TestCase testCases[] = {
- { ".", Root, Root },
- { DirName / ".." / "." / DirName, static_env.Dir, Root },
- { static_env.Dir2 / "..", static_env.Dir, Root },
- { static_env.Dir3 / "../..", static_env.Dir, Root },
- { static_env.Dir / ".", static_env.Dir, Root },
- { Root / "." / DirName / ".." / DirName, static_env.Dir, Root },
- { path("..") / "." / RootName / DirName / ".." / DirName,
- static_env.Dir,
- Root },
- { static_env.SymlinkToFile, static_env.File, Root },
- { SymlinkName, static_env.File, Root}
+ { ".", Root, Root},
+ { DirName / ".." / "." / DirName, StaticEnv::Dir, Root},
+ { StaticEnv::Dir2 / "..", StaticEnv::Dir },
+ { StaticEnv::Dir3 / "../..", StaticEnv::Dir },
+ { StaticEnv::Dir / ".", StaticEnv::Dir },
+ { Root / "." / DirName / ".." / DirName, StaticEnv::Dir},
+ { path("..") / "." / RootName / DirName / ".." / DirName, StaticEnv::Dir, Root},
+ { StaticEnv::SymlinkToFile, StaticEnv::File },
+ { SymlinkName, StaticEnv::File, StaticEnv::Root}
};
for (auto& TC : testCases) {
std::error_code ec = GetTestEC();
@@ -78,23 +85,21 @@ TEST_CASE(test_canonical)
TEST_CASE(test_dne_path)
{
- static_test_env static_env;
std::error_code ec = GetTestEC();
{
- const path ret = canonical(static_env.DNE, ec);
+ const path ret = canonical(StaticEnv::DNE, ec);
TEST_CHECK(ec != GetTestEC());
TEST_REQUIRE(ec);
TEST_CHECK(ret == path{});
}
{
- TEST_CHECK_THROW(filesystem_error, canonical(static_env.DNE));
+ TEST_CHECK_THROW(filesystem_error, canonical(StaticEnv::DNE));
}
}
TEST_CASE(test_exception_contains_paths)
{
#ifndef TEST_HAS_NO_EXCEPTIONS
- static_test_env static_env;
CWDGuard guard;
const path p = "blabla/dne";
try {
@@ -105,13 +110,13 @@ TEST_CASE(test_exception_contains_paths)
// libc++ provides the current path as the second path in the exception
LIBCPP_ONLY(TEST_CHECK(err.path2() == current_path()));
}
- fs::current_path(static_env.Dir);
+ fs::current_path(StaticEnv::Dir);
try {
canonical(p);
TEST_REQUIRE(false);
} catch (filesystem_error const& err) {
TEST_CHECK(err.path1() == p);
- LIBCPP_ONLY(TEST_CHECK(err.path2() == static_env.Dir));
+ LIBCPP_ONLY(TEST_CHECK(err.path2() == StaticEnv::Dir));
}
#endif
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
index 5ffbe1a51c15..82565433e310 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
@@ -63,7 +63,6 @@ TEST_CASE(test_error_reporting)
#endif
};
- static_test_env static_env;
scoped_test_env env;
const path file = env.create_file("file1", 42);
const path dir = env.create_dir("dir");
@@ -75,7 +74,7 @@ TEST_CASE(test_error_reporting)
// !exists(f)
{
std::error_code ec = test_ec;
- const path f = static_env.DNE;
+ const path f = StaticEnv::DNE;
const path t = env.test_root;
fs::copy(f, t, ec);
TEST_REQUIRE(ec);
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
index f5ca9023d96b..cae78c2f5614 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.current_path/current_path.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -51,18 +52,14 @@ TEST_CASE(current_path_test)
TEST_CASE(current_path_after_change_test)
{
- CWDGuard guard;
- static_test_env static_env;
- const path new_path = static_env.Dir;
+ const path new_path = StaticEnv::Dir;
current_path(new_path);
TEST_CHECK(current_path() == new_path);
}
TEST_CASE(current_path_is_file_test)
{
- CWDGuard guard;
- static_test_env static_env;
- const path p = static_env.File;
+ const path p = StaticEnv::File;
std::error_code ec;
const path old_p = current_path();
current_path(p, ec);
@@ -72,16 +69,14 @@ TEST_CASE(current_path_is_file_test)
TEST_CASE(set_to_non_absolute_path)
{
- CWDGuard guard;
- static_test_env static_env;
- const path base = static_env.Dir;
+ const path base = StaticEnv::Dir;
current_path(base);
- const path p = static_env.Dir2.filename();
+ const path p = StaticEnv::Dir2.filename();
std::error_code ec;
current_path(p, ec);
TEST_CHECK(!ec);
const path new_cwd = current_path();
- TEST_CHECK(new_cwd == static_env.Dir2);
+ TEST_CHECK(new_cwd == StaticEnv::Dir2);
TEST_CHECK(new_cwd.is_absolute());
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
index 35f337d0b0a7..71fce4726661 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -35,19 +36,18 @@ TEST_CASE(signature_test) {
}
TEST_CASE(equivalent_test) {
- static_test_env static_env;
struct TestCase {
path lhs;
path rhs;
bool expect;
};
const TestCase testCases[] = {
- {static_env.Dir, static_env.Dir, true},
- {static_env.File, static_env.Dir, false},
- {static_env.Dir, static_env.SymlinkToDir, true},
- {static_env.Dir, static_env.SymlinkToFile, false},
- {static_env.File, static_env.File, true},
- {static_env.File, static_env.SymlinkToFile, true},
+ {StaticEnv::Dir, StaticEnv::Dir, true},
+ {StaticEnv::File, StaticEnv::Dir, false},
+ {StaticEnv::Dir, StaticEnv::SymlinkToDir, true},
+ {StaticEnv::Dir, StaticEnv::SymlinkToFile, false},
+ {StaticEnv::File, StaticEnv::File, true},
+ {StaticEnv::File, StaticEnv::SymlinkToFile, true},
};
for (auto& TC : testCases) {
std::error_code ec;
@@ -57,9 +57,8 @@ TEST_CASE(equivalent_test) {
}
TEST_CASE(equivalent_reports_error_if_input_dne) {
- static_test_env static_env;
- const path E = static_env.File;
- const path DNE = static_env.DNE;
+ const path E = StaticEnv::File;
+ const path DNE = StaticEnv::DNE;
{ // Test that an error is reported when either of the paths don't exist
std::error_code ec = GetTestEC();
TEST_CHECK(equivalent(E, DNE, ec) == false);
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
index b51182b64b4f..45270d4cd0ec 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.exists/exists.pass.cpp
@@ -62,8 +62,7 @@ TEST_CASE(exists_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(exists(p) == false);
std::error_code ec = GetTestEC();
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp
index 0573aa5470d2..6f27a4cb5712 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.file_size/file_size.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -37,8 +38,7 @@ TEST_CASE(signature_test)
TEST_CASE(file_size_empty_test)
{
- static_test_env static_env;
- const path p = static_env.EmptyFile;
+ const path p = StaticEnv::EmptyFile;
TEST_CHECK(file_size(p) == 0);
std::error_code ec;
TEST_CHECK(file_size(p, ec) == 0);
@@ -55,23 +55,21 @@ TEST_CASE(file_size_non_empty)
TEST_CASE(symlink_test_case)
{
- static_test_env static_env;
- const path p = static_env.File;
- const path p2 = static_env.SymlinkToFile;
+ const path p = StaticEnv::File;
+ const path p2 = StaticEnv::SymlinkToFile;
TEST_CHECK(file_size(p) == file_size(p2));
}
TEST_CASE(file_size_error_cases)
{
- static_test_env static_env;
struct {
path p;
std::errc expected_err;
} TestCases[] = {
- {static_env.Dir, std::errc::is_a_directory},
- {static_env.SymlinkToDir, std::errc::is_a_directory},
- {static_env.BadSymlink, std::errc::no_such_file_or_directory},
- {static_env.DNE, std::errc::no_such_file_or_directory},
+ {StaticEnv::Dir, std::errc::is_a_directory},
+ {StaticEnv::SymlinkToDir, std::errc::is_a_directory},
+ {StaticEnv::BadSymlink, std::errc::no_such_file_or_directory},
+ {StaticEnv::DNE, std::errc::no_such_file_or_directory},
{"", std::errc::no_such_file_or_directory}};
const uintmax_t expect = static_cast<uintmax_t>(-1);
for (auto& TC : TestCases) {
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
index 82ac57207171..96da42be0bc7 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.hard_lk_ct/hard_link_count.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -37,15 +38,13 @@ TEST_CASE(signature_test)
TEST_CASE(hard_link_count_for_file)
{
- static_test_env static_env;
- TEST_CHECK(hard_link_count(static_env.File) == 1);
+ TEST_CHECK(hard_link_count(StaticEnv::File) == 1);
std::error_code ec;
- TEST_CHECK(hard_link_count(static_env.File, ec) == 1);
+ TEST_CHECK(hard_link_count(StaticEnv::File, ec) == 1);
}
TEST_CASE(hard_link_count_for_directory)
{
- static_test_env static_env;
uintmax_t DirExpect = 3; // hard link from . .. and Dir2
uintmax_t Dir3Expect = 2; // hard link from . ..
uintmax_t DirExpectAlt = DirExpect;
@@ -57,20 +56,20 @@ TEST_CASE(hard_link_count_for_directory)
DirExpectAlt = 5; // . .. Dir2 file1 file2
Dir3Expect = 3; // . .. file5
#endif
- TEST_CHECK(hard_link_count(static_env.Dir) == DirExpect ||
- hard_link_count(static_env.Dir) == DirExpectAlt ||
- hard_link_count(static_env.Dir) == 1);
- TEST_CHECK(hard_link_count(static_env.Dir3) == Dir3Expect ||
- hard_link_count(static_env.Dir3) == Dir3ExpectAlt ||
- hard_link_count(static_env.Dir3) == 1);
+ TEST_CHECK(hard_link_count(StaticEnv::Dir) == DirExpect ||
+ hard_link_count(StaticEnv::Dir) == DirExpectAlt ||
+ hard_link_count(StaticEnv::Dir) == 1);
+ TEST_CHECK(hard_link_count(StaticEnv::Dir3) == Dir3Expect ||
+ hard_link_count(StaticEnv::Dir3) == Dir3ExpectAlt ||
+ hard_link_count(StaticEnv::Dir3) == 1);
std::error_code ec;
- TEST_CHECK(hard_link_count(static_env.Dir, ec) == DirExpect ||
- hard_link_count(static_env.Dir, ec) == DirExpectAlt ||
- hard_link_count(static_env.Dir) == 1);
- TEST_CHECK(hard_link_count(static_env.Dir3, ec) == Dir3Expect ||
- hard_link_count(static_env.Dir3, ec) == Dir3ExpectAlt ||
- hard_link_count(static_env.Dir3) == 1);
+ TEST_CHECK(hard_link_count(StaticEnv::Dir, ec) == DirExpect ||
+ hard_link_count(StaticEnv::Dir, ec) == DirExpectAlt ||
+ hard_link_count(StaticEnv::Dir) == 1);
+ TEST_CHECK(hard_link_count(StaticEnv::Dir3, ec) == Dir3Expect ||
+ hard_link_count(StaticEnv::Dir3, ec) == Dir3ExpectAlt ||
+ hard_link_count(StaticEnv::Dir3) == 1);
}
TEST_CASE(hard_link_count_increments_test)
{
@@ -85,10 +84,9 @@ TEST_CASE(hard_link_count_increments_test)
TEST_CASE(hard_link_count_error_cases)
{
- static_test_env static_env;
const path testCases[] = {
- static_env.BadSymlink,
- static_env.DNE
+ StaticEnv::BadSymlink,
+ StaticEnv::DNE
};
const uintmax_t expect = static_cast<uintmax_t>(-1);
for (auto& TC : testCases) {
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
index c584605d6381..6cfbc340c44f 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_block_file/is_block_file.pass.cpp
@@ -62,8 +62,7 @@ TEST_CASE(is_block_file_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_block_file(p) == false);
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
index 90690a211e6b..12e66019b65c 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_char_file/is_character_file.pass.cpp
@@ -62,8 +62,7 @@ TEST_CASE(is_character_file_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_character_file(p) == false);
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
index 1059a648641e..35dd5d40f7b0 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_directory/is_directory.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -62,17 +63,15 @@ TEST_CASE(is_directory_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_directory(p) == false);
}
TEST_CASE(static_env_test)
{
- static_test_env static_env;
- TEST_CHECK(is_directory(static_env.Dir));
- TEST_CHECK(is_directory(static_env.SymlinkToDir));
- TEST_CHECK(!is_directory(static_env.File));
+ TEST_CHECK(is_directory(StaticEnv::Dir));
+ TEST_CHECK(is_directory(StaticEnv::SymlinkToDir));
+ TEST_CHECK(!is_directory(StaticEnv::File));
}
TEST_CASE(test_is_directory_fails)
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
index 606cebbf437e..e3393240aa40 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -35,8 +36,7 @@ TEST_CASE(signature_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
std::error_code ec;
TEST_CHECK(is_empty(p, ec) == false);
TEST_CHECK(ec);
@@ -45,9 +45,8 @@ TEST_CASE(test_exist_not_found)
TEST_CASE(test_is_empty_directory)
{
- static_test_env static_env;
- TEST_CHECK(!is_empty(static_env.Dir));
- TEST_CHECK(!is_empty(static_env.SymlinkToDir));
+ TEST_CHECK(!is_empty(StaticEnv::Dir));
+ TEST_CHECK(!is_empty(StaticEnv::SymlinkToDir));
}
TEST_CASE(test_is_empty_directory_dynamic)
@@ -60,9 +59,8 @@ TEST_CASE(test_is_empty_directory_dynamic)
TEST_CASE(test_is_empty_file)
{
- static_test_env static_env;
- TEST_CHECK(is_empty(static_env.EmptyFile));
- TEST_CHECK(!is_empty(static_env.NonEmptyFile));
+ TEST_CHECK(is_empty(StaticEnv::EmptyFile));
+ TEST_CHECK(!is_empty(StaticEnv::NonEmptyFile));
}
TEST_CASE(test_is_empty_fails)
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
index 1488a8916530..4dcf04390364 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_fifo/is_fifo.pass.cpp
@@ -62,8 +62,7 @@ TEST_CASE(is_fifo_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_fifo(p) == false);
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
index 1381eb5ae6e4..894cc57aeba2 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_other/is_other.pass.cpp
@@ -62,8 +62,7 @@ TEST_CASE(is_other_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_other(p) == false);
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
index 5c5e1ea07c75..3fcf779b3213 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_regular_file/is_regular_file.pass.cpp
@@ -62,8 +62,7 @@ TEST_CASE(is_regular_file_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_regular_file(p) == false);
std::error_code ec;
TEST_CHECK(is_regular_file(p, ec) == false);
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
index 3f35c50f6011..ba727d6384c4 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_socket/is_socket.pass.cpp
@@ -62,8 +62,7 @@ TEST_CASE(is_socket_status_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_socket(p) == false);
}
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
index 14da9cb7fa95..75ab6059f4d8 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_symlink/is_symlink.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -62,17 +63,16 @@ TEST_CASE(is_symlink_status_test)
TEST_CASE(static_env_test)
{
- static_test_env static_env;
struct TestCase {
path p;
bool expect;
};
const TestCase testCases[] = {
- {static_env.File, false},
- {static_env.Dir, false},
- {static_env.SymlinkToFile, true},
- {static_env.SymlinkToDir, true},
- {static_env.BadSymlink, true}
+ {StaticEnv::File, false},
+ {StaticEnv::Dir, false},
+ {StaticEnv::SymlinkToFile, true},
+ {StaticEnv::SymlinkToDir, true},
+ {StaticEnv::BadSymlink, true}
};
for (auto& TC : testCases) {
TEST_CHECK(is_symlink(TC.p) == TC.expect);
@@ -81,8 +81,7 @@ TEST_CASE(static_env_test)
TEST_CASE(test_exist_not_found)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
TEST_CHECK(is_symlink(p) == false);
std::error_code ec;
TEST_CHECK(is_symlink(p, ec) == false);
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
index e71da60a65e9..3ef4c53303ad 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -349,28 +350,27 @@ TEST_CASE(signature_test)
TEST_CASE(read_last_write_time_static_env_test)
{
- static_test_env static_env;
using C = file_time_type::clock;
file_time_type min = file_time_type::min();
{
- file_time_type ret = last_write_time(static_env.File);
+ file_time_type ret = last_write_time(StaticEnv::File);
TEST_CHECK(ret != min);
TEST_CHECK(ret < C::now());
- TEST_CHECK(CompareTime(ret, LastWriteTime(static_env.File)));
+ TEST_CHECK(CompareTime(ret, LastWriteTime(StaticEnv::File)));
- file_time_type ret2 = last_write_time(static_env.SymlinkToFile);
+ file_time_type ret2 = last_write_time(StaticEnv::SymlinkToFile);
TEST_CHECK(CompareTime(ret, ret2));
- TEST_CHECK(CompareTime(ret2, LastWriteTime(static_env.SymlinkToFile)));
+ TEST_CHECK(CompareTime(ret2, LastWriteTime(StaticEnv::SymlinkToFile)));
}
{
- file_time_type ret = last_write_time(static_env.Dir);
+ file_time_type ret = last_write_time(StaticEnv::Dir);
TEST_CHECK(ret != min);
TEST_CHECK(ret < C::now());
- TEST_CHECK(CompareTime(ret, LastWriteTime(static_env.Dir)));
+ TEST_CHECK(CompareTime(ret, LastWriteTime(StaticEnv::Dir)));
- file_time_type ret2 = last_write_time(static_env.SymlinkToDir);
+ file_time_type ret2 = last_write_time(StaticEnv::SymlinkToDir);
TEST_CHECK(CompareTime(ret, ret2));
- TEST_CHECK(CompareTime(ret2, LastWriteTime(static_env.SymlinkToDir)));
+ TEST_CHECK(CompareTime(ret2, LastWriteTime(StaticEnv::SymlinkToDir)));
}
}
@@ -564,8 +564,7 @@ TEST_CASE(test_write_max_time) {
TEST_CASE(test_value_on_failure)
{
- static_test_env static_env;
- const path p = static_env.DNE;
+ const path p = StaticEnv::DNE;
std::error_code ec = GetTestEC();
TEST_CHECK(last_write_time(p, ec) == file_time_type::min());
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.relative/relative.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.relative/relative.pass.cpp
index ffe2b3890f0f..2a8d8296c861 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.relative/relative.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.relative/relative.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -41,89 +42,77 @@ TEST_CASE(test_signature_1) {
}
TEST_CASE(test_signature_2) {
- static_test_env static_env;
- fs::path p(static_env.File);
+ fs::path p(StaticEnv::File);
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.File));
+ TEST_CHECK(output == std::string(StaticEnv::File));
}
TEST_CASE(test_signature_3) {
- static_test_env static_env;
- fs::path p(static_env.Dir);
+ fs::path p(StaticEnv::Dir);
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir));
+ TEST_CHECK(output == std::string(StaticEnv::Dir));
}
TEST_CASE(test_signature_4) {
- static_test_env static_env;
- fs::path p(static_env.SymlinkToDir);
+ fs::path p(StaticEnv::SymlinkToDir);
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir));
+ TEST_CHECK(output == std::string(StaticEnv::Dir));
}
TEST_CASE(test_signature_5) {
- static_test_env static_env;
- fs::path p(static_env.SymlinkToDir / "dir2/.");
+ fs::path p(StaticEnv::SymlinkToDir / "dir2/.");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir / "dir2"));
+ TEST_CHECK(output == std::string(StaticEnv::Dir / "dir2"));
}
TEST_CASE(test_signature_6) {
- static_test_env static_env;
// FIXME? If the trailing separator occurs in a part of the path that exists,
// it is omitted. Otherwise it is added to the end of the result.
- fs::path p(static_env.SymlinkToDir / "dir2/./");
+ fs::path p(StaticEnv::SymlinkToDir / "dir2/./");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir / "dir2"));
+ TEST_CHECK(output == std::string(StaticEnv::Dir / "dir2"));
}
TEST_CASE(test_signature_7) {
- static_test_env static_env;
- fs::path p(static_env.SymlinkToDir / "dir2/DNE/./");
+ fs::path p(StaticEnv::SymlinkToDir / "dir2/DNE/./");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir / "dir2/DNE/"));
+ TEST_CHECK(output == std::string(StaticEnv::Dir / "dir2/DNE/"));
}
TEST_CASE(test_signature_8) {
- static_test_env static_env;
- fs::path p(static_env.SymlinkToDir / "dir2");
+ fs::path p(StaticEnv::SymlinkToDir / "dir2");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir2));
+ TEST_CHECK(output == std::string(StaticEnv::Dir2));
}
TEST_CASE(test_signature_9) {
- static_test_env static_env;
- fs::path p(static_env.SymlinkToDir / "dir2/../dir2/DNE/..");
+ fs::path p(StaticEnv::SymlinkToDir / "dir2/../dir2/DNE/..");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir2 / ""));
+ TEST_CHECK(output == std::string(StaticEnv::Dir2 / ""));
}
TEST_CASE(test_signature_10) {
- static_test_env static_env;
- fs::path p(static_env.SymlinkToDir / "dir2/dir3/../DNE/DNE2");
+ fs::path p(StaticEnv::SymlinkToDir / "dir2/dir3/../DNE/DNE2");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir2 / "DNE/DNE2"));
+ TEST_CHECK(output == std::string(StaticEnv::Dir2 / "DNE/DNE2"));
}
TEST_CASE(test_signature_11) {
- static_test_env static_env;
- fs::path p(static_env.Dir / "../dir1");
+ fs::path p(StaticEnv::Dir / "../dir1");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir));
+ TEST_CHECK(output == std::string(StaticEnv::Dir));
}
TEST_CASE(test_signature_12) {
- static_test_env static_env;
- fs::path p(static_env.Dir / "./.");
+ fs::path p(StaticEnv::Dir / "./.");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir));
+ TEST_CHECK(output == std::string(StaticEnv::Dir));
}
TEST_CASE(test_signature_13) {
- static_test_env static_env;
- fs::path p(static_env.Dir / "DNE/../foo");
+ fs::path p(StaticEnv::Dir / "DNE/../foo");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(static_env.Dir / "foo"));
+ TEST_CHECK(output == std::string(StaticEnv::Dir / "foo"));
}
TEST_SUITE_END()
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp
index 6de0b10c6e54..4a0936b920db 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.space/space.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -44,7 +45,6 @@ TEST_CASE(signature_test)
TEST_CASE(test_error_reporting)
{
- static_test_env static_env;
auto checkThrow = [](path const& f, const std::error_code& ec)
{
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -63,8 +63,8 @@ TEST_CASE(test_error_reporting)
};
const path cases[] = {
"",
- static_env.DNE,
- static_env.BadSymlink
+ StaticEnv::DNE,
+ StaticEnv::BadSymlink
};
for (auto& p : cases) {
const auto expect = static_cast<std::uintmax_t>(-1);
@@ -80,13 +80,11 @@ TEST_CASE(test_error_reporting)
TEST_CASE(basic_space_test)
{
- static_test_env static_env;
-
// All the test cases should reside on the same filesystem and therefore
// should have the same expected result. Compute this expected result
// one and check that it looks semi-sane.
struct statvfs expect;
- TEST_REQUIRE(::statvfs(static_env.Dir.c_str(), &expect) != -1);
+ TEST_REQUIRE(::statvfs(StaticEnv::Dir.c_str(), &expect) != -1);
TEST_CHECK(expect.f_bavail > 0);
TEST_CHECK(expect.f_bfree > 0);
TEST_CHECK(expect.f_bsize > 0);
@@ -108,11 +106,11 @@ TEST_CASE(basic_space_test)
// Currently 5% of capacity
const std::uintmax_t delta = expect_capacity / 20;
const path cases[] = {
- static_env.File,
- static_env.Dir,
- static_env.Dir2,
- static_env.SymlinkToFile,
- static_env.SymlinkToDir
+ StaticEnv::File,
+ StaticEnv::Dir,
+ StaticEnv::Dir2,
+ StaticEnv::SymlinkToFile,
+ StaticEnv::SymlinkToDir
};
for (auto& p : cases) {
std::error_code ec = GetTestEC();
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
index af4ddb9c8906..60c99ee923d5 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.status/status.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -33,12 +34,11 @@ TEST_CASE(signature_test)
TEST_CASE(test_status_not_found)
{
- static_test_env static_env;
const std::error_code expect_ec =
std::make_error_code(std::errc::no_such_file_or_directory);
const path cases[] {
- static_env.DNE,
- static_env.BadSymlink
+ StaticEnv::DNE,
+ StaticEnv::BadSymlink
};
for (auto& p : cases) {
std::error_code ec = std::make_error_code(std::errc::address_in_use);
@@ -103,18 +103,17 @@ TEST_CASE(test_status_cannot_resolve)
TEST_CASE(status_file_types_test)
{
- static_test_env static_env;
scoped_test_env env;
struct TestCase {
path p;
file_type expect_type;
} cases[] = {
- {static_env.File, file_type::regular},
- {static_env.SymlinkToFile, file_type::regular},
- {static_env.Dir, file_type::directory},
- {static_env.SymlinkToDir, file_type::directory},
+ {StaticEnv::File, file_type::regular},
+ {StaticEnv::SymlinkToFile, file_type::regular},
+ {StaticEnv::Dir, file_type::directory},
+ {StaticEnv::SymlinkToDir, file_type::directory},
// Block files tested elsewhere
- {static_env.CharFile, file_type::character},
+ {StaticEnv::CharFile, file_type::character},
#if !defined(__APPLE__) && !defined(__FreeBSD__) // No support for domain sockets
{env.create_socket("socket"), file_type::socket},
#endif
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
index e883739b7d5b..350076fcf370 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.symlink_status/symlink_status.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -33,11 +34,10 @@ TEST_CASE(signature_test)
TEST_CASE(test_symlink_status_not_found)
{
- static_test_env static_env;
const std::error_code expect_ec =
std::make_error_code(std::errc::no_such_file_or_directory);
const path cases[] {
- static_env.DNE
+ StaticEnv::DNE
};
for (auto& p : cases) {
std::error_code ec = std::make_error_code(std::errc::address_in_use);
@@ -110,19 +110,18 @@ TEST_CASE(test_symlink_status_cannot_resolve)
TEST_CASE(symlink_status_file_types_test)
{
- static_test_env static_env;
scoped_test_env env;
struct TestCase {
path p;
file_type expect_type;
} cases[] = {
- {static_env.BadSymlink, file_type::symlink},
- {static_env.File, file_type::regular},
- {static_env.SymlinkToFile, file_type::symlink},
- {static_env.Dir, file_type::directory},
- {static_env.SymlinkToDir, file_type::symlink},
+ {StaticEnv::BadSymlink, file_type::symlink},
+ {StaticEnv::File, file_type::regular},
+ {StaticEnv::SymlinkToFile, file_type::symlink},
+ {StaticEnv::Dir, file_type::directory},
+ {StaticEnv::SymlinkToDir, file_type::symlink},
// Block files tested elsewhere
- {static_env.CharFile, file_type::character},
+ {StaticEnv::CharFile, file_type::character},
#if !defined(__APPLE__) && !defined(__FreeBSD__) // No support for domain sockets
{env.create_socket("socket"), file_type::socket},
#endif
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
index c2c86bc35a6b..35d97b8703d5 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -26,9 +27,6 @@
int main(int, char**) {
-
- static_test_env static_env;
-
// clang-format off
struct {
std::string input;
@@ -43,20 +41,20 @@ int main(int, char**) {
{"a/b", fs::current_path() / "a/b"},
{"a", fs::current_path() / "a"},
{"a/b/", fs::current_path() / "a/b/"},
- {static_env.File, static_env.File},
- {static_env.Dir, static_env.Dir},
- {static_env.SymlinkToDir, static_env.Dir},
- {static_env.SymlinkToDir / "dir2/.", static_env.Dir / "dir2"},
+ {StaticEnv::File, StaticEnv::File},
+ {StaticEnv::Dir, StaticEnv::Dir},
+ {StaticEnv::SymlinkToDir, StaticEnv::Dir},
+ {StaticEnv::SymlinkToDir / "dir2/.", StaticEnv::Dir / "dir2"},
// FIXME? If the trailing separator occurs in a part of the path that exists,
// it is omitted. Otherwise it is added to the end of the result.
- {static_env.SymlinkToDir / "dir2/./", static_env.Dir / "dir2"},
- {static_env.SymlinkToDir / "dir2/DNE/./", static_env.Dir / "dir2/DNE/"},
- {static_env.SymlinkToDir / "dir2", static_env.Dir2},
- {static_env.SymlinkToDir / "dir2/../dir2/DNE/..", static_env.Dir2 / ""},
- {static_env.SymlinkToDir / "dir2/dir3/../DNE/DNE2", static_env.Dir2 / "DNE/DNE2"},
- {static_env.Dir / "../dir1", static_env.Dir},
- {static_env.Dir / "./.", static_env.Dir},
- {static_env.Dir / "DNE/../foo", static_env.Dir / "foo"}
+ {StaticEnv::SymlinkToDir / "dir2/./", StaticEnv::Dir / "dir2"},
+ {StaticEnv::SymlinkToDir / "dir2/DNE/./", StaticEnv::Dir / "dir2/DNE/"},
+ {StaticEnv::SymlinkToDir / "dir2", StaticEnv::Dir2},
+ {StaticEnv::SymlinkToDir / "dir2/../dir2/DNE/..", StaticEnv::Dir2 / ""},
+ {StaticEnv::SymlinkToDir / "dir2/dir3/../DNE/DNE2", StaticEnv::Dir2 / "DNE/DNE2"},
+ {StaticEnv::Dir / "../dir1", StaticEnv::Dir},
+ {StaticEnv::Dir / "./.", StaticEnv::Dir},
+ {StaticEnv::Dir / "DNE/../foo", StaticEnv::Dir / "foo"}
};
// clang-format on
int ID = 0;
diff --git a/libcxx/test/support/filesystem_test_helper.h b/libcxx/test/support/filesystem_test_helper.h
index bd136d597949..8553317de76f 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -3,8 +3,7 @@
#include "filesystem_include.h"
-#include <sys/stat.h> // for mkdir, mkfifo
-#include <unistd.h> // for ftruncate, link, symlink
+#include <unistd.h> // for ftruncate
#include <cassert>
#include <cstdio> // for printf
@@ -25,6 +24,89 @@
# include <sys/un.h>
#endif
+// static test helpers
+
+namespace StaticEnv {
+
+// Tests that use these utilities should add '<...>/Inputs/static_test_env'
+// to their FILE_DEPENDENCIES, to make sure the directory is made available
+// to the test. Assuming that, the 'static_test_env' will be available in the
+// directory where the test is run.
+static const fs::path Root = fs::current_path() / "static_test_env";
+
+inline fs::path makePath(fs::path const& p) {
+ // env_path is expected not to contain symlinks.
+ fs::path const& env_path = Root;
+ return env_path / p;
+}
+
+static const fs::path TestFileList[] = {
+ makePath("empty_file"),
+ makePath("non_empty_file"),
+ makePath("dir1/file1"),
+ makePath("dir1/file2")
+};
+const std::size_t TestFileListSize = sizeof(TestFileList) / sizeof(fs::path);
+
+static const fs::path TestDirList[] = {
+ makePath("dir1"),
+ makePath("dir1/dir2"),
+ makePath("dir1/dir2/dir3")
+};
+const std::size_t TestDirListSize = sizeof(TestDirList) / sizeof(fs::path);
+
+static const fs::path File = TestFileList[0];
+static const fs::path Dir = TestDirList[0];
+static const fs::path Dir2 = TestDirList[1];
+static const fs::path Dir3 = TestDirList[2];
+static const fs::path SymlinkToFile = makePath("symlink_to_empty_file");
+static const fs::path SymlinkToDir = makePath("symlink_to_dir");
+static const fs::path BadSymlink = makePath("bad_symlink");
+static const fs::path DNE = makePath("DNE");
+static const fs::path EmptyFile = TestFileList[0];
+static const fs::path NonEmptyFile = TestFileList[1];
+static const fs::path CharFile = "/dev/null"; // Hopefully this exists
+
+static const fs::path DirIterationList[] = {
+ makePath("dir1/dir2"),
+ makePath("dir1/file1"),
+ makePath("dir1/file2")
+};
+const std::size_t DirIterationListSize = sizeof(DirIterationList)
+ / sizeof(fs::path);
+
+static const fs::path DirIterationListDepth1[] = {
+ makePath("dir1/dir2/afile3"),
+ makePath("dir1/dir2/dir3"),
+ makePath("dir1/dir2/symlink_to_dir3"),
+ makePath("dir1/dir2/file4"),
+};
+
+static const fs::path RecDirIterationList[] = {
+ makePath("dir1/dir2"),
+ makePath("dir1/file1"),
+ makePath("dir1/file2"),
+ makePath("dir1/dir2/afile3"),
+ makePath("dir1/dir2/dir3"),
+ makePath("dir1/dir2/symlink_to_dir3"),
+ makePath("dir1/dir2/file4"),
+ makePath("dir1/dir2/dir3/file5")
+};
+
+static const fs::path RecDirFollowSymlinksIterationList[] = {
+ makePath("dir1/dir2"),
+ makePath("dir1/file1"),
+ makePath("dir1/file2"),
+ makePath("dir1/dir2/afile3"),
+ makePath("dir1/dir2/dir3"),
+ makePath("dir1/dir2/file4"),
+ makePath("dir1/dir2/dir3/file5"),
+ makePath("dir1/dir2/symlink_to_dir3"),
+ makePath("dir1/dir2/symlink_to_dir3/file5"),
+};
+
+} // namespace StaticEnv
+
namespace random_utils {
inline char to_hex(int ch) {
return ch < 10 ? static_cast<char>('0' + ch)
@@ -125,18 +207,17 @@ struct scoped_test_env
std::string create_dir(std::string filename) {
filename = sanitize_path(std::move(filename));
- int ret = ::mkdir(filename.c_str(), 0777); // rwxrwxrwx mode
+ std::string cmd = "mkdir " + filename;
+ int ret = std::system(cmd.c_str());
assert(ret == 0);
return filename;
}
- std::string create_symlink(std::string source,
- std::string to,
- bool sanitize_source = true) {
- if (sanitize_source)
- source = sanitize_path(std::move(source));
+ std::string create_symlink(std::string source, std::string to) {
+ source = sanitize_path(std::move(source));
to = sanitize_path(std::move(to));
- int ret = ::symlink(source.c_str(), to.c_str());
+ std::string cmd = "ln -s " + source + ' ' + to;
+ int ret = std::system(cmd.c_str());
assert(ret == 0);
return to;
}
@@ -144,14 +225,16 @@ struct scoped_test_env
std::string create_hardlink(std::string source, std::string to) {
source = sanitize_path(std::move(source));
to = sanitize_path(std::move(to));
- int ret = ::link(source.c_str(), to.c_str());
+ std::string cmd = "ln " + source + ' ' + to;
+ int ret = std::system(cmd.c_str());
assert(ret == 0);
return to;
}
std::string create_fifo(std::string file) {
file = sanitize_path(std::move(file));
- int ret = ::mkfifo(file.c_str(), 0666); // rw-rw-rw- mode
+ std::string cmd = "mkfifo " + file;
+ int ret = std::system(cmd.c_str());
assert(ret == 0);
return file;
}
@@ -193,123 +276,6 @@ struct scoped_test_env
}
};
-/// This class generates the following tree:
-///
-/// static_test_env
-/// ├── bad_symlink -> dne
-/// ├── dir1
-/// │ ├── dir2
-/// │ │ ├── afile3
-/// │ │ ├── dir3
-/// │ │ │ └── file5
-/// │ │ ├── file4
-/// │ │ └── symlink_to_dir3 -> dir3
-/// │ ├── file1
-/// │ └── file2
-/// ├── empty_file
-/// ├── non_empty_file
-/// ├── symlink_to_dir -> dir1
-/// └── symlink_to_empty_file -> empty_file
-///
-class static_test_env {
- scoped_test_env env_;
-public:
- static_test_env() {
- env_.create_symlink("dne", "bad_symlink", false);
- env_.create_dir("dir1");
- env_.create_dir("dir1/dir2");
- env_.create_file("dir1/dir2/afile3");
- env_.create_dir("dir1/dir2/dir3");
- env_.create_file("dir1/dir2/dir3/file5");
- env_.create_file("dir1/dir2/file4");
- env_.create_symlink("dir3", "dir1/dir2/symlink_to_dir3", false);
- env_.create_file("dir1/file1");
- env_.create_file("dir1/file2", 42);
- env_.create_file("empty_file");
- env_.create_file("non_empty_file", 42);
- env_.create_symlink("dir1", "symlink_to_dir", false);
- env_.create_symlink("empty_file", "symlink_to_empty_file", false);
- }
-
- const fs::path Root = env_.test_root;
-
- fs::path makePath(fs::path const& p) const {
- // env_path is expected not to contain symlinks.
- fs::path const& env_path = Root;
- return env_path / p;
- }
-
- const std::vector<fs::path> TestFileList = {
- makePath("empty_file"),
- makePath("non_empty_file"),
- makePath("dir1/file1"),
- makePath("dir1/file2")
- };
-
- const std::vector<fs::path> TestDirList = {
- makePath("dir1"),
- makePath("dir1/dir2"),
- makePath("dir1/dir2/dir3")
- };
-
- const fs::path File = TestFileList[0];
- const fs::path Dir = TestDirList[0];
- const fs::path Dir2 = TestDirList[1];
- const fs::path Dir3 = TestDirList[2];
- const fs::path SymlinkToFile = makePath("symlink_to_empty_file");
- const fs::path SymlinkToDir = makePath("symlink_to_dir");
- const fs::path BadSymlink = makePath("bad_symlink");
- const fs::path DNE = makePath("DNE");
- const fs::path EmptyFile = TestFileList[0];
- const fs::path NonEmptyFile = TestFileList[1];
- const fs::path CharFile = "/dev/null"; // Hopefully this exists
-
- const std::vector<fs::path> DirIterationList = {
- makePath("dir1/dir2"),
- makePath("dir1/file1"),
- makePath("dir1/file2")
- };
-
- const std::vector<fs::path> DirIterationListDepth1 = {
- makePath("dir1/dir2/afile3"),
- makePath("dir1/dir2/dir3"),
- makePath("dir1/dir2/symlink_to_dir3"),
- makePath("dir1/dir2/file4"),
- };
-
- const std::vector<fs::path> RecDirIterationList = {
- makePath("dir1/dir2"),
- makePath("dir1/file1"),
- makePath("dir1/file2"),
- makePath("dir1/dir2/afile3"),
- makePath("dir1/dir2/dir3"),
- makePath("dir1/dir2/symlink_to_dir3"),
- makePath("dir1/dir2/file4"),
- makePath("dir1/dir2/dir3/file5")
- };
-
- const std::vector<fs::path> RecDirFollowSymlinksIterationList = {
- makePath("dir1/dir2"),
- makePath("dir1/file1"),
- makePath("dir1/file2"),
- makePath("dir1/dir2/afile3"),
- makePath("dir1/dir2/dir3"),
- makePath("dir1/dir2/file4"),
- makePath("dir1/dir2/dir3/file5"),
- makePath("dir1/dir2/symlink_to_dir3"),
- makePath("dir1/dir2/symlink_to_dir3/file5"),
- };
-};
-
-struct CWDGuard {
- fs::path OldCWD;
- CWDGuard() : OldCWD(fs::current_path()) { }
- ~CWDGuard() { fs::current_path(OldCWD); }
-
- CWDGuard(CWDGuard const&) = delete;
- CWDGuard& operator=(CWDGuard const&) = delete;
-};
-
// Misc test types
#define MKSTR(Str) {Str, TEST_CONCAT(L, Str), TEST_CONCAT(u, Str), TEST_CONCAT(U, Str)}
More information about the libcxx-commits
mailing list