aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/cpp
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-01-23 15:14:03 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2017-01-23 15:16:17 +0000
commit50c13ce372a889422ec2efbcd68298f8fb6c66a8 (patch)
treed7c066436891f5fdd3acfacc253947169ed53886 /src/test/cpp
parenta4342784d67e2cdad2068d51dcf74cc856c89061 (diff)
*** Reason for rollback *** Breaks Bazel-Install-Trigger on CI. *** Original change description *** Bazel client, Windows: impl. ForEachDirectoryEntry Implement ForEachDirectoryEntry on Windows using FindFirstFileW / FindNextFileW. Supports long paths and traversing junctions. See https://github.com/bazelbuild/bazel/issues/2107 See https://github.com/bazelbuild/bazel/issues/2181 -- PiperOrigin-RevId: 145282158 MOS_MIGRATED_REVID=145282158
Diffstat (limited to 'src/test/cpp')
-rw-r--r--src/test/cpp/util/file_test.cc54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/test/cpp/util/file_test.cc b/src/test/cpp/util/file_test.cc
index 093841e20a..83bf3a9845 100644
--- a/src/test/cpp/util/file_test.cc
+++ b/src/test/cpp/util/file_test.cc
@@ -14,8 +14,6 @@
#include <stdio.h>
#include <string.h>
-#include <algorithm>
-#include <map>
#include <memory> // unique_ptr
#include <thread> // NOLINT (to silence Google-internal linter)
@@ -25,9 +23,7 @@
namespace blaze_util {
-using std::map;
using std::string;
-using std::vector;
TEST(FileTest, TestSingleThreadedPipe) {
std::unique_ptr<IPipe> pipe(CreatePipe());
@@ -148,54 +144,4 @@ TEST(FileTest, TestMtimeHandling) {
ASSERT_FALSE(mtime.get()->GetIfInDistantFuture(file, &actual));
}
-class CollectingDirectoryEntryConsumer : public DirectoryEntryConsumer {
- public:
- void Consume(const std::string& name, bool is_directory) override {
- // use just base name for easy comparison and no hassle with path separators
- // for Windows' sake (test runs on every platform)
- entries[Basename(name)] = is_directory;
- }
-
- map<string, bool> entries;
-};
-
-TEST(FileTest, ForEachDirectoryEntryTest) {
- string rootdir(JoinPath(getenv("TEST_TMPDIR"), "foo"));
- string file1(JoinPath(rootdir, "file1.txt"));
- string file2(JoinPath(rootdir, "file2.txt"));
- string subdir(JoinPath(rootdir, "dir1"));
- string file3(JoinPath(subdir, "file3.txt"));
-
- ASSERT_TRUE(MakeDirectories(subdir, 0700));
- ASSERT_TRUE(WriteFile("hello", 5, file1));
- ASSERT_TRUE(WriteFile("hello", 5, file2));
- ASSERT_TRUE(WriteFile("hello", 5, file3));
-
- map<string, bool> expected;
- expected["file1.txt"] = false;
- expected["file2.txt"] = false;
- expected["dir1"] = true;
-
- CollectingDirectoryEntryConsumer consumer;
- ForEachDirectoryEntry(rootdir, &consumer);
- ASSERT_EQ(consumer.entries, expected);
-
- vector<string> actual2;
- GetAllFilesUnder(rootdir, &actual2);
- std::sort(actual2.begin(), actual2.end());
-
- vector<string> expected2;
- vector<string> unixstyle_actual;
- // normalize path separators for Windows' sake (test runs on every platform)
- for (auto i : actual2) {
- std::replace(i.begin(), i.end(), '\\', '/');
- unixstyle_actual.push_back(i);
- }
- for (auto i : {file3, file1, file2}) {
- std::replace(i.begin(), i.end(), '\\', '/');
- expected2.push_back(i);
- }
- ASSERT_EQ(unixstyle_actual, expected2);
-}
-
} // namespace blaze_util