servo: Merge #13107 - Tidy: Handle empty files (from UK992:tidy); r=Wafflespeanut

Fix index error ``list index out of range``, when file is empty.

r? @Wafflespeanut

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes

Source-Repo: https://github.com/servo/servo
Source-Revision: c3ce9f2c909cd75c8f424bcef4036d0e29476546
This commit is contained in:
UK992
2016-08-31 07:42:25 -05:00
parent 56fe4a1096
commit 182dcf7a3e
4 changed files with 8 additions and 1 deletions

View File

@@ -39,6 +39,11 @@ class CheckTidiness(unittest.TestCase):
self.assertEqual('no newline at EOF', errors.next()[2])
self.assertNoMoreErrors(errors)
def test_empty_file(self):
errors = tidy.collect_errors_for_files(iterFile('empty_file.rs'), [], [tidy.check_by_line], print_text=False)
self.assertEqual('file is empty', errors.next()[2])
self.assertNoMoreErrors(errors)
def test_long_line(self):
errors = tidy.collect_errors_for_files(iterFile('long_line.rs'), [], [tidy.check_by_line], print_text=False)
self.assertEqual('Line is longer than 120 characters', errors.next()[2])