aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy_tests/test_tidy.py
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2016-04-20 13:29:39 -0400
committerJosh Matthews <josh@joshmatthews.net>2016-04-20 13:29:39 -0400
commitc7d5a2b3114a55ef77fcc730a2327cf1aa0917ed (patch)
tree0b5fbf22b6ab35ed4e1641772b07ab3a8678b21c /python/tidy/servo_tidy_tests/test_tidy.py
parent8d988f20c12e0a5267e79650a90310951c66ca77 (diff)
downloadservo-c7d5a2b3114a55ef77fcc730a2327cf1aa0917ed.tar.gz
servo-c7d5a2b3114a55ef77fcc730a2327cf1aa0917ed.zip
Ensure that we aren't missing any errors in the tidy self-test.
Diffstat (limited to 'python/tidy/servo_tidy_tests/test_tidy.py')
-rw-r--r--python/tidy/servo_tidy_tests/test_tidy.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py
index 031e0873a56..69bb4ae4e46 100644
--- a/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/python/tidy/servo_tidy_tests/test_tidy.py
@@ -19,25 +19,34 @@ def iterFile(name):
class CheckTidiness(unittest.TestCase):
+ def assertNoMoreErrors(self, errors):
+ with self.assertRaises(StopIteration):
+ errors.next()
+
def test_spaces_correctnes(self):
errors = tidy.collect_errors_for_files(iterFile('wrong_space.rs'), [], [tidy.check_by_line])
self.assertEqual('trailing whitespace', errors.next()[2])
self.assertEqual('no newline at EOF', errors.next()[2])
self.assertEqual('tab on line', errors.next()[2])
self.assertEqual('CR on line', errors.next()[2])
+ self.assertEqual('no newline at EOF', 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])
self.assertEqual('Line is longer than 120 characters', errors.next()[2])
+ self.assertNoMoreErrors(errors)
def test_whatwg_link(self):
errors = tidy.collect_errors_for_files(iterFile('whatwg_link.rs'), [], [tidy.check_by_line])
self.assertTrue('link to WHATWG may break in the future, use this format instead:' in errors.next()[2])
self.assertTrue('links to WHATWG single-page url, change to multi page:' in errors.next()[2])
+ self.assertNoMoreErrors(errors)
def test_licence(self):
errors = tidy.collect_errors_for_files(iterFile('incorrect_license.rs'), [], [tidy.check_license])
self.assertEqual('incorrect license', errors.next()[2])
+ self.assertNoMoreErrors(errors)
def test_rust(self):
errors = tidy.collect_errors_for_files(iterFile('rust_tidy.rs'), [], [tidy.check_rust])
@@ -61,19 +70,23 @@ class CheckTidiness(unittest.TestCase):
self.assertEqual('extra space before :', errors.next()[2])
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
self.assertEqual('use &str instead of &String', errors.next()[2])
+ self.assertNoMoreErrors(errors)
def test_spec_link(self):
tidy.spec_base_path = base_path
errors = tidy.collect_errors_for_files(iterFile('speclink.rs'), [], [tidy.check_spec])
self.assertEqual('method declared in webidl is missing a comment with a specification link', errors.next()[2])
+ self.assertNoMoreErrors(errors)
def test_webidl(self):
errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [])
self.assertEqual('No specification link found.', errors.next()[2])
+ self.assertNoMoreErrors(errors)
def test_toml(self):
errors = tidy.collect_errors_for_files(iterFile('test.toml'), [tidy.check_toml], [])
self.assertEqual('found asterisk instead of minimum version number', errors.next()[2])
+ self.assertNoMoreErrors(errors)
def do_tests():