tmuxp icon indicating copy to clipboard operation
tmuxp copied to clipboard

1.12.0: test_automatic_rename_option failure

Open dvzrv opened this issue 3 years ago • 3 comments
trafficstars

Step 1: Provide a summary of your problem

Hi! Upon trying to package 1.12.0 for Arch Linux I ran into issues with test_automatic_rename_option.

Step 2: Provide tmuxp details

  • python 3.10.5
  • tmuxp 1.12.0
  • libtmux 0.12.0
  • kaptan 0.5.12
  • colorama 0.4.5
  • click 8.1.3
  • pytest 7.1.2

Step 3: Describe the problem:

Steps to reproduce:

  1. python -m build --wheel --no-isolation
  2. pytest -vv
  3. ...

Observed Results:

=================================== FAILURES ===================================
_________________________ test_automatic_rename_option _________________________

session = Session($1 libtmux_5qtbopkd)

    def test_automatic_rename_option(session):
        """With option automatic-rename: on."""
        yaml_config = test_utils.read_config_file(
            "workspacebuilder/window_automatic_rename.yaml"
        )
        s = session
        sconfig = kaptan.Kaptan(handler="yaml")
        sconfig = sconfig.import_config(yaml_config).get()

        # This should be a command guaranteed to be terminal name across systems
        portable_command = sconfig["windows"][0]["panes"][0]["shell_command"][0]["cmd"]
        # If a command is like "man ls", get the command base name, "ls"
        if " " in portable_command:
            portable_command = portable_command.split(" ")[0]

        builder = WorkspaceBuilder(sconf=sconfig)

        window_count = len(session._windows)  # current window count
        assert len(s._windows) == window_count
        for w, wconf in builder.iter_create_windows(s):

            for p in builder.iter_create_panes(w, wconf):
                w.select_layout("tiled")  # fix glitch with pane size
                p = p
                assert len(s._windows), window_count
            assert isinstance(w, Window)
            assert w.show_window_option("automatic-rename") == "on"

            assert len(s._windows) == window_count

            window_count += 1
            w.select_layout(wconf["layout"])

        assert s.name != "tmuxp"
        w = s.windows[0]

        def check_window_name_mismatch() -> bool:
            session.server._update_windows()
            return w.name != portable_command

        assert retry_until(check_window_name_mismatch, 2, interval=0.25)

        pane_base_index = w.show_window_option("pane-base-index", g=True)
        w.select_pane(pane_base_index)

        def check_window_name_match() -> bool:
            session.server._update_windows()
            return w.name == portable_command

>       assert retry_until(
            check_window_name_match, 2, interval=0.25
        ), f"Window name {w.name} should be {portable_command}"

tests/test_workspacebuilder.py:401:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

fun = <function test_automatic_rename_option.<locals>.check_window_name_match at 0x6d9ff9bb44c0>
seconds = 2

    def retry_until(
        fun: Callable,
        seconds: float = RETRY_TIMEOUT_SECONDS,
        *,
        interval: float = RETRY_INTERVAL_SECONDS,
        raises: Optional[bool] = True,
    ) -> bool:
        """
        Retry a function until a condition meets or the specified time passes.

        Parameters
        ----------
        fun : callable
            A function that will be called repeatedly until it returns ``True``  or
            the specified time passes.
        seconds : float
            Seconds to retry. Defaults to ``8``, which is configurable via
            ``RETRY_TIMEOUT_SECONDS`` environment variables.
        interval : float
            Time in seconds to wait between calls. Defaults to ``0.05`` and is
            configurable via ``RETRY_INTERVAL_SECONDS`` environment variable.
        raises : bool
            Wether or not to raise an exception on timeout. Defaults to ``True``.

        Examples
        --------

        >>> def f():
        ...     p = w.attached_pane
        ...     p.server._update_panes()
        ...     return p.current_path == pane_path
        ...
        ... retry(f)

        In pytest:

        >>> assert retry(f, raises=False)
        """
        ini = time.time()

        while not fun():
            end = time.time()
            if end - ini >= seconds:
                if raises:
>                   raise WaitTimeout()
E                   libtmux.exc.WaitTimeout

