Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: tools/gn/filesystem_utils_unittest.cc

Issue 1672783002: Revert of [GN] Don't rewrite files with the same contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/filesystem_utils.cc ('k') | tools/gn/function_write_file.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/filesystem_utils_unittest.cc
diff --git a/tools/gn/filesystem_utils_unittest.cc b/tools/gn/filesystem_utils_unittest.cc
index e44d33797e8b5d7c5103a68439cea933b0c8fa5c..27ccab2ea4d0db453c217d1921db71729de58aac 100644
--- a/tools/gn/filesystem_utils_unittest.cc
+++ b/tools/gn/filesystem_utils_unittest.cc
@@ -3,11 +3,8 @@
// found in the LICENSE file.
#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_temp_dir.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/filesystem_utils.h"
@@ -557,59 +554,6 @@
#endif
}
-TEST(FilesystemUtils, ContentsEqual) {
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-
- std::string data = "foo";
-
- base::FilePath file_path = temp_dir.path().AppendASCII("foo.txt");
- base::WriteFile(file_path, data.c_str(), static_cast<int>(data.size()));
-
- EXPECT_TRUE(ContentsEqual(file_path, data));
-
- // Different length and contents.
- data += "bar";
- EXPECT_FALSE(ContentsEqual(file_path, data));
-
- // The same length, different contents.
- EXPECT_FALSE(ContentsEqual(file_path, "bar"));
-}
-
-TEST(FilesystemUtils, WriteFileIfChanged) {
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-
- std::string data = "foo";
-
- // Write if file doesn't exist. Create also directory.
- base::FilePath file_path =
- temp_dir.path().AppendASCII("bar").AppendASCII("foo.txt");
- EXPECT_TRUE(WriteFileIfChanged(file_path, data, nullptr));
-
- base::File::Info file_info;
- ASSERT_TRUE(base::GetFileInfo(file_path, &file_info));
- base::Time last_modified = file_info.last_modified;
-
-#if defined(OS_MACOSX)
- // Modification times are in seconds in HFS on Mac.
- base::TimeDelta sleep_time = base::TimeDelta::FromSeconds(1);
-#else
- base::TimeDelta sleep_time = base::TimeDelta::FromMilliseconds(1);
-#endif
- base::PlatformThread::Sleep(sleep_time);
-
- // Don't write if contents is the same.
- EXPECT_TRUE(WriteFileIfChanged(file_path, data, nullptr));
- ASSERT_TRUE(base::GetFileInfo(file_path, &file_info));
- EXPECT_EQ(last_modified, file_info.last_modified);
-
- // Write if contents changed.
- EXPECT_TRUE(WriteFileIfChanged(file_path, "bar", nullptr));
- ASSERT_TRUE(base::GetFileInfo(file_path, &file_info));
- EXPECT_NE(last_modified, file_info.last_modified);
-}
-
TEST(FilesystemUtils, GetToolchainDirs) {
BuildSettings build_settings;
build_settings.SetBuildDir(SourceDir("//out/Debug/"));
« no previous file with comments | « tools/gn/filesystem_utils.cc ('k') | tools/gn/function_write_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698