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

Unified Diff: chrome/test/base/testing_profile.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.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/testing_profile.cc
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index c43d29fdee2dbfb04d59119c832b39124fcdedb7..3c8a43c4c868c6addf0faa182fa1ed734af640bb 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -566,7 +566,19 @@ TestingProfile::~TestingProfile() {
}
base::ThreadRestrictions::ScopedAllowIO allow_io;
- ignore_result(temp_dir_.Delete());
+ // Release the temp dir during the |allow_io| scope (otherwise the
+ // ScopedTempDir destructor will do it in a context where IO is not allowed).
+ // If Delete fails (other than in the valid case where the path is empty), the
+ // test will leave detritus, so fail the test.
+ if (!temp_dir_.IsEmpty()) {
+ if (!temp_dir_.Delete()) {
+ LOG(ERROR) << "CHECK(temp_dir_.Delete()) would fail!!!";
+ } else {
+ LOG(WARNING) << "Delete in ScopedAllowIO succeeded";
+ }
+ } else {
+ LOG(WARNING) << "Not calling Delete in ScopedAllowIO (path is empty)";
+ }
}
void TestingProfile::CreateFaviconService() {
« no previous file with comments | « base/files/scoped_temp_dir.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698