/usr/lib/python3.10/site-packages/libtmux/test.py:115: WaitTimeout
=============================== warnings summary ===============================
../../../../usr/lib/python3.10/site-packages/libtmux/common.py:484: 1 warning
tests/test_cli.py: 226 warnings
tests/test_plugin.py: 10 warnings
tests/test_util.py: 8 warnings
tests/test_workspacebuilder.py: 205 warnings
tests/test_workspacefreezer.py: 5 warnings
tests/tests/test_helpers.py: 12 warnings
  /usr/lib/python3.10/site-packages/libtmux/common.py:484: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    return LooseVersion(version)

../../../../usr/lib/python3.10/site-packages/libtmux/common.py:569
  /usr/lib/python3.10/site-packages/libtmux/common.py:569: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    return get_version() < LooseVersion(max_version)

tests/test_cli.py: 172 warnings
tests/test_util.py: 8 warnings
tests/test_workspacebuilder.py: 205 warnings
tests/test_workspacefreezer.py: 5 warnings
tests/tests/test_helpers.py: 12 warnings
  /usr/lib/python3.10/site-packages/libtmux/common.py:535: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    return get_version() >= LooseVersion(min_version)

tests/test_cli.py: 52 warnings
  /usr/lib/python3.10/site-packages/libtmux/common.py:602: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if get_version() < LooseVersion(TMUX_MIN_VERSION):

tests/test_cli.py: 1 warning
tests/test_plugin.py: 10 warnings
  /build/tmuxp/src/tmuxp-1.12.0/tmuxp/plugin.py:87: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    self.tmuxp_version = LooseVersion(__version__)

tests/test_cli.py: 3 warnings
tests/test_plugin.py: 48 warnings
  /build/tmuxp/src/tmuxp-1.12.0/tmuxp/plugin.py:138: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if vmin and version < LooseVersion(vmin):

tests/test_cli.py: 1 warning
tests/test_plugin.py: 34 warnings
  /usr/lib/python3.10/site-packages/setuptools/_distutils/version.py:351: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    other = LooseVersion(other)

tests/test_cli.py: 1 warning
tests/test_plugin.py: 11 warnings
  /build/tmuxp/src/tmuxp-1.12.0/tmuxp/plugin.py:140: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if vmax and version > LooseVersion(vmax):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_workspacebuilder.py::test_automatic_rename_option - libtmux...
=========== 1 failed, 178 passed, 2 skipped, 1031 warnings in 27.14s ===========

Full build log: tmuxp-1.12.0-1-x86_64-build.log

Full test log: tmuxp-1.12.0-1-x86_64-check.log

Expected Results:

All tests pass

Relevant Code:

dvzrv avatar Aug 01 '22 23:08 dvzrv

Looks like we're not out of the woods yet as far as bug fixes go.

Do you know of any github actions that would let us test on Arch? https://github.com/uraimo/run-on-arch-action?

tony avatar Aug 01 '22 23:08 tony

You can directly incorporate the official Arch Linux container in github's CI, install all required packages to it, build the same way we do (using PEP517) and run tests with pytest in there. If I find time, I can have a look into providing a PR for this, unless your setup is very complex ;-)

dvzrv avatar Aug 02 '22 07:08 dvzrv

I can have a look into providing a PR for this, unless your setup is very complex ;-)

You can try, or alternatively show an example github CI file of an arch workflow

tony avatar Aug 02 '22 11:08 tony

FWIW, this is still an issue with 1.15.1

dvzrv avatar Sep 24 '22 10:09 dvzrv

You can try, or alternatively show an example github CI file of an arch workflow

You can have a look at this for using the official Arch Linux container: https://github.com/jackaudio/jack-example-tools/blob/c3d07f03454da5bb8f4a03acd1417efd53f2cff0/.github/workflows/build.yml#L36-L49

dvzrv avatar Sep 24 '22 10:09 dvzrv

@dvzrv Thank you for keeping in touch on this test! I am actively working on improving the tests to work perfectly across platforms

You can have a look at this for using the official Arch Linux container: https://github.com/jackaudio/jack-example-tools/blob/c3d07f03454da5bb8f4a03acd1417efd53f2cff0/.github/workflows/build.yml#L36-L49

Thank you for this!

tony avatar Sep 24 '22 12:09 tony

@dvzrv Does tests/workspace/test_builder.py::test_automatic_rename_option still fail with the latest tmuxp/libtmux?

tony avatar Dec 28 '22 15:12 tony

This seems fixed with libtmux 0.18.1/ tmuxp 1.22.1

Thank you!

dvzrv avatar Dec 30 '22 10:12 dvzrv