Title: [250608] trunk/Tools
Revision
250608
Author
[email protected]
Date
2019-10-02 09:21:03 -0700 (Wed, 02 Oct 2019)

Log Message

Python 3: Add test-webkitpy for Python 3
https://bugs.webkit.org/show_bug.cgi?id=201954

Reviewed by Aakash Jain.

* Scripts/test-webkitpy-python3: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (250607 => 250608)


--- trunk/Tools/ChangeLog	2019-10-02 15:58:12 UTC (rev 250607)
+++ trunk/Tools/ChangeLog	2019-10-02 16:21:03 UTC (rev 250608)
@@ -1,3 +1,12 @@
+2019-10-01  Jonathan Bedard  <[email protected]>
+
+        Python 3: Add test-webkitpy for Python 3
+        https://bugs.webkit.org/show_bug.cgi?id=201954
+
+        Reviewed by Aakash Jain.
+
+        * Scripts/test-webkitpy-python3: Added.
+
 2019-10-02  Carlos Garcia Campos  <[email protected]>
 
         [GTK][WPE] Stop using legacy custom protocol implementation

Added: trunk/Tools/Scripts/test-webkitpy-python3 (0 => 250608)


--- trunk/Tools/Scripts/test-webkitpy-python3	                        (rev 0)
+++ trunk/Tools/Scripts/test-webkitpy-python3	2019-10-02 16:21:03 UTC (rev 250608)
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+import sys
+sys.dont_write_bytecode = True
+
+import argparse
+import os
+import sys
+import unittest
+
+
+PYTHON3_COMPATIBLE_DIRECTORIES = [
+  'webkitpy.common.system',
+  'webkitpy.common.thread',
+]
+
+
+def main():
+    parser = argparse.ArgumentParser(description='Run unit tests with Python3. This is intended as a temporary script during the Python2/3 transition')
+    parser.add_argument(
+        '-v', '--verbose',
+        default=False, action='',
+        help='Verbose output',
+    )
+    parser.add_argument(
+        '-f', '--stop-on-fail',
+        default=False, action='',
+        help='Stop on first fail or error',
+    )
+
+    if len(PYTHON3_COMPATIBLE_DIRECTORIES) == 1:
+        compatible_directories_readable = PYTHON3_COMPATIBLE_DIRECTORIES[0]
+    else:
+        compatible_directories_readable = '{} and {}'.format(
+            ', '.join(PYTHON3_COMPATIBLE_DIRECTORIES[:-1]),
+            PYTHON3_COMPATIBLE_DIRECTORIES[-1],
+        )
+    parser.add_argument(
+        'modules_to_test', nargs='*',
+        help='Modules to be tested. By default, this is {}'.format(compatible_directories_readable),
+        default=PYTHON3_COMPATIBLE_DIRECTORIES,
+    )
+    options = parser.parse_args()
+
+    root = os.path.dirname(os.path.abspath(__file__))
+
+    suite = unittest.TestSuite()
+    for module_name in options.modules_to_test:
+        module_suite = unittest.defaultTestLoader.discover(os.path.join(root, module_name.replace('.', '/')), pattern='*test.py', top_level_dir=root)
+        for test in (module_suite or []):
+            suite.addTest(test)
+
+    if suite.countTestCases() == 0:
+        raise RuntimeError('No matching tests found.')
+
+    result = unittest.TextTestRunner(verbosity=int(options.verbose) + 1, failfast=options.stop_on_fail, buffer=not options.verbose).run(suite)
+    return len(result.errors)
+
+if __name__ == '__main__':
+    sys.exit(main())
Property changes on: trunk/Tools/Scripts/test-webkitpy-python3
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to