Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test__version__from_fossil fails without home #77

Closed
mtelka opened this issue Feb 8, 2024 · 6 comments
Closed

test__version__from_fossil fails without home #77

mtelka opened this issue Feb 8, 2024 · 6 comments

Comments

@mtelka
Copy link

mtelka commented Feb 8, 2024

The test__version__from_fossil test fails when there is no home set:

__________________________ test__version__from_fossil __________________________

tmp_path = PosixPath('/tmp/pytest-of-marcel/pytest-18/test__version__from_fossil0')

    @pytest.mark.skipif(shutil.which("fossil") is None, reason="Requires Fossil")
    def test__version__from_fossil(tmp_path) -> None:
        vcs = tmp_path / "dunamai-fossil"
        vcs.mkdir()
        run = make_run_callback(vcs)
        from_vcs = make_from_callback(Version.from_fossil)
        b = "trunk"

        with chdir(vcs):
>           run("fossil init repo")

tests/integration/test_dunamai.py:800:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/integration/test_dunamai.py:44: in inner
    _, out = _run_cmd(command, where=where, codes=[expected_code], env=env)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

command = 'fossil init repo'
where = PosixPath('/tmp/pytest-of-marcel/pytest-18/test__version__from_fossil0/dunamai-fossil')
codes = [0], shell = False, env = None

    def _run_cmd(
        command: str,
        where: Optional[Path],
        codes: Sequence[int] = (0,),
        shell: bool = False,
        env: Optional[dict] = None,
    ) -> Tuple[int, str]:
        result = subprocess.run(
            shlex.split(command),
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            cwd=str(where) if where is not None else None,
            shell=shell,
            env=env,
        )
        output = result.stdout.decode().strip()
        if codes and result.returncode not in codes:
>           raise RuntimeError(
                "The command '{}' returned code {}. Output:\n{}".format(
                    command, result.returncode, output
                )
            )
E           RuntimeError: The command 'fossil init repo' returned code 1. Output:
E           cannot locate home directory - please set one of the FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment variables

dunamai/__init__.py:207: RuntimeError

Please note that once I provide home (by setting HOME to /tmp) then test complains with this:

>           raise RuntimeError(
                "The command '{}' returned code {}. Output:\n{}".format(
                    command, result.returncode, output
                )
            )
E           RuntimeError: The command 'fossil init repo' returned code 1. Output:
E           cannot determine user
E           Cannot figure out who you are!  Consider using the --user
E           command line option, setting your USER environment variable,
E           or setting a default user with "fossil user default USER".

So user needs to be provided too. It looks like fossil is too picky and is unable to call getuid() :-). Nomen omen? :-)

mtkennerly added a commit that referenced this issue Feb 9, 2024
@mtkennerly
Copy link
Owner

That's good to know, thanks! I've added a note to CONTRIBUTING.md about this.

@mtelka
Copy link
Author

mtelka commented Feb 9, 2024

Wouldn't it be simpler to simply set HOME in test__version__from_fossil if it is not set already?

@mtkennerly
Copy link
Owner

I guess that's probably fine. It may not always be necessary (e.g., user already ran fossil user default ..., or is on Windows where it's seemingly not required), but it shouldn't hurt anything.

@mtelka
Copy link
Author

mtelka commented Feb 9, 2024

Looking at the patch... will that work when there is no user dunamai in /etc/passwd? Sorry for stupid question, I've zero experience with fossil.

@mtkennerly
Copy link
Owner

I'm assuming Fossil just takes the env var value as-is, but I'm not sure either. Would you mind giving it a test in your setup?

@mtelka
Copy link
Author

mtelka commented Feb 9, 2024

Confirmed: all tests pass with 3cc9be2 without need to set HOME/USER explicitly.

Thank you!

PS1: I think you can remove fossil note from f17bcf2
PS2: I do NOT need new dunamai release with this fix only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants