summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-06-17 22:22:37 +0000
committerEric Fiselier <eric@efcs.ca>2016-06-17 22:22:37 +0000
commite32264a4c092588d395b80be339eaed3565d423d (patch)
treeee98186fca0f0dd0fb53ea510fa1176a914a4ac2 /libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
parent0114bb5aa0a5e5fbaddc7aeadac7a790737e9a0e (diff)
downloadbcm5719-llvm-e32264a4c092588d395b80be339eaed3565d423d.tar.gz
bcm5719-llvm-e32264a4c092588d395b80be339eaed3565d423d.zip
Fix bugs in recursive_directory_iterator implementation and tests.
There are two fixes in this patch: * Fix bug where the constructor of recursive_directory_iterator did not reset the error code if no failure occurred. * Fix tests were dependent on the iteration order of the test directories. llvm-svn: 273060
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp')
-rw-r--r--libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp b/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
index 833e6203430..5a3bdd9d482 100644
--- a/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
+++ b/libcxx/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
@@ -130,16 +130,33 @@ TEST_CASE(increment_resets_value)
TEST_CASE(pop_does_not_reset_value)
{
const recursive_directory_iterator endIt;
+
+ auto& DE0 = StaticEnv::DirIterationList;
+ std::set<path> notSeenDepth0(std::begin(DE0), std::end(DE0));
+
recursive_directory_iterator it(StaticEnv::Dir);
+ TEST_REQUIRE(it != endIt);
while (it.depth() == 0) {
+ notSeenDepth0.erase(it->path());
++it;
TEST_REQUIRE(it != endIt);
}
+ TEST_REQUIRE(it.depth() == 1);
it.disable_recursion_pending();
it.pop();
- TEST_REQUIRE(it != endIt);
- TEST_CHECK(it.recursion_pending() == false);
+ // Since the order of iteration is unspecified the pop() could result
+ // in the end iterator. When this is the case it is undefined behavior
+ // to call recursion_pending().
+ if (it == endIt) {
+ TEST_CHECK(notSeenDepth0.empty());
+#if defined(_LIBCPP_VERSION)
+ TEST_CHECK(it.recursion_pending() == false);
+#endif
+ } else {
+ TEST_CHECK(! notSeenDepth0.empty());
+ TEST_CHECK(it.recursion_pending() == false);
+ }
}
TEST_SUITE_END()
OpenPOWER on IntegriCloud