TDB2: Made sure file exists before checking readability

This commit is contained in:
Paul Beckingham 2016-11-19 09:45:04 -05:00
parent 764ada3a17
commit 80ea2bb51d
2 changed files with 4 additions and 2 deletions

View file

@ -571,8 +571,8 @@ const std::string TF2::dump ()
label = rightJustify (_file._data.substr (slash + 1), 14);
// File mode.
std::string mode = std::string (_file.readable () ? "r" : "-") +
std::string (_file.writable () ? "w" : "-");
std::string mode = std::string (_file.exists () && _file.readable () ? "r" : "-") +
std::string (_file.exists () && _file.writable () ? "w" : "-");
if (mode == "r-") mode = red.colorize (mode);
else if (mode == "rw") mode = green.colorize (mode);
else mode = yellow.colorize (mode);

View file

@ -50,6 +50,8 @@ class TestDiagnostics(TestCase):
self.tap(out)
self.assertRegexpMatches(out, "Compliance:\s+C\+\+11")
self.assertRegexpMatches(out, "libgnutls:\s+\d+\.\d+\.\d+")
self.assertIn("edlin", out)
self.assertIn("strict", out)
if __name__ == "__main__":