Title: [276434] trunk/Tools
Revision
276434
Author
gsnedd...@apple.com
Date
2021-04-22 07:09:22 -0700 (Thu, 22 Apr 2021)

Log Message

Fix potential flakiness when running webkitpy tests
https://bugs.webkit.org/show_bug.cgi?id=224887

Reviewed by Jonathan Bedard.

* Scripts/webkitpy/common/system/executive_unittest.py:
(ExecutiveTest.serial_test_run_in_parallel): Increase the delay to ensure it's
much greater than the VM spawn time, as the current time is a bit marginal when
the system is under load and we're using the spawn multiprocessing start method
* Scripts/webkitpy/test/main.py:
(Tester.run): Allow argv to be passed through for testing
* Scripts/webkitpy/test/main_unittest.py:
(TesterTest.test_no_tests_found): Explicitly pass argv to avoid using sys.argv
* Scripts/webkitpy/w3c/test_parser_unittest.py:
(TestParserTest.test_analyze_pixel_test_all_true): Reset options after test
(TestParserTest.test_analyze_pixel_test_all_false): Reset options after test
* Scripts/webkitpy/xcode/simulated_device_unittest.py:
(SimulatedDeviceTest.reset_simulated_device_manager): _device_identifier_to_name
is a dict, and should remain one

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (276433 => 276434)


--- trunk/Tools/ChangeLog	2021-04-22 14:06:06 UTC (rev 276433)
+++ trunk/Tools/ChangeLog	2021-04-22 14:09:22 UTC (rev 276434)
@@ -1,3 +1,25 @@
+2021-04-22  Sam Sneddon  <gsnedd...@apple.com>
+
+        Fix potential flakiness when running webkitpy tests
+        https://bugs.webkit.org/show_bug.cgi?id=224887
+
+        Reviewed by Jonathan Bedard.
+
+        * Scripts/webkitpy/common/system/executive_unittest.py:
+        (ExecutiveTest.serial_test_run_in_parallel): Increase the delay to ensure it's
+        much greater than the VM spawn time, as the current time is a bit marginal when
+        the system is under load and we're using the spawn multiprocessing start method
+        * Scripts/webkitpy/test/main.py:
+        (Tester.run): Allow argv to be passed through for testing
+        * Scripts/webkitpy/test/main_unittest.py:
+        (TesterTest.test_no_tests_found): Explicitly pass argv to avoid using sys.argv
+        * Scripts/webkitpy/w3c/test_parser_unittest.py:
+        (TestParserTest.test_analyze_pixel_test_all_true): Reset options after test
+        (TestParserTest.test_analyze_pixel_test_all_false): Reset options after test
+        * Scripts/webkitpy/xcode/simulated_device_unittest.py:
+        (SimulatedDeviceTest.reset_simulated_device_manager): _device_identifier_to_name
+        is a dict, and should remain one
+
 2021-04-22  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [iOS] Web processes recreated after crashing are not created with the right contentSizeCategory

Modified: trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py (276433 => 276434)


--- trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py	2021-04-22 14:06:06 UTC (rev 276433)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py	2021-04-22 14:09:22 UTC (rev 276434)
@@ -246,7 +246,7 @@
         import multiprocessing
 
         NUM_PROCESSES = 4
-        DELAY_SECS = 0.25
+        DELAY_SECS = 1.0  # make sure this is much greater than the VM spawn time
         cmd_line = [sys.executable, '-c', 'import time; time.sleep(%f); print("hello")' % DELAY_SECS]
         cwd = os.getcwd()
         commands = [tuple([cmd_line, cwd])] * NUM_PROCESSES

Modified: trunk/Tools/Scripts/webkitpy/test/main.py (276433 => 276434)


--- trunk/Tools/Scripts/webkitpy/test/main.py	2021-04-22 14:06:06 UTC (rev 276433)
+++ trunk/Tools/Scripts/webkitpy/test/main.py	2021-04-22 14:09:22 UTC (rev 276434)
@@ -170,8 +170,8 @@
 
         return parser.parse_args(argv)
 
-    def run(self):
-        self._options, args = self._parse_args()
+    def run(self, argv=None):
+        self._options, args = self._parse_args(argv)
         self.printer.configure(self._options)
 
         self.finder.clean_trees()

Modified: trunk/Tools/Scripts/webkitpy/test/main_unittest.py (276433 => 276434)


