Ignore empty CONFIG_DIR for validators file (RIPD-1221)

This commit is contained in:
wilsonianb
2016-07-01 14:51:22 -07:00
committed by seelabs
parent e29163e922
commit b72724a4a4
2 changed files with 14 additions and 10 deletions

View File

@@ -440,7 +440,7 @@ void Config::loadFromString (std::string const& fileContents)
Throw<std::runtime_error> ( Throw<std::runtime_error> (
"Invalid path specified in [" SECTION_VALIDATORS_FILE "]"); "Invalid path specified in [" SECTION_VALIDATORS_FILE "]");
if (!validatorsFile.is_absolute()) if (!validatorsFile.is_absolute() && !CONFIG_DIR.empty())
validatorsFile = CONFIG_DIR / validatorsFile; validatorsFile = CONFIG_DIR / validatorsFile;
if (!boost::filesystem::exists (validatorsFile)) if (!boost::filesystem::exists (validatorsFile))
@@ -454,7 +454,7 @@ void Config::loadFromString (std::string const& fileContents)
"Invalid file specified in [" SECTION_VALIDATORS_FILE "]: " + "Invalid file specified in [" SECTION_VALIDATORS_FILE "]: " +
validatorsFile.string()); validatorsFile.string());
} }
else else if (!CONFIG_DIR.empty())
{ {
validatorsFile = CONFIG_DIR / validatorsFileName; validatorsFile = CONFIG_DIR / validatorsFileName;

View File

@@ -141,7 +141,7 @@ protected:
remove (toRm); remove (toRm);
else else
test_.log << "Expected " << toRm.string () test_.log << "Expected " << toRm.string ()
<< " to be an empty existing directory."; << " to be an empty existing directory." << std::endl;
}; };
public: public:
@@ -176,12 +176,13 @@ public:
if (rmSubDir_) if (rmSubDir_)
rmDir (subDir_); rmDir (subDir_);
else else
test_.log << "Skipping rm dir: " << subDir_.string (); test_.log << "Skipping rm dir: "
<< subDir_.string () << std::endl;
} }
catch (std::exception& e) catch (std::exception& e)
{ {
// if we throw here, just let it die. // if we throw here, just let it die.
test_.log << "Error in ~ConfigGuard: " << e.what (); test_.log << "Error in ~ConfigGuard: " << e.what () << std::endl;
}; };
} }
}; };
@@ -249,19 +250,21 @@ public:
using namespace boost::filesystem; using namespace boost::filesystem;
if (!boost::filesystem::exists (configFile_)) if (!boost::filesystem::exists (configFile_))
test_.log << "Expected " << configFile_.string () test_.log << "Expected " << configFile_.string ()
<< " to be an existing file."; << " to be an existing file." << std::endl;
else else
remove (configFile_.string ()); remove (configFile_.string ());
if (rmDataDir_) if (rmDataDir_)
rmDir (dataDir_); rmDir (dataDir_);
else else
test_.log << "Skipping rm dir: " << dataDir_.string (); test_.log << "Skipping rm dir: "
<< dataDir_.string () << std::endl;
} }
catch (std::exception& e) catch (std::exception& e)
{ {
// if we throw here, just let it die. // if we throw here, just let it die.
test_.log << "Error in ~RippledCfgGuard: " << e.what (); test_.log << "Error in ~RippledCfgGuard: "
<< e.what () << std::endl;
}; };
} }
}; };
@@ -337,14 +340,15 @@ public:
using namespace boost::filesystem; using namespace boost::filesystem;
if (!boost::filesystem::exists (validatorsFile_)) if (!boost::filesystem::exists (validatorsFile_))
test_.log << "Expected " << validatorsFile_.string () test_.log << "Expected " << validatorsFile_.string ()
<< " to be an existing file."; << " to be an existing file." << std::endl;
else else
remove (validatorsFile_.string ()); remove (validatorsFile_.string ());
} }
catch (std::exception& e) catch (std::exception& e)
{ {
// if we throw here, just let it die. // if we throw here, just let it die.
test_.log << "Error in ~ValidatorsTxtGuard: " << e.what (); test_.log << "Error in ~ValidatorsTxtGuard: "
<< e.what () << std::endl;
}; };
} }
}; };