⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276512 in webkit


Ignore:
Timestamp:
Apr 23, 2021, 12:34:35 PM (5 years ago)
Author:
Sam Sneddon
Message:

Add a conftest.py to run existing webkitpy tests in pytest
https://bugs.webkit.org/show_bug.cgi?id=224687

Reviewed by Jonathan Bedard.

  • Scripts/webkitpy/common/system/executive_unittest.py:

(ExecutiveTest.serial_test_run_in_parallel): Deal with the fact that pytest
running the tests might be not be the same version as the autoinstalled version,
and not API compatible.

  • Scripts/webkitpy/conftest.py: Added.

(pytest_configure): Define the markers the plugins in conftest use
(pytest_addoption): Add --run-integration to allow them to be disabled by default.
(pytest_pycollect_makeitem): Rename serial/integration tests so pytest finds them.
(pytest_collection_modifyitems): Mark tests as skipped when needed per the above.

  • Scripts/webkitpy/pytest.ini: Added.
  • Scripts/webkitpy/test/main_unittest.py:

(TestStubs): Stop these from being picked up by pytest as tests.

  • Scripts/webkitpy/test/markers.py: Fix this so pytest is technically optional,

even though it is always present because of the autoinstalled copy.

Location:
trunk/Tools
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r276505 r276512  
     12021-04-23  Sam Sneddon  <gsnedders@apple.com>
     2
     3        Add a conftest.py to run existing webkitpy tests in pytest
     4        https://bugs.webkit.org/show_bug.cgi?id=224687
     5
     6        Reviewed by Jonathan Bedard.
     7
     8        * Scripts/webkitpy/common/system/executive_unittest.py:
     9        (ExecutiveTest.serial_test_run_in_parallel): Deal with the fact that pytest
     10        running the tests might be not be the same version as the autoinstalled version,
     11        and not API compatible.
     12        * Scripts/webkitpy/conftest.py: Added.
     13        (pytest_configure): Define the markers the plugins in conftest use
     14        (pytest_addoption): Add --run-integration to allow them to be disabled by default.
     15        (pytest_pycollect_makeitem): Rename serial/integration tests so pytest finds them.
     16        (pytest_collection_modifyitems): Mark tests as skipped when needed per the above.
     17        * Scripts/webkitpy/pytest.ini: Added.
     18        * Scripts/webkitpy/test/main_unittest.py:
     19        (TestStubs): Stop these from being picked up by pytest as tests.
     20        * Scripts/webkitpy/test/markers.py: Fix this so pytest is technically optional,
     21        even though it is always present because of the autoinstalled copy.
     22
    1232021-04-23  Aakash Jain  <aakash_jain@apple.com>
    224
  • trunk/Tools/Scripts/webkitpy/common/system/executive_unittest.py

    r276434 r276512  
    251251        cwd = os.getcwd()
    252252        commands = [tuple([cmd_line, cwd])] * NUM_PROCESSES
    253         start = time.time()
    254         command_outputs = Executive().run_in_parallel(commands, processes=NUM_PROCESSES)
    255         done = time.time()
     253
     254        try:
     255            # we overwrite __main__ to be this to avoid any issues with
     256            # multiprocessing's spawning caused by multiple versions of pytest on
     257            # sys.path
     258            old_main = sys.modules["__main__"]
     259            sys.modules["__main__"] = sys.modules[__name__]
     260            start = time.time()
     261            command_outputs = Executive().run_in_parallel(commands, processes=NUM_PROCESSES)
     262            done = time.time()
     263        finally:
     264            sys.modules["__main__"] = old_main
     265
    256266        self.assertTrue(done - start < NUM_PROCESSES * DELAY_SECS)
    257267        self.assertEqual([output[1] for output in command_outputs], [b'hello\n'] * NUM_PROCESSES)
  • trunk/Tools/Scripts/webkitpy/test/main_unittest.py

    r276434 r276512  
    3939
    4040class TestStubs(unittest.TestCase):
     41    __pytest_no_rewrite__ = True
     42
    4143    def test_empty(self):
    4244        pass
  • trunk/Tools/Scripts/webkitpy/test/markers.py

    r276436 r276512  
    2222
    2323import unittest
     24
     25try:
     26    import pytest
     27except ImportError:
     28    pass
    2429
    2530
Note: See TracChangeset for help on using the changeset viewer.