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

Unified Diff: base/files/scoped_temp_dir.cc

Issue 2854323002: Make TestingProfile delete failures explicitly CHECK-fail.
Patch Set: TEMP: Deliberately crash tests on ~ScopedTempDir, to see logs. Created 3 years, 7 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 | « base/files/scoped_temp_dir.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/scoped_temp_dir.cc
diff --git a/base/files/scoped_temp_dir.cc b/base/files/scoped_temp_dir.cc
index 26815217c6b46f07ab9540c349df33d2a726c898..dcbf5301523d256e42f9028724278e758ff0cf59 100644
--- a/base/files/scoped_temp_dir.cc
+++ b/base/files/scoped_temp_dir.cc
@@ -13,8 +13,16 @@ ScopedTempDir::ScopedTempDir() {
}
ScopedTempDir::~ScopedTempDir() {
- if (!path_.empty() && !Delete())
- DLOG(WARNING) << "Could not delete temp dir in dtor.";
+ if (!path_.empty()) {
+ if (!Delete())
+ DLOG(WARNING) << "Could not delete temp dir in dtor.";
+ else
+ LOG(WARNING) << "Delete in ~ScopedTempDir succeeded";
+ } else {
+ LOG(WARNING) << "Not calling Delete in ~ScopedTempDir (path empty)";
+ }
+
+ CHECK(false) << "Deliberate crash.";
}
bool ScopedTempDir::CreateUniqueTempDir() {
@@ -58,13 +66,19 @@ bool ScopedTempDir::Set(const FilePath& path) {
}
bool ScopedTempDir::Delete() {
- if (path_.empty())
+ if (path_.empty()) {
+ LOG(WARNING) << "ScopedTempDir::Delete: Failing due to path being empty";
return false;
+ }
bool ret = base::DeleteFile(path_, true);
if (ret) {
// We only clear the path if deleted the directory.
+ LOG(WARNING)
+ << "ScopedTempDir::Delete: DeleteFile Succeeded; clearing path";
path_.clear();
+ } else {
+ LOG(WARNING) << "ScopedTempDir::Delete: DeleteFile Failed";
}
return ret;
@@ -81,8 +95,12 @@ const FilePath& ScopedTempDir::GetPath() const {
return path_;
}
+bool ScopedTempDir::IsEmpty() const {
+ return path_.empty();
+}
+
bool ScopedTempDir::IsValid() const {
- return !path_.empty() && DirectoryExists(path_);
+ return !IsEmpty() && DirectoryExists(path_);
}
} // namespace base
« no previous file with comments | « base/files/scoped_temp_dir.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698