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

Unified Diff: chrome/test/test_launcher/test_runner.cc

Issue 2302003: Create directory if the given gtest_output path is in an unexisting directory. (Closed)
Patch Set: added 'creating the directory' warning Created 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/test_launcher/test_runner.cc
diff --git a/chrome/test/test_launcher/test_runner.cc b/chrome/test/test_launcher/test_runner.cc
index 7bb9163e314cb03650cdbb73b95c0840d5d4e5d1..33c758645cebf9033023454e22e519509957f85e 100644
--- a/chrome/test/test_launcher/test_runner.cc
+++ b/chrome/test/test_launcher/test_runner.cc
@@ -40,7 +40,7 @@ static const FilePath::CharType kDefaultOutputFile[] = FILE_PATH_LITERAL(
// detailed failure messages either.
class ResultsPrinter {
public:
- ResultsPrinter(const CommandLine& command_line);
+ explicit ResultsPrinter(const CommandLine& command_line);
~ResultsPrinter();
void OnTestCaseStart(const char* name, int test_count) const;
void OnTestCaseEnd() const;
@@ -71,6 +71,13 @@ ResultsPrinter::ResultsPrinter(const CommandLine& command_line) : out_(NULL) {
}
if (path.value().empty())
path = FilePath(kDefaultOutputFile);
+ FilePath dir_name = path.DirName();
+ if (!file_util::DirectoryExists(dir_name)) {
+ LOG(WARNING) << "The output directory does not exist. "
+ << "Creating the directory: " << dir_name.value() << std::endl;
+ // Create the directory if necessary (because the gtest does the same).
+ file_util::CreateDirectory(dir_name);
+ }
out_ = file_util::OpenFile(path, "w");
if (!out_) {
LOG(ERROR) << "Cannot open output file: "
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698