diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 05:20:16 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 05:20:16 +0000 |
commit | 08ee1fafa30a5202a8b3c25b6b7a38acbe090298 (patch) | |
tree | aa10777adae04612c4972a229672068023782aa9 /chrome/test | |
parent | 94d98bfd8ceaafe67d6cd05c6d71d298927516a0 (diff) | |
download | chromium_src-08ee1fafa30a5202a8b3c25b6b7a38acbe090298.zip chromium_src-08ee1fafa30a5202a8b3c25b6b7a38acbe090298.tar.gz chromium_src-08ee1fafa30a5202a8b3c25b6b7a38acbe090298.tar.bz2 |
Create directory if the given gtest_output path is in an unexisting directory.
BUG=42781
TEST=Run one of out-of-process-tests (e.g. browser_tests) with --gtest_output=xml:unexisting_dir/output.xml parameter and see if the specified unexisting_dir is successfully created (if it's in a writable location).
Review URL: http://codereview.chromium.org/2302003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/test_launcher/test_runner.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/chrome/test/test_launcher/test_runner.cc b/chrome/test/test_launcher/test_runner.cc index 7bb9163..33c7586 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: " |