--- trunk/Tools/Scripts/webkitpy/test/main_unittest.py	2021-04-22 14:06:06 UTC (rev 276433)
+++ trunk/Tools/Scripts/webkitpy/test/main_unittest.py	2021-04-22 14:09:22 UTC (rev 276434)
@@ -53,7 +53,7 @@
 
 class TesterTest(unittest.TestCase):
 
-    def test_no_tests_found(self):
+    def serial_test_no_tests_found(self):
         tester = Tester()
         errors = StringIO()
 
@@ -61,16 +61,18 @@
         # don't log the messages webkitpy.test while we're testing it.
         root_logger = logging.getLogger()
         root_handlers = root_logger.handlers
-        root_logger.handlers = []
+        try:
+            root_logger.handlers = []
 
-        tester.printer.stream = errors
-        tester.finder.find_names = lambda args, run_all: []
-        with OutputCapture(level=logging.INFO) as captured:
-            self.assertFalse(tester.run())
-        root_logger.handlers = root_handlers
+            tester.printer.stream = errors
+            tester.finder.find_names = lambda args, run_all: []
+            with OutputCapture(level=logging.INFO) as captured:
+                self.assertFalse(tester.run([]))
 
-        self.assertIn('No tests to run', errors.getvalue())
-        self.assertIn('No tests to run', captured.root.log.getvalue())
+            self.assertIn('No tests to run', errors.getvalue())
+            self.assertIn('No tests to run', captured.root.log.getvalue())
+        finally:
+            root_logger.handlers = root_handlers
 
     def _find_test_names(self, args):
         tester = Tester()

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_parser_unittest.py (276433 => 276434)


--- trunk/Tools/Scripts/webkitpy/w3c/test_parser_unittest.py	2021-04-22 14:06:06 UTC (rev 276433)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_parser_unittest.py	2021-04-22 14:09:22 UTC (rev 276434)
@@ -217,17 +217,22 @@
 </html>
 """
         # Set options to 'all' so this gets found
-        options['all'] = True
+        global options
+        orig_options = options.copy()
+        try:
+            options['all'] = True
 
-        test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
-        parser = TestParser(options, os.path.join(test_path, 'somefile.html'))
-        test_info = parser.analyze_test(test_contents=test_html)
+            test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
+            parser = TestParser(options, os.path.join(test_path, 'somefile.html'))
+            test_info = parser.analyze_test(test_contents=test_html)
 
-        self.assertNotEqual(test_info, None, 'test_info is None')
-        self.assertTrue('test' in test_info.keys(), 'did not find a test file')
-        self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
-        self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
-        self.assertFalse('jstest' in test_info.keys(), 'test should not be a jstest')
+            self.assertNotEqual(test_info, None, 'test_info is None')
+            self.assertTrue('test' in test_info.keys(), 'did not find a test file')
+            self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file')
+            self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test')
+            self.assertFalse('jstest' in test_info.keys(), 'test should not be a jstest')
+        finally:
+            options = orig_options
 
     def test_analyze_pixel_test_all_false(self):
         """ Tests analyze_test() using a test that is neither a reftest or jstest, with -all=False """
@@ -246,13 +251,18 @@
 </html>
 """
         # Set all to false so this gets skipped
-        options['all'] = False
+        global options
+        orig_options = options.copy()
+        try:
+            options['all'] = False
 
-        test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
-        parser = TestParser(options, os.path.join(test_path, 'somefile.html'))
-        test_info = parser.analyze_test(test_contents=test_html)
+            test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
+            parser = TestParser(options, os.path.join(test_path, 'somefile.html'))
+            test_info = parser.analyze_test(test_contents=test_html)
 
-        self.assertEqual(test_info, None, 'test should have been skipped')
+            self.assertEqual(test_info, None, 'test should have been skipped')
+        finally:
+            options = orig_options
 
     def test_analyze_non_html_file(self):
         """ Tests analyze_test() with a file that has no html"""

Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py (276433 => 276434)


--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py	2021-04-22 14:06:06 UTC (rev 276433)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py	2021-04-22 14:09:22 UTC (rev 276434)
@@ -513,7 +513,7 @@
         SimulatedDeviceManager.AVAILABLE_RUNTIMES = []
         SimulatedDeviceManager.AVAILABLE_DEVICES = []
         SimulatedDeviceManager.INITIALIZED_DEVICES = None
-        SimulatedDeviceManager._device_identifier_to_name = False
+        SimulatedDeviceManager._device_identifier_to_name = {}
         SimulatedDeviceManager._managing_simulator_app = False
 
     def tearDown(self):
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to