Commit 4d775c83 authored by cjerdonek@webkit.org's avatar cjerdonek@webkit.org
Browse files

Changed test-webkitpy so that messages logged as a side-effect

of unit-testing code do not get displayed to the screen.  These
messages clutter up the unit test results if not filtered out.

Reviewed by Adam Barth.

https://bugs.webkit.org/show_bug.cgi?id=35835

* Scripts/test-webkitpy:
  - Adjusted the configure_logging() method to filter out any
    log messages from webkitpy.
  - Also added an INFO message stating that most console logging
    is getting suppressed.

* Scripts/webkitpy/init/versioning.py:
  - Added a log parameter to the check_version() method.

* Scripts/webkitpy/init/versioning_unittest.py:
  - Qualified a call to check_version() with the parameter names.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55971 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 477e780e
2010-03-13 Chris Jerdonek <cjerdonek@webkit.org>
Reviewed by Adam Barth.
Changed test-webkitpy so that messages logged as a side-effect
of unit-testing code do not get displayed to the screen. These
messages clutter up the unit test results if not filtered out.
https://bugs.webkit.org/show_bug.cgi?id=35835
* Scripts/test-webkitpy:
- Adjusted the configure_logging() method to filter out any
log messages from webkitpy.
- Also added an INFO message stating that most console logging
is getting suppressed.
* Scripts/webkitpy/init/versioning.py:
- Added a log parameter to the check_version() method.
* Scripts/webkitpy/init/versioning_unittest.py:
- Qualified a call to check_version() with the parameter names.
2010-03-13 Chris Jerdonek <cjerdonek@webkit.org>
 
Reviewed by Adam Barth.
......
......@@ -38,7 +38,12 @@ _log = logging.getLogger("test-webkitpy")
def configure_logging():
"""Configure the root logger to log info messages and above."""
"""Configure the root logger.
Configure the root logger not to log any messages from webkitpy,
and to log all other messages that are INFO and above.
"""
handler = logging.StreamHandler(sys.stderr)
formatter = logging.Formatter("[%(levelname)s] %(name)s: %(message)s")
handler.setFormatter(formatter)
......@@ -47,12 +52,34 @@ def configure_logging():
logger.setLevel(logging.INFO)
logger.addHandler(handler)
# Filter out most webkitpy messages.
#
# Messages can be selectively re-enabled for this script by updating
# this method accordingly.
def filter(record):
"""Filter out autoinstall and non-third-party webkitpy messages."""
# FIXME: Enable the logging of autoinstall messages once
# autoinstall is adjusted. Currently, autoinstall logs
# INFO messages when importing already-downloaded packages,
# which is too verbose.
if record.name.startswith("webkitpy"):
return False
return True
testing_filter = logging.Filter()
testing_filter.filter = filter
# Display a message so developers are not mystified as to why
# logging does not work in the unit tests.
_log.info("Suppressing most webkitpy logging while running unit tests.")
handler.addFilter(testing_filter)
def init():
"""Execute code prior to importing from webkitpy.unittests."""
configure_logging()
versioning.check_version()
versioning.check_version(log=_log)
(comparison, current_version, minimum_version) = \
versioning.compare_version()
......
......@@ -97,13 +97,15 @@ def compare_version(sysmodule=None, target_version=None):
# FIXME: Add a logging level parameter to allow the version message
# to be logged at levels other than WARNING, for example CRITICAL.
def check_version(sysmodule=None, target_version=None):
def check_version(log=None, sysmodule=None, target_version=None):
"""Check the current Python version against a target version.
Logs a warning message if the current version is less than the
target version.
Args:
log: A logging.logger instance to use when logging the version warning.
Defaults to the logger of this module.
sysmodule: See the compare_version() docstring.
target_version: See the compare_version() docstring.
......@@ -112,6 +114,9 @@ def check_version(sysmodule=None, target_version=None):
or equal to the target version.
"""
if log is None:
log = _log
(comparison, current_version, target_version) = \
compare_version(sysmodule, target_version)
......@@ -122,5 +127,5 @@ def check_version(sysmodule=None, target_version=None):
message = ("WebKit Python scripts do not support your current Python "
"version (%s). The minimum supported version is %s."
% (current_version, target_version))
_log.warn(message)
log.warn(message)
return False
......@@ -112,7 +112,7 @@ class CheckVersionTest(unittest.TestCase):
def _check_version(self, minimum_version):
"""Call check_version()."""
mock_sys = MockSys("2.5.3")
return check_version(mock_sys, minimum_version)
return check_version(sysmodule=mock_sys, target_version=minimum_version)
def test_true_return_value(self):
"""Test the configured minimum version that webkitpy supports."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment