Commit ff1030ca authored by eric@webkit.org's avatar eric@webkit.org

2010-01-05 Chris Jerdonek <chris.jerdonek@gmail.com>

        Reviewed by Eric Seidel.

        Minor improvements to test-webkit-scripts, as suggested
        by an earlier review.

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

        * Scripts/test-webkit-scripts:
          - Used OptionParser class instead of getopt.getopt().
          - Created main() method for __main__ block.
          - Enclosed functions in a class.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 545a8b4b
2010-01-05 Chris Jerdonek <chris.jerdonek@gmail.com>
Reviewed by Eric Seidel.
Minor improvements to test-webkit-scripts, as suggested
by an earlier review.
https://bugs.webkit.org/show_bug.cgi?id=33125
* Scripts/test-webkit-scripts:
- Used OptionParser class instead of getopt.getopt().
- Created main() method for __main__ block.
- Enclosed functions in a class.
2010-01-05 Chris Fleizach <cfleizach@apple.com>
No review. Fix DRT breakage on Tiger/Leopard.
......
#!/usr/bin/python
#
# Copyright (C) 2009 Chris Jerdonek (chris.jerdonek@gmail.com)
# Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek@gmail.com)
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
......@@ -28,56 +28,58 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Tests WebKit Perl and Python scripts.
"""Run unit tests of WebKit's Perl and Python scripts."""
Syntax: test-webkit-scripts [--all]
--all Runs all available tests, including those suppressed
by default.
"""
# The docstring above is passed as the "description" to the OptionParser
# used in this script's __main__ block.
#
# For the command options supported by this script, see the code below
# that instantiates the OptionParser class, or else pass --help
# while running this script (since argument help is auto-generated).
import getopt
import os
import subprocess
import sys
from optparse import OptionParser
def test_script(title, script_path, args=None):
"""Run the given test command."""
print('Testing %s:' % title)
class ScriptsTester(object):
call_args = [script_path]
if args is not None:
call_args.extend(args)
subprocess.call(call_args)
print(70 * "*") # dividing line
"""Supports running unit tests of WebKit scripts."""
if __name__ == '__main__':
def __init__(self, scripts_directory):
self.scripts_directory = scripts_directory
try:
(opts, filenames) = getopt.getopt(sys.argv[1:], '', ['help', 'all'])
except getopt.GetoptError:
print(__doc__)
sys.exit('Error: invalid option.')
def script_path(self, script_file_name):
"""Return an absolute path to the given script."""
return os.path.join(self.scripts_directory, script_file_name)
should_include_all = False
def run_test_script(self, script_title, script_path, args=None):
"""Run the given test script."""
print('Testing %s:' % script_title)
call_args = [script_path]
if args:
call_args.extend(args)
subprocess.call(call_args)
print(70 * "*") # dividing line
for (opt, val) in opts:
if opt == '--help':
print(__doc__)
sys.exit()
elif opt == '--all':
should_include_all = True
def main(self):
parser = OptionParser(description=__doc__)
parser.add_option('-a', '--all', dest='all', action='store_true',
default=False, help='run all available tests, '
'including those suppressed by default')
(options, args) = parser.parse_args()
# Use absolute paths so this script can be run from any directory.
scripts_directory = sys.path[0]
self.run_test_script('Perl scripts', self.script_path('test-webkitperl'))
self.run_test_script('Python scripts', self.script_path('test-webkitpy'),
['--all'] if options.all else None)
test_script('Perl scripts', os.path.join(scripts_directory, 'test-webkitperl'))
# FIXME: Display a cumulative indication of success or failure.
# In addition, call sys.exit() with 0 or 1 depending on that
# cumulative success or failure.
print('Note: Perl and Python results appear separately above.')
test_script('Python scripts',
os.path.join(scripts_directory, 'test-webkitpy'),
['--all'] if should_include_all else None)
# FIXME: Display a cumulative indication of success or failure.
# In addition, call sys.exit() with 0 or 1 depending on that
# cumulative success or failure.
print('Note: Perl and Python results appear separately above.')
if __name__ == '__main__':
# The scripts directory is the directory containing this file.
tester = ScriptsTester(os.path.dirname(__file__))
tester.main()
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