Update test for walk_path. It is CE now

GitOrigin-RevId: 850f17f25c3f1e8e3b63fc93936455883be35c4f
This commit is contained in:
Arseny Smirnov 2018-09-12 15:07:54 +03:00
parent f8568f0400
commit f72bcd230f
2 changed files with 6 additions and 5 deletions

View File

@ -41,7 +41,6 @@ static FileFd &get_file_fd() {
static FileFd result = FileFd::from_native_fd(NativeFd(handle, true));
#else
static FileFd result;
result = FileFd();
#endif
return result;
}

View File

@ -17,9 +17,7 @@ TEST(Port, files) {
CSlice main_dir = "test_dir";
rmrf(main_dir).ignore();
ASSERT_TRUE(FileFd::open(main_dir, FileFd::Write).is_error());
ASSERT_TRUE(walk_path(main_dir, [](CSlice name, bool is_directory) {
UNREACHABLE();
}).is_error());
ASSERT_TRUE(walk_path(main_dir, [](CSlice name, bool is_directory) { UNREACHABLE(); }).is_error());
mkdir(main_dir).ensure();
mkdir(PSLICE() << main_dir << TD_DIR_SLASH << "A").ensure();
mkdir(PSLICE() << main_dir << TD_DIR_SLASH << "B").ensure();
@ -37,11 +35,15 @@ TEST(Port, files) {
const int ITER_COUNT = 1000;
for (int i = 0; i < ITER_COUNT; i++) {
walk_path(main_dir,
[&](CSlice name, bool is_directory) {
[&, ptr = std::make_unique<int>(2)](CSlice name, bool is_directory) mutable {
ASSERT_EQ(2, *ptr);
if (!is_directory) {
ASSERT_TRUE(name == fd_path || name == fd2_path);
}
cnt++;
if (cnt == 7) {
ptr.reset();
}
})
.ensure();
}