Changeset 52790 in webkit
- Timestamp:
- Jan 5, 2010 12:47:34 AM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r52789 r52790 1 2010-01-05 Chris Jerdonek <chris.jerdonek@gmail.com> 2 3 Reviewed by Eric Seidel. 4 5 Minor improvements to test-webkit-scripts, as suggested 6 by an earlier review. 7 8 https://bugs.webkit.org/show_bug.cgi?id=33125 9 10 * Scripts/test-webkit-scripts: 11 - Used OptionParser class instead of getopt.getopt(). 12 - Created main() method for __main__ block. 13 - Enclosed functions in a class. 14 1 15 2010-01-05 Chris Fleizach <cfleizach@apple.com> 2 16 -
trunk/WebKitTools/Scripts/test-webkit-scripts
r52732 r52790 1 1 #!/usr/bin/python 2 2 # 3 # Copyright (C) 2009 Chris Jerdonek (chris.jerdonek@gmail.com)3 # Copyright (C) 2009, 2010 Chris Jerdonek (chris.jerdonek@gmail.com) 4 4 # 5 5 # Redistribution and use in source and binary forms, with or without … … 29 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 30 31 """ Tests WebKit Perl and Python scripts.31 """Run unit tests of WebKit's Perl and Python scripts.""" 32 32 33 Syntax: test-webkit-scripts [--all] 33 # The docstring above is passed as the "description" to the OptionParser 34 # used in this script's __main__ block. 35 # 36 # For the command options supported by this script, see the code below 37 # that instantiates the OptionParser class, or else pass --help 38 # while running this script (since argument help is auto-generated). 34 39 35 --all Runs all available tests, including those suppressed36 by default.37 """38 39 import getopt40 40 import os 41 41 import subprocess 42 42 import sys 43 from optparse import OptionParser 43 44 44 def test_script(title, script_path, args=None): 45 """Run the given test command.""" 46 print('Testing %s:' % title) 45 class ScriptsTester(object): 47 46 48 call_args = [script_path] 49 if args is not None: 50 call_args.extend(args) 51 subprocess.call(call_args) 52 print(70 * "*") # dividing line 47 """Supports running unit tests of WebKit scripts.""" 48 49 def __init__(self, scripts_directory): 50 self.scripts_directory = scripts_directory 51 52 def script_path(self, script_file_name): 53 """Return an absolute path to the given script.""" 54 return os.path.join(self.scripts_directory, script_file_name) 55 56 def run_test_script(self, script_title, script_path, args=None): 57 """Run the given test script.""" 58 print('Testing %s:' % script_title) 59 call_args = [script_path] 60 if args: 61 call_args.extend(args) 62 subprocess.call(call_args) 63 print(70 * "*") # dividing line 64 65 def main(self): 66 parser = OptionParser(description=__doc__) 67 parser.add_option('-a', '--all', dest='all', action='store_true', 68 default=False, help='run all available tests, ' 69 'including those suppressed by default') 70 (options, args) = parser.parse_args() 71 72 self.run_test_script('Perl scripts', self.script_path('test-webkitperl')) 73 self.run_test_script('Python scripts', self.script_path('test-webkitpy'), 74 ['--all'] if options.all else None) 75 76 # FIXME: Display a cumulative indication of success or failure. 77 # In addition, call sys.exit() with 0 or 1 depending on that 78 # cumulative success or failure. 79 print('Note: Perl and Python results appear separately above.') 80 53 81 54 82 if __name__ == '__main__': 55 56 try: 57 (opts, filenames) = getopt.getopt(sys.argv[1:], '', ['help', 'all']) 58 except getopt.GetoptError: 59 print(__doc__) 60 sys.exit('Error: invalid option.') 61 62 should_include_all = False 63 64 for (opt, val) in opts: 65 if opt == '--help': 66 print(__doc__) 67 sys.exit() 68 elif opt == '--all': 69 should_include_all = True 70 71 # Use absolute paths so this script can be run from any directory. 72 scripts_directory = sys.path[0] 73 74 test_script('Perl scripts', os.path.join(scripts_directory, 'test-webkitperl')) 75 76 test_script('Python scripts', 77 os.path.join(scripts_directory, 'test-webkitpy'), 78 ['--all'] if should_include_all else None) 79 80 # FIXME: Display a cumulative indication of success or failure. 81 # In addition, call sys.exit() with 0 or 1 depending on that 82 # cumulative success or failure. 83 print('Note: Perl and Python results appear separately above.') 83 # The scripts directory is the directory containing this file. 84 tester = ScriptsTester(os.path.dirname(__file__)) 85 tester.main()
Note: See TracChangeset
for help on using the changeset viewer.