Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 894502 - dev-vcs/pre-commit-3.0.4 fails tests if previously installed: AssertionError: assert Executable git not found == pre-commit not found Did you forget to activate your virtualenv?
Summary: dev-vcs/pre-commit-3.0.4 fails tests if previously installed: AssertionError:...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Marek Szuba (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-15 07:44 UTC by Agostino Sarubbo
Modified: 2023-11-09 00:03 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,129.46 KB, text/plain)
2023-02-15 07:44 UTC, Agostino Sarubbo
Details
1-test.log (1-test.log,44 bytes, text/plain)
2023-02-15 07:44 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2023-02-15 07:44:31 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: dev-vcs/pre-commit-3.0.4 fails tests (HARDENED-SYSTEM).
Discovered on: amd64 (internal ref: hardened_tinderbox)

NOTE:
(HARDENED-SYSTEM) in the summary means that the bug was found on a machine that runs an hardened profile with -D_FORTIFY_SOURCE=3 and -D_GLIBCXX_ASSERTIONS (https://www.gentoo.org/support/news-items/2023-01-01-hardening-fortify-assertions.html) but this bug MAY or MAY NOT BE related to the changes related to hardened.
Comment 1 Agostino Sarubbo gentoo-dev 2023-02-15 07:44:33 UTC
Created attachment 851174 [details]
build.log

build log and emerge --info
Comment 2 Agostino Sarubbo gentoo-dev 2023-02-15 07:44:34 UTC
Created attachment 851176 [details]
1-test.log

1-test.log
Comment 3 Agostino Sarubbo gentoo-dev 2023-02-15 07:44:34 UTC
Error(s) that match a know pattern in addition to what has been reported in the summary:


'
E           AssertionError: assert 'Executable `git` not found' == '`pre-commit` not found.  Did you forget to activate your virtualenv?
FAILED tests/commands/install_uninstall_test.py::test_environment_not_sourced
FAILED tests/commands/install_uninstall_test.py::test_installed_from_venv - a...
Comment 4 Marek Szuba (RETIRED) archtester gentoo-dev 2023-10-25 22:24:02 UTC
Is this still a problem with 3.3.3, and if so could you confirm:
 - that the executable 'git' is actually present on the file system, and
 - if it is, that the directory containing it is in PATH?
Comment 5 Alfred Wingate 2023-11-05 18:36:06 UTC
This is a problem in 3.5.0. 

It appears to be case of https://github.com/pre-commit/pre-commit/blob/14169eb31db6a0ac3e4dfbc38234a8a3e90bc6c1/tests/commands/install_uninstall_test.py#L248 removing /usr/bin instead of the venv part. This would be triggered if pre-commit was installed already.

Even if "fixed" it would cause the test to fail if pre-commit is already installed as its supposed to tests that pre-commit isn't path.
Comment 6 Larry the Git Cow gentoo-dev 2023-11-06 15:00:55 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2d2264f3830c1c14acd266a00577be7a86020723

commit 2d2264f3830c1c14acd266a00577be7a86020723
Author:     Marek Szuba <marecki@gentoo.org>
AuthorDate: 2023-11-06 11:36:41 +0000
Commit:     Marek Szuba <marecki@gentoo.org>
CommitDate: 2023-11-06 15:00:45 +0000

    dev-vcs/pre-commit: deselect tests that fail if pre-commit is installed
    
    On the one hand quite a few bits of pre-commit rely on the executable
    "git" being present in PATH, on the other the tests delete the directory
    containing "pre-commit" from PATH prior to executing. If both reside in
    /usr/bin, hilarity ensues.
    
    Just deselect these tests, they aren't directly relevant to packaged
    pre-commit anyway.
    
    Thanks-to: Alfred Wingate <parona@protonmail.com>
    Closes: https://bugs.gentoo.org/894502
    Signed-off-by: Marek Szuba <marecki@gentoo.org>

 dev-vcs/pre-commit/pre-commit-3.3.3.ebuild | 13 ++++++++-----
 dev-vcs/pre-commit/pre-commit-3.5.0.ebuild | 13 ++++++++-----
 2 files changed, 16 insertions(+), 10 deletions(-)
Comment 7 Marek Szuba (RETIRED) archtester gentoo-dev 2023-11-06 15:09:20 UTC
Thank you very much for having figured this out, I must say this issue had me rather stumped - mostly because I do all my package development on a clean system! I have just pulled the relevant bits out of your PR, the py3.12 stuff has been left alone because it both is beyond the scope of this issue and involves another maintainer.

Could you possibly report this problem upstream as well, so that they could try to actually fix it?
Comment 8 Alfred Wingate 2023-11-09 00:03:50 UTC
I don't think reporting it is going to be useful, upstream has gone through it before and the advice was to skip it as the test isn't useful from the context of a system wide install.

https://github.com/pre-commit/pre-commit/issues/1235#issuecomment-562868123

The big problem is that it failing is really caused by how gentoo installs it (and the fact it can be tested after its already installed) so upstream real has no incentive to completely rethink their tests to accommodate this edge case.

Fedora went through this at one point as well https://github.com/pre-commit/pre-commit/issues/1183#issuecomment-545103220