Adds more checks before deleting temporary files.

pull/66/merge
Feng Xiao 10 years ago
parent ad7f41bd57
commit baca1a8a1a
  1. 4
      src/google/protobuf/compiler/command_line_interface_unittest.cc
  2. 4
      src/google/protobuf/compiler/importer_unittest.cc
  3. 2
      src/google/protobuf/testing/file.cc

@ -252,7 +252,9 @@ void CommandLineInterfaceTest::SetUp() {
void CommandLineInterfaceTest::TearDown() { void CommandLineInterfaceTest::TearDown() {
// Delete the temp directory. // Delete the temp directory.
File::DeleteRecursively(temp_directory_, NULL, NULL); if (File::Exists(temp_directory_)) {
File::DeleteRecursively(temp_directory_, NULL, NULL);
}
// Delete all the MockCodeGenerators. // Delete all the MockCodeGenerators.
for (int i = 0; i < mock_generators_to_delete_.size(); i++) { for (int i = 0; i < mock_generators_to_delete_.size(); i++) {

@ -348,7 +348,9 @@ class DiskSourceTreeTest : public testing::Test {
virtual void TearDown() { virtual void TearDown() {
for (int i = 0; i < dirnames_.size(); i++) { for (int i = 0; i < dirnames_.size(); i++) {
File::DeleteRecursively(dirnames_[i], NULL, NULL); if (File::Exists(dirnames_[i])) {
File::DeleteRecursively(dirnames_[i], NULL, NULL);
}
} }
} }

@ -133,6 +133,8 @@ bool File::RecursivelyCreateDir(const string& path, int mode) {
void File::DeleteRecursively(const string& name, void File::DeleteRecursively(const string& name,
void* dummy1, void* dummy2) { void* dummy1, void* dummy2) {
if (name.empty()) return;
// We don't care too much about error checking here since this is only used // We don't care too much about error checking here since this is only used
// in tests to delete temporary directories that are under /tmp anyway. // in tests to delete temporary directories that are under /tmp anyway.

Loading…
Cancel
Save