[libcxx-commits] [libcxx] 52cc8ba - [libc++] [test] Generate static_test_env on the fly
Sergej Jaskiewicz via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 5 15:24:19 PDT 2020
Author: Sergej Jaskiewicz
Date: 2020-05-06T01:23:50+03:00
New Revision: 52cc8bac7780dbfb90dcc8cfe24696618eeaa06e
URL: https://github.com/llvm/llvm-project/commit/52cc8bac7780dbfb90dcc8cfe24696618eeaa06e
DIFF: https://github.com/llvm/llvm-project/commit/52cc8bac7780dbfb90dcc8cfe24696618eeaa06e.diff
LOG: [libc++] [test] Generate static_test_env on the fly
Summary:
Instead of storing `static_test_env` (with all the symlinks) in the repo, we create it on the fly to be cross-toolchain-friendly. The primary use case for this are Windows-hosted cross-toolchains. Windows doesn't really have a concept of symlinks. So, when the monorepo is cloned, those symlinks turn to ordinary text files. Previously, if we cross-compiled libc++ for some symlink-friendly system (e. g. Linux) and ran tests on the target system, some tests would fail. This patch makes them pass.
Reviewers: ldionne, #libc
Reviewed By: ldionne, #libc
Subscribers: EricWF, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D78200
Added:
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:
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
################################################################################
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
deleted file mode 120000
index 76646beed5ed..000000000000
--- a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/bad_symlink
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index e69de29bb2d1..000000000000
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
deleted file mode 100644
index e69de29bb2d1..000000000000
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
deleted file mode 100644
index e69de29bb2d1..000000000000
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
deleted file mode 120000
index 397913952621..000000000000
--- a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/dir2/symlink_to_dir3
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index e69de29bb2d1..000000000000
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
deleted file mode 100644
index 44834e586734..000000000000
--- a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/dir1/file2
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index e69de29bb2d1..000000000000
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
deleted file mode 100644
index 44834e586734..000000000000
--- a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/non_empty_file
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 120000
index df490f837a85..000000000000
--- a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_dir
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 120000
index b79b689fc85a..000000000000
--- a/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/symlink_to_empty_file
+++ /dev/null
@@ -1 +0,0 @@
-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 850be12e839c..f7c3e442707d 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -46,6 +45,7 @@ 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(StaticEnv::File, ec);
- TEST_CHECK(e.path() == StaticEnv::File);
+ const directory_entry e(static_env.File, ec);
+ TEST_CHECK(e.path() == static_env.File);
TEST_CHECK(!ec);
}
{
@@ -121,26 +121,28 @@ 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(StaticEnv::DNE, ec);
+ directory_entry ent(static_env.DNE, ec);
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
- TEST_CHECK(ent.path() == StaticEnv::DNE);
+ TEST_CHECK(ent.path() == static_env.DNE);
}
// don't report dead symlinks as an error.
{
std::error_code ec = GetTestEC();
- directory_entry ent(StaticEnv::BadSymlink, ec);
+ directory_entry ent(static_env.BadSymlink, ec);
TEST_CHECK(!ec);
- TEST_CHECK(ent.path() == StaticEnv::BadSymlink);
+ TEST_CHECK(ent.path() == static_env.BadSymlink);
}
// DNE does not cause the constructor to throw
{
- directory_entry ent(StaticEnv::DNE);
- TEST_CHECK(ent.path() == StaticEnv::DNE);
+ directory_entry ent(static_env.DNE);
+ TEST_CHECK(ent.path() == static_env.DNE);
- directory_entry ent_two(StaticEnv::BadSymlink);
- TEST_CHECK(ent_two.path() == StaticEnv::BadSymlink);
+ directory_entry ent_two(static_env.BadSymlink);
+ TEST_CHECK(ent_two.path() == static_env.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 2a2146be1b84..0f3624bd65a5 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -54,6 +53,7 @@ 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 = StaticEnv::EmptyFile;
- const path expect = StaticEnv::NonEmptyFile;
- const path replace = StaticEnv::NonEmptyFile.filename();
+ const path p = static_env.EmptyFile;
+ const path expect = static_env.NonEmptyFile;
+ const path replace = static_env.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 8ff1b46b3b99..ad4cc43c95d9 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -112,6 +111,7 @@ 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(StaticEnv::DNE, ec);
- TEST_REQUIRE(ent.path() == StaticEnv::DNE);
+ ent.assign(static_env.DNE, ec);
+ TEST_REQUIRE(ent.path() == static_env.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(StaticEnv::DNE,
+ ExceptionChecker Checker(static_env.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(StaticEnv::BadSymlink, ec);
+ uintmax_t expect_bad = file_size(static_env.BadSymlink, ec);
TEST_CHECK(expect_bad == uintmax_t(-1));
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
- ent.assign(StaticEnv::BadSymlink, ec);
- TEST_REQUIRE(ent.path() == StaticEnv::BadSymlink);
+ ent.assign(static_env.BadSymlink, ec);
+ TEST_REQUIRE(ent.path() == static_env.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(StaticEnv::BadSymlink,
+ ExceptionChecker Checker(static_env.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 f5a44b76a8b0..b3bfa5e7eeac 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;
-
- for (auto p : {StaticEnv::DNE, StaticEnv::BadSymlink}) {
+ static_test_env static_env;
+ for (auto p : {static_env.DNE, static_env.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 d9958a6c5f03..8090bd77da72 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -110,6 +109,7 @@ 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(StaticEnv::DNE, ec);
+ ent.assign(static_env.DNE, ec);
TEST_CHECK(ec);
- TEST_REQUIRE(ent.path() == StaticEnv::DNE);
+ TEST_REQUIRE(ent.path() == static_env.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(StaticEnv::DNE,
+ ExceptionChecker Checker(static_env.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(StaticEnv::BadSymlink, ec);
+ uintmax_t expect_bad = hard_link_count(static_env.BadSymlink, ec);
TEST_CHECK(expect_bad == uintmax_t(-1));
TEST_CHECK(ErrorIs(ec, std::errc::no_such_file_or_directory));
ec = GetTestEC();
- ent.assign(StaticEnv::BadSymlink, ec);
- TEST_REQUIRE(ent.path() == StaticEnv::BadSymlink);
+ ent.assign(static_env.BadSymlink, ec);
+ TEST_REQUIRE(ent.path() == static_env.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(StaticEnv::BadSymlink,
+ ExceptionChecker Checker(static_env.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 de6c36c218f2..98949ea06e0c 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -84,6 +83,7 @@ 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(StaticEnv::DNE, ec);
- TEST_REQUIRE(ent.path() == StaticEnv::DNE);
+ ent.assign(static_env.DNE, ec);
+ TEST_REQUIRE(ent.path() == static_env.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(StaticEnv::DNE,
+ ExceptionChecker Checker(static_env.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(StaticEnv::BadSymlink, ec);
+ file_time_type expect_bad = last_write_time(static_env.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(StaticEnv::BadSymlink, ec);
- TEST_REQUIRE(ent.path() == StaticEnv::BadSymlink);
+ ent.assign(static_env.BadSymlink, ec);
+ TEST_REQUIRE(ent.path() == static_env.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(StaticEnv::BadSymlink,
+ ExceptionChecker Checker(static_env.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 8ea1fdbcbe6e..796d47bfb525 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,6 +28,7 @@ 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;
@@ -36,8 +37,8 @@ TEST_CASE(test_basic) {
static_assert(noexcept(e.status()) == false, "");
static_assert(noexcept(e.status(ec)) == true, "");
}
- path TestCases[] = {StaticEnv::File, StaticEnv::Dir, StaticEnv::SymlinkToFile,
- StaticEnv::DNE};
+ path TestCases[] = {static_env.File, static_env.Dir, static_env.SymlinkToFile,
+ static_env.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 cff19bc583ff..c8dd6c133539 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,6 +28,7 @@ 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;
@@ -36,8 +37,8 @@ TEST_CASE(test_signature) {
static_assert(noexcept(e.symlink_status()) == false, "");
static_assert(noexcept(e.symlink_status(ec)) == true, "");
}
- path TestCases[] = {StaticEnv::File, StaticEnv::Dir, StaticEnv::SymlinkToFile,
- StaticEnv::DNE};
+ path TestCases[] = {static_env.File, static_env.Dir, static_env.SymlinkToFile,
+ static_env.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 d01854c1e403..5b7d709d9aec 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -43,7 +42,8 @@ TEST_CASE(test_copy_end_iterator)
TEST_CASE(test_copy_valid_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.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 8d3324079105..920ded9523da 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -36,7 +35,8 @@ TEST_CASE(test_assignment_signature)
TEST_CASE(test_copy_to_end_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
const directory_iterator from(testDir);
TEST_REQUIRE(from != directory_iterator{});
@@ -52,7 +52,8 @@ TEST_CASE(test_copy_to_end_iterator)
TEST_CASE(test_copy_from_end_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
const directory_iterator from{};
@@ -66,7 +67,8 @@ TEST_CASE(test_copy_from_end_iterator)
TEST_CASE(test_copy_valid_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.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 a06c4a64c7ff..206e7860f487 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -60,11 +59,12 @@ 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[] = { StaticEnv::DNE, StaticEnv::BadSymlink };
+ const path testPaths[] = { static_env.DNE, static_env.BadSymlink };
for (path const& testPath : testPaths)
{
{
@@ -169,9 +169,10 @@ TEST_CASE(test_open_on_empty_directory_equals_end)
TEST_CASE(test_open_on_directory_succeeds)
{
- const path testDir = StaticEnv::Dir;
- std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
- std::end( StaticEnv::DirIterationList));
+ 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 directory_iterator endIt{};
{
@@ -190,7 +191,8 @@ TEST_CASE(test_open_on_directory_succeeds)
TEST_CASE(test_open_on_file_fails)
{
- const path testFile = StaticEnv::File;
+ static_test_env static_env;
+ const path testFile = static_env.File;
const directory_iterator endIt{};
{
std::error_code ec;
@@ -225,9 +227,10 @@ TEST_CASE(test_open_on_dot_dir)
TEST_CASE(test_open_on_symlink)
{
- const path symlinkToDir = StaticEnv::SymlinkToDir;
+ static_test_env static_env;
+ const path symlinkToDir = static_env.SymlinkToDir;
std::set<path> dir_contents;
- for (path const& p : StaticEnv::DirIterationList) {
+ for (path const& p : static_env.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 c527013237ac..f1f9a27a45f0 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -44,9 +43,10 @@ TEST_CASE(test_increment_signatures)
TEST_CASE(test_prefix_increment)
{
- const path testDir = StaticEnv::Dir;
- const std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
- std::end( StaticEnv::DirIterationList));
+ 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 directory_iterator endIt{};
std::error_code ec;
@@ -67,9 +67,10 @@ TEST_CASE(test_prefix_increment)
TEST_CASE(test_postfix_increment)
{
- const path testDir = StaticEnv::Dir;
- const std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
- std::end( StaticEnv::DirIterationList));
+ 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 directory_iterator endIt{};
std::error_code ec;
@@ -91,9 +92,10 @@ TEST_CASE(test_postfix_increment)
TEST_CASE(test_increment_method)
{
- const path testDir = StaticEnv::Dir;
- const std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
- std::end( StaticEnv::DirIterationList));
+ 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 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 c4d0e23b46f8..8b17383fe6c1 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -46,7 +45,8 @@ TEST_CASE(test_move_end_iterator)
TEST_CASE(test_move_valid_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.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 bf737146d585..93fa67b4230e 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -42,7 +41,8 @@ TEST_CASE(test_assignment_signature)
TEST_CASE(test_move_to_end_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
directory_iterator from(testDir);
TEST_REQUIRE(from != directory_iterator{});
@@ -57,7 +57,8 @@ TEST_CASE(test_move_to_end_iterator)
TEST_CASE(test_move_from_end_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
directory_iterator from{};
@@ -71,7 +72,8 @@ TEST_CASE(test_move_from_end_iterator)
TEST_CASE(test_move_valid_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
const directory_iterator endIt{};
directory_iterator it(testDir);
@@ -101,9 +103,10 @@ 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(StaticEnv::Dir);
- directory_iterator it2(StaticEnv::Dir);
+ directory_iterator it(static_env.Dir);
+ directory_iterator it2(static_env.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 5b1205edc6db..c80458eeab8b 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -43,9 +42,10 @@ TEST_CASE(test_function_signatures)
TEST_CASE(test_ranged_for_loop)
{
- const path testDir = StaticEnv::Dir;
- std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
- std::end( StaticEnv::DirIterationList));
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
+ std::set<path> dir_contents(static_env.DirIterationList.begin(),
+ static_env.DirIterationList.end());
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 bff2a18dd70a..09a53e46e263 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -44,7 +43,8 @@ TEST_CASE(test_copy_end_iterator)
TEST_CASE(test_copy_valid_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.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 d7468a21c4ed..e03e9f3880b8 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -28,7 +27,7 @@ using namespace fs;
TEST_SUITE(recursive_directory_iterator_copy_assign_tests)
-recursive_directory_iterator createInterestingIterator()
+recursive_directory_iterator createInterestingIterator(const static_test_env &static_env)
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -36,7 +35,7 @@ recursive_directory_iterator createInterestingIterator()
// it.depth() == 1
// it.recursion_pending() == true
{
- const path testDir = StaticEnv::Dir;
+ const path testDir = static_env.Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::skip_permission_denied);
@@ -51,7 +50,7 @@ recursive_directory_iterator createInterestingIterator()
}
-recursive_directory_iterator createDifferentInterestingIterator()
+recursive_directory_iterator createDifferentInterestingIterator(const static_test_env &static_env)
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -59,7 +58,7 @@ recursive_directory_iterator createDifferentInterestingIterator()
// it.depth() == 2
// it.recursion_pending() == false
{
- const path testDir = StaticEnv::Dir;
+ const path testDir = static_env.Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::follow_directory_symlink);
@@ -79,9 +78,10 @@ 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();
+ const recursive_directory_iterator from = createInterestingIterator(static_env);
const path entry = *from;
recursive_directory_iterator to;
@@ -96,8 +96,9 @@ 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();
+ recursive_directory_iterator to = createInterestingIterator(static_env);
to = from;
TEST_REQUIRE(to == from);
@@ -106,12 +107,13 @@ 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();
+ const recursive_directory_iterator it = createInterestingIterator(static_env);
const path entry = *it;
- recursive_directory_iterator it2 = createDifferentInterestingIterator();
+ recursive_directory_iterator it2 = createDifferentInterestingIterator(static_env);
TEST_REQUIRE(it2 != it);
TEST_CHECK(it2.options() != it.options());
TEST_CHECK(it2.depth() != it.depth());
@@ -136,9 +138,10 @@ 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();
- recursive_directory_iterator it2 = createInterestingIterator();
+ recursive_directory_iterator it = createInterestingIterator(static_env);
+ recursive_directory_iterator it2 = createInterestingIterator(static_env);
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 177edb46e058..40f89df4e81a 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -61,11 +60,12 @@ 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[] = { StaticEnv::DNE, StaticEnv::BadSymlink };
+ const path testPaths[] = { static_env.DNE, static_env.BadSymlink };
for (path const& testPath : testPaths)
{
{
@@ -171,9 +171,10 @@ TEST_CASE(test_open_on_empty_directory_equals_end)
TEST_CASE(test_open_on_directory_succeeds)
{
- const path testDir = StaticEnv::Dir;
- std::set<path> dir_contents(std::begin(StaticEnv::DirIterationList),
- std::end( StaticEnv::DirIterationList));
+ 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 RDI endIt{};
{
@@ -192,7 +193,8 @@ TEST_CASE(test_open_on_directory_succeeds)
TEST_CASE(test_open_on_file_fails)
{
- const path testFile = StaticEnv::File;
+ static_test_env static_env;
+ const path testFile = static_env.File;
const RDI endIt{};
{
std::error_code ec;
@@ -207,8 +209,9 @@ TEST_CASE(test_open_on_file_fails)
TEST_CASE(test_options_post_conditions)
{
- const path goodDir = StaticEnv::Dir;
- const path badDir = StaticEnv::DNE;
+ static_test_env static_env;
+ const path goodDir = static_env.Dir;
+ const path badDir = static_env.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 da6c10a88cc9..bd12ec888566 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -30,9 +29,10 @@ TEST_SUITE(recursive_directory_iterator_depth_tests)
TEST_CASE(test_depth)
{
- const path testDir = StaticEnv::Dir;
- const path DirDepth1 = StaticEnv::Dir2;
- const path DirDepth2 = StaticEnv::Dir3;
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
+ const path DirDepth1 = static_env.Dir2;
+ const path DirDepth2 = static_env.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 5d29b7e32f60..568563984dd4 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -32,7 +31,8 @@ TEST_SUITE(recursive_directory_iterator_disable_recursion_pending_tests)
// in the 'recursion_pending()' tests.
TEST_CASE(basic_test)
{
- recursive_directory_iterator it(StaticEnv::Dir);
+ static_test_env static_env;
+ recursive_directory_iterator it(static_env.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 1c7650543396..3c0127e2a318 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -43,9 +42,10 @@ TEST_CASE(test_increment_signatures)
TEST_CASE(test_prefix_increment)
{
- const path testDir = StaticEnv::Dir;
- const std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
- std::end( StaticEnv::RecDirIterationList));
+ 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 recursive_directory_iterator endIt{};
std::error_code ec;
@@ -66,9 +66,10 @@ TEST_CASE(test_prefix_increment)
TEST_CASE(test_postfix_increment)
{
- const path testDir = StaticEnv::Dir;
- const std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
- std::end( StaticEnv::RecDirIterationList));
+ 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 recursive_directory_iterator endIt{};
std::error_code ec;
@@ -89,9 +90,10 @@ TEST_CASE(test_postfix_increment)
TEST_CASE(test_increment_method)
{
- const path testDir = StaticEnv::Dir;
- const std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
- std::end( StaticEnv::RecDirIterationList));
+ 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 recursive_directory_iterator endIt{};
std::error_code ec;
@@ -113,10 +115,11 @@ TEST_CASE(test_increment_method)
TEST_CASE(test_follow_symlinks)
{
- const path testDir = StaticEnv::Dir;
- auto const& IterList = StaticEnv::RecDirFollowSymlinksIterationList;
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
+ auto const& IterList = static_env.RecDirFollowSymlinksIterationList;
- const std::set<path> dir_contents(std::begin(IterList), std::end(IterList));
+ const std::set<path> dir_contents(IterList.begin(), IterList.end());
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 d709012bef8c..a944478284e6 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -46,7 +45,8 @@ TEST_CASE(test_move_end_iterator)
TEST_CASE(test_move_valid_iterator)
{
- const path testDir = StaticEnv::Dir;
+ static_test_env static_env;
+ const path testDir = static_env.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 2dee77c71731..3dc2bb758b89 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -34,7 +33,7 @@ using namespace fs;
TEST_SUITE(recursive_directory_iterator_move_assign_tests)
-recursive_directory_iterator createInterestingIterator()
+recursive_directory_iterator createInterestingIterator(const static_test_env &static_env)
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -42,7 +41,7 @@ recursive_directory_iterator createInterestingIterator()
// it.depth() == 1
// it.recursion_pending() == true
{
- const path testDir = StaticEnv::Dir;
+ const path testDir = static_env.Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::skip_permission_denied);
@@ -56,7 +55,7 @@ recursive_directory_iterator createInterestingIterator()
return it;
}
-recursive_directory_iterator createDifferentInterestingIterator()
+recursive_directory_iterator createDifferentInterestingIterator(const static_test_env &static_env)
// Create an "interesting" iterator where all fields are
// in a non-default state. The returned 'it' is in a
// state such that:
@@ -64,7 +63,7 @@ recursive_directory_iterator createDifferentInterestingIterator()
// it.depth() == 2
// it.recursion_pending() == false
{
- const path testDir = StaticEnv::Dir;
+ const path testDir = static_env.Dir;
const recursive_directory_iterator endIt;
recursive_directory_iterator it(testDir,
directory_options::follow_directory_symlink);
@@ -87,9 +86,10 @@ 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();
+ recursive_directory_iterator from = createInterestingIterator(static_env);
const recursive_directory_iterator from_copy(from);
const path entry = *from;
@@ -106,8 +106,9 @@ 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();
+ recursive_directory_iterator to = createInterestingIterator(static_env);
to = std::move(from);
TEST_REQUIRE(to == from);
@@ -116,13 +117,14 @@ 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();
+ recursive_directory_iterator it = createInterestingIterator(static_env);
const recursive_directory_iterator it_copy(it);
const path entry = *it;
- recursive_directory_iterator it2 = createDifferentInterestingIterator();
+ recursive_directory_iterator it2 = createDifferentInterestingIterator(static_env);
const recursive_directory_iterator it2_copy(it2);
TEST_REQUIRE(it2 != it);
TEST_CHECK(it2.options() != it.options());
@@ -149,9 +151,10 @@ 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();
- recursive_directory_iterator it2 = createInterestingIterator();
+ recursive_directory_iterator it = createInterestingIterator(static_env);
+ recursive_directory_iterator it2 = createInterestingIterator(static_env);
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 c6ecdae56db3..2d4edc97c549 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -40,16 +39,17 @@ 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 = StaticEnv::DirIterationList;
- std::set<path> notSeenDepth0(std::begin(DE0), std::end(DE0));
+ auto& DE0 = static_env.DirIterationList;
+ std::set<path> notSeenDepth0(DE0.begin(), DE0.end());
- auto& DE1 = StaticEnv::DirIterationListDepth1;
- std::set<path> notSeenDepth1(std::begin(DE1), std::end(DE1));
+ auto& DE1 = static_env.DirIterationListDepth1;
+ std::set<path> notSeenDepth1(DE1.begin(), DE1.end());
std::error_code ec;
- recursive_directory_iterator it(StaticEnv::Dir, ec);
+ recursive_directory_iterator it(static_env.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 6bb7b939554a..731766e262b3 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -30,14 +29,16 @@ TEST_SUITE(recursive_directory_iterator_recursion_pending_tests)
TEST_CASE(initial_value_test)
{
- recursive_directory_iterator it(StaticEnv::Dir);
+ static_test_env static_env;
+ recursive_directory_iterator it(static_env.Dir);
TEST_REQUIRE(it.recursion_pending() == true);
}
TEST_CASE(value_after_copy_construction_and_assignment_test)
{
- recursive_directory_iterator rec_pending_it(StaticEnv::Dir);
- recursive_directory_iterator no_rec_pending_it(StaticEnv::Dir);
+ static_test_env static_env;
+ recursive_directory_iterator rec_pending_it(static_env.Dir);
+ recursive_directory_iterator no_rec_pending_it(static_env.Dir);
no_rec_pending_it.disable_recursion_pending();
{ // copy construction
@@ -50,14 +51,14 @@ TEST_CASE(value_after_copy_construction_and_assignment_test)
TEST_CHECK(it2.recursion_pending() == false);
}
{ // copy assignment
- recursive_directory_iterator it(StaticEnv::Dir);
+ recursive_directory_iterator it(static_env.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(StaticEnv::Dir);
+ recursive_directory_iterator it2(static_env.Dir);
it2 = no_rec_pending_it;
TEST_CHECK(it2.recursion_pending() == false);
}
@@ -68,8 +69,9 @@ TEST_CASE(value_after_copy_construction_and_assignment_test)
TEST_CASE(value_after_move_construction_and_assignment_test)
{
- recursive_directory_iterator rec_pending_it(StaticEnv::Dir);
- recursive_directory_iterator no_rec_pending_it(StaticEnv::Dir);
+ static_test_env static_env;
+ recursive_directory_iterator rec_pending_it(static_env.Dir);
+ recursive_directory_iterator no_rec_pending_it(static_env.Dir);
no_rec_pending_it.disable_recursion_pending();
{ // move construction
@@ -82,13 +84,13 @@ TEST_CASE(value_after_move_construction_and_assignment_test)
TEST_CHECK(it2.recursion_pending() == false);
}
{ // copy assignment
- recursive_directory_iterator it(StaticEnv::Dir);
+ recursive_directory_iterator it(static_env.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(StaticEnv::Dir);
+ recursive_directory_iterator it2(static_env.Dir);
recursive_directory_iterator it_cp2(no_rec_pending_it);
it2 = std::move(it_cp2);
TEST_CHECK(it2.recursion_pending() == false);
@@ -99,9 +101,10 @@ 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(StaticEnv::Dir);
+ recursive_directory_iterator it(static_env.Dir);
it.disable_recursion_pending();
TEST_CHECK(it.recursion_pending() == false);
++it;
@@ -109,7 +112,7 @@ TEST_CASE(increment_resets_value)
TEST_CHECK(it.depth() == 0);
}
{
- recursive_directory_iterator it(StaticEnv::Dir);
+ recursive_directory_iterator it(static_env.Dir);
it.disable_recursion_pending();
TEST_CHECK(it.recursion_pending() == false);
it++;
@@ -117,7 +120,7 @@ TEST_CASE(increment_resets_value)
TEST_CHECK(it.depth() == 0);
}
{
- recursive_directory_iterator it(StaticEnv::Dir);
+ recursive_directory_iterator it(static_env.Dir);
it.disable_recursion_pending();
TEST_CHECK(it.recursion_pending() == false);
std::error_code ec;
@@ -129,12 +132,13 @@ TEST_CASE(increment_resets_value)
TEST_CASE(pop_does_not_reset_value)
{
+ static_test_env static_env;
const recursive_directory_iterator endIt;
- auto& DE0 = StaticEnv::DirIterationList;
- std::set<path> notSeenDepth0(std::begin(DE0), std::end(DE0));
+ auto& DE0 = static_env.DirIterationList;
+ std::set<path> notSeenDepth0(DE0.begin(), DE0.end());
- recursive_directory_iterator it(StaticEnv::Dir);
+ recursive_directory_iterator it(static_env.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 24eaf84c2931..1a076f3a3ed5 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -43,9 +42,10 @@ TEST_CASE(test_function_signatures)
TEST_CASE(test_ranged_for_loop)
{
- const path testDir = StaticEnv::Dir;
- std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList),
- std::end( StaticEnv::RecDirIterationList));
+ static_test_env static_env;
+ const path testDir = static_env.Dir;
+ std::set<path> dir_contents(static_env.RecDirIterationList.begin(),
+ static_env.RecDirIterationList.end());
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 de2fa54aca48..bc3f581b828e 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -24,15 +23,6 @@
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)
@@ -47,29 +37,32 @@ 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 = StaticEnv::Root;
+ const path Root = static_env.Root;
const path RootName = Root.filename();
- const path DirName = StaticEnv::Dir.filename();
- const path SymlinkName = StaticEnv::SymlinkToFile.filename();
+ const path DirName = static_env.Dir.filename();
+ const path SymlinkName = static_env.SymlinkToFile.filename();
struct TestCase {
path p;
path expect;
path base;
- TestCase(path p1, path e, path b = StaticEnv::Root)
+ TestCase(path p1, path e, path b)
: p(p1), expect(e), base(b) {}
};
const TestCase testCases[] = {
- { ".", 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}
+ { ".", 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}
};
for (auto& TC : testCases) {
std::error_code ec = GetTestEC();
@@ -85,21 +78,23 @@ TEST_CASE(test_canonical)
TEST_CASE(test_dne_path)
{
+ static_test_env static_env;
std::error_code ec = GetTestEC();
{
- const path ret = canonical(StaticEnv::DNE, ec);
+ const path ret = canonical(static_env.DNE, ec);
TEST_CHECK(ec != GetTestEC());
TEST_REQUIRE(ec);
TEST_CHECK(ret == path{});
}
{
- TEST_CHECK_THROW(filesystem_error, canonical(StaticEnv::DNE));
+ TEST_CHECK_THROW(filesystem_error, canonical(static_env.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 {
@@ -110,13 +105,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(StaticEnv::Dir);
+ fs::current_path(static_env.Dir);
try {
canonical(p);
TEST_REQUIRE(false);
} catch (filesystem_error const& err) {
TEST_CHECK(err.path1() == p);
- LIBCPP_ONLY(TEST_CHECK(err.path2() == StaticEnv::Dir));
+ LIBCPP_ONLY(TEST_CHECK(err.path2() == static_env.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 82565433e310..5ffbe1a51c15 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,6 +63,7 @@ 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");
@@ -74,7 +75,7 @@ TEST_CASE(test_error_reporting)
// !exists(f)
{
std::error_code ec = test_ec;
- const path f = StaticEnv::DNE;
+ const path f = static_env.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 cae78c2f5614..f5ca9023d96b 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -52,14 +51,18 @@ TEST_CASE(current_path_test)
TEST_CASE(current_path_after_change_test)
{
- const path new_path = StaticEnv::Dir;
+ CWDGuard guard;
+ static_test_env static_env;
+ const path new_path = static_env.Dir;
current_path(new_path);
TEST_CHECK(current_path() == new_path);
}
TEST_CASE(current_path_is_file_test)
{
- const path p = StaticEnv::File;
+ CWDGuard guard;
+ static_test_env static_env;
+ const path p = static_env.File;
std::error_code ec;
const path old_p = current_path();
current_path(p, ec);
@@ -69,14 +72,16 @@ TEST_CASE(current_path_is_file_test)
TEST_CASE(set_to_non_absolute_path)
{
- const path base = StaticEnv::Dir;
+ CWDGuard guard;
+ static_test_env static_env;
+ const path base = static_env.Dir;
current_path(base);
- const path p = StaticEnv::Dir2.filename();
+ const path p = static_env.Dir2.filename();
std::error_code ec;
current_path(p, ec);
TEST_CHECK(!ec);
const path new_cwd = current_path();
- TEST_CHECK(new_cwd == StaticEnv::Dir2);
+ TEST_CHECK(new_cwd == static_env.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 71fce4726661..35f337d0b0a7 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -36,18 +35,19 @@ TEST_CASE(signature_test) {
}
TEST_CASE(equivalent_test) {
+ static_test_env static_env;
struct TestCase {
path lhs;
path rhs;
bool expect;
};
const TestCase testCases[] = {
- {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},
+ {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},
};
for (auto& TC : testCases) {
std::error_code ec;
@@ -57,8 +57,9 @@ TEST_CASE(equivalent_test) {
}
TEST_CASE(equivalent_reports_error_if_input_dne) {
- const path E = StaticEnv::File;
- const path DNE = StaticEnv::DNE;
+ static_test_env static_env;
+ const path E = static_env.File;
+ const path DNE = static_env.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 45270d4cd0ec..b51182b64b4f 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,7 +62,8 @@ TEST_CASE(exists_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 6f27a4cb5712..0573aa5470d2 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -38,7 +37,8 @@ TEST_CASE(signature_test)
TEST_CASE(file_size_empty_test)
{
- const path p = StaticEnv::EmptyFile;
+ static_test_env static_env;
+ const path p = static_env.EmptyFile;
TEST_CHECK(file_size(p) == 0);
std::error_code ec;
TEST_CHECK(file_size(p, ec) == 0);
@@ -55,21 +55,23 @@ TEST_CASE(file_size_non_empty)
TEST_CASE(symlink_test_case)
{
- const path p = StaticEnv::File;
- const path p2 = StaticEnv::SymlinkToFile;
+ static_test_env static_env;
+ const path p = static_env.File;
+ const path p2 = static_env.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[] = {
- {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},
+ {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},
{"", 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 96da42be0bc7..82ac57207171 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -38,13 +37,15 @@ TEST_CASE(signature_test)
TEST_CASE(hard_link_count_for_file)
{
- TEST_CHECK(hard_link_count(StaticEnv::File) == 1);
+ static_test_env static_env;
+ TEST_CHECK(hard_link_count(static_env.File) == 1);
std::error_code ec;
- TEST_CHECK(hard_link_count(StaticEnv::File, ec) == 1);
+ TEST_CHECK(hard_link_count(static_env.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;
@@ -56,20 +57,20 @@ TEST_CASE(hard_link_count_for_directory)
DirExpectAlt = 5; // . .. Dir2 file1 file2
Dir3Expect = 3; // . .. file5
#endif
- 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);
+ 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);
std::error_code ec;
- 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_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_CASE(hard_link_count_increments_test)
{
@@ -84,9 +85,10 @@ TEST_CASE(hard_link_count_increments_test)
TEST_CASE(hard_link_count_error_cases)
{
+ static_test_env static_env;
const path testCases[] = {
- StaticEnv::BadSymlink,
- StaticEnv::DNE
+ static_env.BadSymlink,
+ static_env.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 6cfbc340c44f..c584605d6381 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,7 +62,8 @@ TEST_CASE(is_block_file_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 12e66019b65c..90690a211e6b 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,7 +62,8 @@ TEST_CASE(is_character_file_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 35dd5d40f7b0..1059a648641e 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -63,15 +62,17 @@ TEST_CASE(is_directory_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.DNE;
TEST_CHECK(is_directory(p) == false);
}
TEST_CASE(static_env_test)
{
- TEST_CHECK(is_directory(StaticEnv::Dir));
- TEST_CHECK(is_directory(StaticEnv::SymlinkToDir));
- TEST_CHECK(!is_directory(StaticEnv::File));
+ 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_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 e3393240aa40..606cebbf437e 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -36,7 +35,8 @@ TEST_CASE(signature_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.DNE;
std::error_code ec;
TEST_CHECK(is_empty(p, ec) == false);
TEST_CHECK(ec);
@@ -45,8 +45,9 @@ TEST_CASE(test_exist_not_found)
TEST_CASE(test_is_empty_directory)
{
- TEST_CHECK(!is_empty(StaticEnv::Dir));
- TEST_CHECK(!is_empty(StaticEnv::SymlinkToDir));
+ static_test_env static_env;
+ TEST_CHECK(!is_empty(static_env.Dir));
+ TEST_CHECK(!is_empty(static_env.SymlinkToDir));
}
TEST_CASE(test_is_empty_directory_dynamic)
@@ -59,8 +60,9 @@ TEST_CASE(test_is_empty_directory_dynamic)
TEST_CASE(test_is_empty_file)
{
- TEST_CHECK(is_empty(StaticEnv::EmptyFile));
- TEST_CHECK(!is_empty(StaticEnv::NonEmptyFile));
+ static_test_env static_env;
+ TEST_CHECK(is_empty(static_env.EmptyFile));
+ TEST_CHECK(!is_empty(static_env.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 4dcf04390364..1488a8916530 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,7 +62,8 @@ TEST_CASE(is_fifo_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 894cc57aeba2..1381eb5ae6e4 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,7 +62,8 @@ TEST_CASE(is_other_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 3fcf779b3213..5c5e1ea07c75 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,7 +62,8 @@ TEST_CASE(is_regular_file_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 ba727d6384c4..3f35c50f6011 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,7 +62,8 @@ TEST_CASE(is_socket_status_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 75ab6059f4d8..14da9cb7fa95 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -63,16 +62,17 @@ 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[] = {
- {StaticEnv::File, false},
- {StaticEnv::Dir, false},
- {StaticEnv::SymlinkToFile, true},
- {StaticEnv::SymlinkToDir, true},
- {StaticEnv::BadSymlink, true}
+ {static_env.File, false},
+ {static_env.Dir, false},
+ {static_env.SymlinkToFile, true},
+ {static_env.SymlinkToDir, true},
+ {static_env.BadSymlink, true}
};
for (auto& TC : testCases) {
TEST_CHECK(is_symlink(TC.p) == TC.expect);
@@ -81,7 +81,8 @@ TEST_CASE(static_env_test)
TEST_CASE(test_exist_not_found)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 3ef4c53303ad..e71da60a65e9 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -350,27 +349,28 @@ 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(StaticEnv::File);
+ file_time_type ret = last_write_time(static_env.File);
TEST_CHECK(ret != min);
TEST_CHECK(ret < C::now());
- TEST_CHECK(CompareTime(ret, LastWriteTime(StaticEnv::File)));
+ TEST_CHECK(CompareTime(ret, LastWriteTime(static_env.File)));
- file_time_type ret2 = last_write_time(StaticEnv::SymlinkToFile);
+ file_time_type ret2 = last_write_time(static_env.SymlinkToFile);
TEST_CHECK(CompareTime(ret, ret2));
- TEST_CHECK(CompareTime(ret2, LastWriteTime(StaticEnv::SymlinkToFile)));
+ TEST_CHECK(CompareTime(ret2, LastWriteTime(static_env.SymlinkToFile)));
}
{
- file_time_type ret = last_write_time(StaticEnv::Dir);
+ file_time_type ret = last_write_time(static_env.Dir);
TEST_CHECK(ret != min);
TEST_CHECK(ret < C::now());
- TEST_CHECK(CompareTime(ret, LastWriteTime(StaticEnv::Dir)));
+ TEST_CHECK(CompareTime(ret, LastWriteTime(static_env.Dir)));
- file_time_type ret2 = last_write_time(StaticEnv::SymlinkToDir);
+ file_time_type ret2 = last_write_time(static_env.SymlinkToDir);
TEST_CHECK(CompareTime(ret, ret2));
- TEST_CHECK(CompareTime(ret2, LastWriteTime(StaticEnv::SymlinkToDir)));
+ TEST_CHECK(CompareTime(ret2, LastWriteTime(static_env.SymlinkToDir)));
}
}
@@ -564,7 +564,8 @@ TEST_CASE(test_write_max_time) {
TEST_CASE(test_value_on_failure)
{
- const path p = StaticEnv::DNE;
+ static_test_env static_env;
+ const path p = static_env.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 2a8d8296c861..ffe2b3890f0f 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -42,77 +41,89 @@ TEST_CASE(test_signature_1) {
}
TEST_CASE(test_signature_2) {
- fs::path p(StaticEnv::File);
+ static_test_env static_env;
+ fs::path p(static_env.File);
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::File));
+ TEST_CHECK(output == std::string(static_env.File));
}
TEST_CASE(test_signature_3) {
- fs::path p(StaticEnv::Dir);
+ static_test_env static_env;
+ fs::path p(static_env.Dir);
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir));
+ TEST_CHECK(output == std::string(static_env.Dir));
}
TEST_CASE(test_signature_4) {
- fs::path p(StaticEnv::SymlinkToDir);
+ static_test_env static_env;
+ fs::path p(static_env.SymlinkToDir);
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir));
+ TEST_CHECK(output == std::string(static_env.Dir));
}
TEST_CASE(test_signature_5) {
- fs::path p(StaticEnv::SymlinkToDir / "dir2/.");
+ static_test_env static_env;
+ fs::path p(static_env.SymlinkToDir / "dir2/.");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir / "dir2"));
+ TEST_CHECK(output == std::string(static_env.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(StaticEnv::SymlinkToDir / "dir2/./");
+ fs::path p(static_env.SymlinkToDir / "dir2/./");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir / "dir2"));
+ TEST_CHECK(output == std::string(static_env.Dir / "dir2"));
}
TEST_CASE(test_signature_7) {
- fs::path p(StaticEnv::SymlinkToDir / "dir2/DNE/./");
+ static_test_env static_env;
+ fs::path p(static_env.SymlinkToDir / "dir2/DNE/./");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir / "dir2/DNE/"));
+ TEST_CHECK(output == std::string(static_env.Dir / "dir2/DNE/"));
}
TEST_CASE(test_signature_8) {
- fs::path p(StaticEnv::SymlinkToDir / "dir2");
+ static_test_env static_env;
+ fs::path p(static_env.SymlinkToDir / "dir2");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir2));
+ TEST_CHECK(output == std::string(static_env.Dir2));
}
TEST_CASE(test_signature_9) {
- fs::path p(StaticEnv::SymlinkToDir / "dir2/../dir2/DNE/..");
+ static_test_env static_env;
+ fs::path p(static_env.SymlinkToDir / "dir2/../dir2/DNE/..");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir2 / ""));
+ TEST_CHECK(output == std::string(static_env.Dir2 / ""));
}
TEST_CASE(test_signature_10) {
- fs::path p(StaticEnv::SymlinkToDir / "dir2/dir3/../DNE/DNE2");
+ static_test_env static_env;
+ fs::path p(static_env.SymlinkToDir / "dir2/dir3/../DNE/DNE2");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir2 / "DNE/DNE2"));
+ TEST_CHECK(output == std::string(static_env.Dir2 / "DNE/DNE2"));
}
TEST_CASE(test_signature_11) {
- fs::path p(StaticEnv::Dir / "../dir1");
+ static_test_env static_env;
+ fs::path p(static_env.Dir / "../dir1");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir));
+ TEST_CHECK(output == std::string(static_env.Dir));
}
TEST_CASE(test_signature_12) {
- fs::path p(StaticEnv::Dir / "./.");
+ static_test_env static_env;
+ fs::path p(static_env.Dir / "./.");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir));
+ TEST_CHECK(output == std::string(static_env.Dir));
}
TEST_CASE(test_signature_13) {
- fs::path p(StaticEnv::Dir / "DNE/../foo");
+ static_test_env static_env;
+ fs::path p(static_env.Dir / "DNE/../foo");
const fs::path output = fs::weakly_canonical(p);
- TEST_CHECK(output == std::string(StaticEnv::Dir / "foo"));
+ TEST_CHECK(output == std::string(static_env.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 4a0936b920db..6de0b10c6e54 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -45,6 +44,7 @@ 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[] = {
"",
- StaticEnv::DNE,
- StaticEnv::BadSymlink
+ static_env.DNE,
+ static_env.BadSymlink
};
for (auto& p : cases) {
const auto expect = static_cast<std::uintmax_t>(-1);
@@ -80,11 +80,13 @@ 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(StaticEnv::Dir.c_str(), &expect) != -1);
+ TEST_REQUIRE(::statvfs(static_env.Dir.c_str(), &expect) != -1);
TEST_CHECK(expect.f_bavail > 0);
TEST_CHECK(expect.f_bfree > 0);
TEST_CHECK(expect.f_bsize > 0);
@@ -106,11 +108,11 @@ TEST_CASE(basic_space_test)
// Currently 5% of capacity
const std::uintmax_t delta = expect_capacity / 20;
const path cases[] = {
- StaticEnv::File,
- StaticEnv::Dir,
- StaticEnv::Dir2,
- StaticEnv::SymlinkToFile,
- StaticEnv::SymlinkToDir
+ static_env.File,
+ static_env.Dir,
+ static_env.Dir2,
+ static_env.SymlinkToFile,
+ static_env.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 60c99ee923d5..af4ddb9c8906 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -34,11 +33,12 @@ 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[] {
- StaticEnv::DNE,
- StaticEnv::BadSymlink
+ static_env.DNE,
+ static_env.BadSymlink
};
for (auto& p : cases) {
std::error_code ec = std::make_error_code(std::errc::address_in_use);
@@ -103,17 +103,18 @@ 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[] = {
- {StaticEnv::File, file_type::regular},
- {StaticEnv::SymlinkToFile, file_type::regular},
- {StaticEnv::Dir, file_type::directory},
- {StaticEnv::SymlinkToDir, file_type::directory},
+ {static_env.File, file_type::regular},
+ {static_env.SymlinkToFile, file_type::regular},
+ {static_env.Dir, file_type::directory},
+ {static_env.SymlinkToDir, file_type::directory},
// Block files tested elsewhere
- {StaticEnv::CharFile, file_type::character},
+ {static_env.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 350076fcf370..e883739b7d5b 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -34,10 +33,11 @@ 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[] {
- StaticEnv::DNE
+ static_env.DNE
};
for (auto& p : cases) {
std::error_code ec = std::make_error_code(std::errc::address_in_use);
@@ -110,18 +110,19 @@ 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[] = {
- {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},
+ {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},
// Block files tested elsewhere
- {StaticEnv::CharFile, file_type::character},
+ {static_env.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 35d97b8703d5..c2c86bc35a6b 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,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// FILE_DEPENDENCIES: ../../Inputs/static_test_env
// UNSUPPORTED: c++98, c++03
// <filesystem>
@@ -27,6 +26,9 @@
int main(int, char**) {
+
+ static_test_env static_env;
+
// clang-format off
struct {
std::string input;
@@ -41,20 +43,20 @@ int main(int, char**) {
{"a/b", fs::current_path() / "a/b"},
{"a", fs::current_path() / "a"},
{"a/b/", fs::current_path() / "a/b/"},
- {StaticEnv::File, StaticEnv::File},
- {StaticEnv::Dir, StaticEnv::Dir},
- {StaticEnv::SymlinkToDir, StaticEnv::Dir},
- {StaticEnv::SymlinkToDir / "dir2/.", StaticEnv::Dir / "dir2"},
+ {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"},
// 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.
- {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"}
+ {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"}
};
// 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 8553317de76f..bd136d597949 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -3,7 +3,8 @@
#include "filesystem_include.h"
-#include <unistd.h> // for ftruncate
+#include <sys/stat.h> // for mkdir, mkfifo
+#include <unistd.h> // for ftruncate, link, symlink
#include <cassert>
#include <cstdio> // for printf
@@ -24,89 +25,6 @@
# 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)
@@ -207,17 +125,18 @@ struct scoped_test_env
std::string create_dir(std::string filename) {
filename = sanitize_path(std::move(filename));
- std::string cmd = "mkdir " + filename;
- int ret = std::system(cmd.c_str());
+ int ret = ::mkdir(filename.c_str(), 0777); // rwxrwxrwx mode
assert(ret == 0);
return filename;
}
- std::string create_symlink(std::string source, std::string to) {
- source = sanitize_path(std::move(source));
+ std::string create_symlink(std::string source,
+ std::string to,
+ bool sanitize_source = true) {
+ if (sanitize_source)
+ source = sanitize_path(std::move(source));
to = sanitize_path(std::move(to));
- std::string cmd = "ln -s " + source + ' ' + to;
- int ret = std::system(cmd.c_str());
+ int ret = ::symlink(source.c_str(), to.c_str());
assert(ret == 0);
return to;
}
@@ -225,16 +144,14 @@ 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));
- std::string cmd = "ln " + source + ' ' + to;
- int ret = std::system(cmd.c_str());
+ int ret = ::link(source.c_str(), to.c_str());
assert(ret == 0);
return to;
}
std::string create_fifo(std::string file) {
file = sanitize_path(std::move(file));
- std::string cmd = "mkfifo " + file;
- int ret = std::system(cmd.c_str());
+ int ret = ::mkfifo(file.c_str(), 0666); // rw-rw-rw- mode
assert(ret == 0);
return file;
}
@@ -276,6 +193,123 @@ 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