aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy_tests
diff options
context:
space:
mode:
Diffstat (limited to 'python/tidy/servo_tidy_tests')
-rw-r--r--python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py5
-rw-r--r--python/tidy/servo_tidy_tests/lints/no_lint.py5
-rw-r--r--python/tidy/servo_tidy_tests/lints/no_run.py5
-rw-r--r--python/tidy/servo_tidy_tests/lints/not_inherited.py2
-rw-r--r--python/tidy/servo_tidy_tests/lints/not_script0
-rw-r--r--python/tidy/servo_tidy_tests/lints/proper_file.py6
-rw-r--r--python/tidy/servo_tidy_tests/test_tidy.py30
7 files changed, 49 insertions, 4 deletions
diff --git a/python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py b/python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py
new file mode 100644
index 00000000000..4851cdf402c
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py
@@ -0,0 +1,5 @@
+from servo_tidy.tidy import LintRunner
+
+class Lint(LintRunner):
+ def run(self):
+ yield None
diff --git a/python/tidy/servo_tidy_tests/lints/no_lint.py b/python/tidy/servo_tidy_tests/lints/no_lint.py
new file mode 100644
index 00000000000..e9f84aa9f3c
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/lints/no_lint.py
@@ -0,0 +1,5 @@
+from servo_tidy.tidy import LintRunner
+
+class Linter(LintRunner):
+ def run(self):
+ pass
diff --git a/python/tidy/servo_tidy_tests/lints/no_run.py b/python/tidy/servo_tidy_tests/lints/no_run.py
new file mode 100644
index 00000000000..2acd5db1fee
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/lints/no_run.py
@@ -0,0 +1,5 @@
+from servo_tidy.tidy import LintRunner
+
+class Lint(LintRunner):
+ def some_method(self):
+ pass
diff --git a/python/tidy/servo_tidy_tests/lints/not_inherited.py b/python/tidy/servo_tidy_tests/lints/not_inherited.py
new file mode 100644
index 00000000000..fc38dff2c58
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/lints/not_inherited.py
@@ -0,0 +1,2 @@
+class Lint(object):
+ pass
diff --git a/python/tidy/servo_tidy_tests/lints/not_script b/python/tidy/servo_tidy_tests/lints/not_script
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/lints/not_script
diff --git a/python/tidy/servo_tidy_tests/lints/proper_file.py b/python/tidy/servo_tidy_tests/lints/proper_file.py
new file mode 100644
index 00000000000..acecb82abd4
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/lints/proper_file.py
@@ -0,0 +1,6 @@
+from servo_tidy.tidy import LintRunner
+
+class Lint(LintRunner):
+ def run(self):
+ for _ in [None]:
+ yield ('path', 0, 'foobar')
diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py
index 12d7b9ebae7..c6fe8bd83fa 100644
--- a/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/python/tidy/servo_tidy_tests/test_tidy.py
@@ -203,14 +203,36 @@ class CheckTidiness(unittest.TestCase):
self.assertEqual(msg, errors.next()[2])
self.assertNoMoreErrors(errors)
+ def test_lint_runner(self):
+ test_path = base_path + 'lints/'
+ runner = tidy.LintRunner(only_changed_files=False, progress=False)
+ runner.path = test_path + 'some-fictional-file'
+ self.assertEqual([(runner.path, 0, "file does not exist")], list(runner.check()))
+ runner.path = test_path + 'not_script'
+ self.assertEqual([(runner.path, 0, "lint should be a python script")],
+ list(runner.check()))
+ runner.path = test_path + 'not_inherited.py'
+ self.assertEqual([(runner.path, 1, "class 'Lint' should inherit from 'LintRunner'")],
+ list(runner.check()))
+ runner.path = test_path + 'no_lint.py'
+ self.assertEqual([(runner.path, 1, "script should contain a class named 'Lint'")],
+ list(runner.check()))
+ runner.path = test_path + 'no_run.py'
+ self.assertEqual([(runner.path, 0, "class 'Lint' should implement 'run' method")],
+ list(runner.check()))
+ runner.path = test_path + 'invalid_error_tuple.py'
+ self.assertEqual([(runner.path, 1, "errors should be a tuple of (path, line, reason)")],
+ list(runner.check()))
+ runner.path = test_path + 'proper_file.py'
+ self.assertEqual([('path', 0, "foobar")], list(runner.check()))
+
def test_file_list(self):
base_path='./python/tidy/servo_tidy_tests/test_ignored'
- file_list = tidy.get_file_list(base_path, only_changed_files=False,
- exclude_dirs=[])
+ file_list = tidy.FileList(base_path, only_changed_files=False, exclude_dirs=[])
lst = list(file_list)
self.assertEqual([os.path.join(base_path, 'whee', 'test.rs'), os.path.join(base_path, 'whee', 'foo', 'bar.rs')], lst)
- file_list = tidy.get_file_list(base_path, only_changed_files=False,
- exclude_dirs=[os.path.join(base_path, 'whee', 'foo')])
+ file_list = tidy.FileList(base_path, only_changed_files=False,
+ exclude_dirs=[os.path.join(base_path, 'whee', 'foo')])
lst = list(file_list)
self.assertEqual([os.path.join(base_path, 'whee', 'test.rs')], lst)