aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-06-24 11:15:27 +0200
committerMartin Robinson <mrobinson@igalia.com>2023-06-29 19:09:33 +0200
commitae9a9e1d17b57f6566db56a2e6f1cb9b9bec8d6a (patch)
tree57405e05887d599e9e8b3d4199578ff1b5a247c4 /python/tidy
parentedeed11cefba1524abbce55d398574c005b7687a (diff)
downloadservo-ae9a9e1d17b57f6566db56a2e6f1cb9b9bec8d6a.tar.gz
servo-ae9a9e1d17b57f6566db56a2e6f1cb9b9bec8d6a.zip
Combine all script tests into `test-scripts`
Remove: - tidy self test support from `./mach test` - `./mach test-idl` Adds a `./mach test-scripts` command that is responsible for running all Python script tests. Run this during the CI to catch regressions in changes to scripts. The WebIDL tests are still *very* slow and there are from Gecko, so only run them when "-a" is passed meaning all tests.
Diffstat (limited to 'python/tidy')
-rw-r--r--python/tidy/__init__.py2
-rw-r--r--python/tidy/test.py17
2 files changed, 11 insertions, 8 deletions
diff --git a/python/tidy/__init__.py b/python/tidy/__init__.py
index 74a15acad8f..4d834ec6d7a 100644
--- a/python/tidy/__init__.py
+++ b/python/tidy/__init__.py
@@ -8,4 +8,4 @@
# except according to those terms.
from .tidy import scan # noqa
-from .test import do_tests # noqa
+from .test import run_tests # noqa
diff --git a/python/tidy/test.py b/python/tidy/test.py
index 49c83579c93..e28549f2c3c 100644
--- a/python/tidy/test.py
+++ b/python/tidy/test.py
@@ -7,6 +7,7 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
+import logging
import os
import unittest
@@ -48,7 +49,7 @@ class CheckTidiness(unittest.TestCase):
os.path.join(BASE_PATH, "dir_check/webidl_plus"): ['webidl', 'test'],
os.path.join(BASE_PATH, "dir_check/only_webidl"): ['webidl']
}
- errors = tidy.check_directory_files(dirs)
+ errors = tidy.check_directory_files(dirs, print_text=False)
error_dir = os.path.join(BASE_PATH, "dir_check/webidl_plus")
self.assertEqual("Unexpected extension found for test.rs. We only expect files with webidl, test extensions in {0}".format(error_dir), next(errors)[2])
self.assertEqual("Unexpected extension found for test2.rs. We only expect files with webidl, test extensions in {0}".format(error_dir), next(errors)[2])
@@ -100,7 +101,7 @@ class CheckTidiness(unittest.TestCase):
self.assertNoMoreErrors(errors)
def test_apache2_incomplete(self):
- errors = tidy.collect_errors_for_files(iterFile('apache2_license.rs'), [], [tidy.check_license])
+ errors = tidy.collect_errors_for_files(iterFile('apache2_license.rs'), [], [tidy.check_license], print_text=False)
self.assertEqual('incorrect license', next(errors)[2])
def test_rust(self):
@@ -249,19 +250,21 @@ class CheckTidiness(unittest.TestCase):
def test_file_list(self):
file_path = os.path.join(BASE_PATH, 'test_ignored')
- file_list = tidy.FileList(file_path, only_changed_files=False, exclude_dirs=[])
+ file_list = tidy.FileList(file_path, only_changed_files=False, exclude_dirs=[], progress=False)
lst = list(file_list)
self.assertEqual([os.path.join(file_path, 'whee', 'test.rs'), os.path.join(file_path, 'whee', 'foo', 'bar.rs')], lst)
file_list = tidy.FileList(file_path, only_changed_files=False,
- exclude_dirs=[os.path.join(file_path, 'whee', 'foo')])
+ exclude_dirs=[os.path.join(file_path, 'whee', 'foo')],
+ progress=False)
lst = list(file_list)
self.assertEqual([os.path.join(file_path, 'whee', 'test.rs')], lst)
def test_multiline_string(self):
- errors = tidy.collect_errors_for_files(iterFile('multiline_string.rs'), [], [tidy.check_rust], print_text=True)
+ errors = tidy.collect_errors_for_files(iterFile('multiline_string.rs'), [], [tidy.check_rust], print_text=False)
self.assertNoMoreErrors(errors)
-def do_tests():
+def run_tests():
+ verbosity = 1 if logging.getLogger().level >= logging.WARN else 2
suite = unittest.TestLoader().loadTestsFromTestCase(CheckTidiness)
- return 0 if unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() else 1
+ return unittest.TextTestRunner(verbosity=verbosity).run(suite).wasSuccessful()