Skip to content

Long test path + name is too long for file system #136

@dooferlad

Description

@dooferlad

Bug Report

Current Behavior A clear and concise description of the behavior.
Some tests cause OSError: [Errno 36] File name too long because the test path and test name is too long for the file system to support.

Input Code
Just create a test in a sufficiently long test path.

Expected behavior/code A clear and concise description of what you expected to
happen (or code).
Test to Just Work(tm).

Environment

  • Python(s): [e.g. python3.8, python3.9, ...]
    Python 3.11 on ext4.

Possible Solution

Change path generation code to not substitute os.sep for - and create the full directory hierarchy. I use a short value for --memray-bin-path and this change to the plugin:

        def _build_bin_path() -> Path:
            if self._tmp_dir is None and not os.getenv("MEMRAY_RESULT_PATH"):
                of_id = pyfuncitem.nodeid.replace("::", "-")
                name = f"{self._bin_prefix}/{of_id}.bin"
            else:
                name = f"{uuid.uuid4().hex}.bin"

            result_file = self.result_path / name
            result_file.parent.mkdir(parents=True, exist_ok=True)
            if self._tmp_dir is None and result_file.exists():
                result_file.unlink()
            return result_file

This works in my case because the path is long, but the actual file name is short enough for the file system to support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions