Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Unified Diff: Tools/Scripts/webkitpy/layout_tests/lint_test_expectations_unittest.py

Issue 267803007: Add checks for READMEs for each virtual test suite. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge to r175714 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Tools/Scripts/webkitpy/layout_tests/lint_test_expectations_unittest.py
diff --git a/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations_unittest.py b/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations_unittest.py
index 13187e3ece79a6ee9bb802720d49c8fb654dc986..1f7babfd67e733ef747d644d1a0431e5b508ffca 100644
--- a/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations_unittest.py
+++ b/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations_unittest.py
@@ -72,7 +72,7 @@ class FakeFactory(object):
for port in ports:
self.ports[port.name] = port
- def get(self, port_name, *args, **kwargs): # pylint: disable=W0613,E0202
+ def get(self, port_name='a', *args, **kwargs): # pylint: disable=W0613,E0202
return self.ports[port_name]
def all_port_names(self, platform=None): # pylint: disable=W0613,E0202
@@ -89,7 +89,11 @@ class LintTest(unittest.TestCase):
logging_stream = StringIO.StringIO()
options = optparse.Values({'platform': None})
- res = lint_test_expectations.lint(host, options, logging_stream)
+ logger, handler = lint_test_expectations.set_up_logging(logging_stream)
+ try:
+ res = lint_test_expectations.lint(host, options)
+ finally:
+ lint_test_expectations.tear_down_logging(logger, handler)
self.assertEqual(res, 0)
self.assertEqual(host.ports_parsed, ['a', 'b', 'b-win'])
@@ -102,10 +106,13 @@ class LintTest(unittest.TestCase):
# FIXME: incorrect complaints about spacing pylint: disable=C0322
host.port_factory.all_port_names = lambda platform=None: [platform]
- res = lint_test_expectations.lint(host, options, logging_stream)
+ logger, handler = lint_test_expectations.set_up_logging(logging_stream)
+ try:
+ res = lint_test_expectations.lint(host, options)
+ self.assertEqual(res, 0)
+ finally:
+ lint_test_expectations.tear_down_logging(logger, handler)
- self.assertEqual(res, 0)
- self.assertIn('Lint succeeded', logging_stream.getvalue())
def test_lint_test_files__errors(self):
options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
@@ -119,42 +126,75 @@ class LintTest(unittest.TestCase):
host.port_factory.all_port_names = lambda platform=None: [port.name()]
logging_stream = StringIO.StringIO()
+ logger, handler = lint_test_expectations.set_up_logging(logging_stream)
+ try:
+ res = lint_test_expectations.lint(host, options)
+ finally:
+ lint_test_expectations.tear_down_logging(logger, handler)
- res = lint_test_expectations.lint(host, options, logging_stream)
-
- self.assertEqual(res, -1)
- self.assertIn('Lint failed', logging_stream.getvalue())
+ self.assertTrue(res)
self.assertIn('foo:1', logging_stream.getvalue())
self.assertIn('bar:1', logging_stream.getvalue())
+class CheckVirtualSuiteTest(unittest.TestCase):
+ def test_check_virtual_test_suites(self):
+ host = MockHost()
+ options = optparse.Values({'platform': 'test', 'debug_rwt_logging': False})
+ orig_get = host.port_factory.get
+ host.port_factory.get = lambda options: orig_get('test', options=options)
+
+ logging_stream = StringIO.StringIO()
+ logger, handler = lint_test_expectations.set_up_logging(logging_stream)
+ try:
+ res = lint_test_expectations.check_virtual_test_suites(host, options)
+ self.assertTrue(res)
+
+ host.filesystem.exists = lambda path: True
+ res = lint_test_expectations.check_virtual_test_suites(host, options)
+ self.assertFalse(res)
+ finally:
+ lint_test_expectations.tear_down_logging(logger, handler)
+
+
class MainTest(unittest.TestCase):
- def test_success(self):
- orig_lint_fn = lint_test_expectations.lint
+ # unused args pylint: disable=W0613
- # unused args pylint: disable=W0613
- def interrupting_lint(host, options, logging_stream):
- raise KeyboardInterrupt
+ def setUp(self):
+ self.orig_lint_fn = lint_test_expectations.lint
+ self.orig_check_fn = lint_test_expectations.check_virtual_test_suites
+ lint_test_expectations.check_virtual_test_suites = lambda host, options: False
- def successful_lint(host, options, logging_stream):
- return 0
+ self.stdout = StringIO.StringIO()
+ self.stderr = StringIO.StringIO()
- def exception_raising_lint(host, options, logging_stream):
- assert False
+ def tearDown(self):
+ lint_test_expectations.lint = self.orig_lint_fn
+ lint_test_expectations.check_virtual_test_suites = self.orig_check_fn
- stdout = StringIO.StringIO()
- stderr = StringIO.StringIO()
- try:
- lint_test_expectations.lint = interrupting_lint
- res = lint_test_expectations.main([], stdout, stderr)
- self.assertEqual(res, lint_test_expectations.INTERRUPTED_EXIT_STATUS)
+ def test_success(self):
+ lint_test_expectations.lint = lambda host, options: False
+ res = lint_test_expectations.main(['--platform', 'test'], self.stdout, self.stderr)
+ self.assertTrue('Lint succeeded' in self.stderr.getvalue())
+ self.assertEqual(res, 0)
- lint_test_expectations.lint = successful_lint
- res = lint_test_expectations.main(['--platform', 'test'], stdout, stderr)
- self.assertEqual(res, 0)
+ def test_failure(self):
+ lint_test_expectations.lint = lambda host, options: True
+ res = lint_test_expectations.main(['--platform', 'test'], self.stdout, self.stderr)
+ self.assertTrue('Lint failed' in self.stderr.getvalue())
+ self.assertEqual(res, 1)
- lint_test_expectations.lint = exception_raising_lint
- res = lint_test_expectations.main([], stdout, stderr)
- self.assertEqual(res, lint_test_expectations.EXCEPTIONAL_EXIT_STATUS)
- finally:
- lint_test_expectations.lint = orig_lint_fn
+ def test_interrupt(self):
+ def interrupting_lint(host, options):
+ raise KeyboardInterrupt
+
+ lint_test_expectations.lint = interrupting_lint
+ res = lint_test_expectations.main([], self.stdout, self.stderr)
+ self.assertEqual(res, lint_test_expectations.INTERRUPTED_EXIT_STATUS)
+
+ def test_exception(self):
+ def exception_raising_lint(host, options):
+ assert False
+ lint_test_expectations.lint = exception_raising_lint
+ res = lint_test_expectations.main([], self.stdout, self.stderr)
+ self.assertEqual(res, lint_test_expectations.EXCEPTIONAL_EXIT_STATUS)
« no previous file with comments | « Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py ('k') | Tools/Scripts/webkitpy/layout_tests/port/base.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698