Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 518768 - Default src_test should additionally pass -i (--ignore-errors) to make -n when detecting supported test targets
Summary: Default src_test should additionally pass -i (--ignore-errors) to make -n whe...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-01 22:40 UTC by Maciej Mrozowski
Modified: 2025-05-08 07:46 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Mrozowski gentoo-dev 2014-08-01 22:40:49 UTC
Issue that was discovered with bug 499580.

PMS does not provide reference default_src_test implementation, stating just:
"The default implementation used when the ebuild lacks the src_test function must, if tests are enabled, run emake check if and only if such a target is available, or if not run emake test if and only if such a target is available. In both cases, if emake returns non-zero the build must be aborted."

It doesn't say specifically how to check "if such target is available".
Existing eapi0 implementation in Portage for that likely comes from bug 350404.
It invokes:
make -n <target_to_check>

Bug 499580 discovered that sometimes running make in 'dry run' mode is not enough.
And indeed 'make' manual page says:

"  -n, --just-print, --dry-run, --recon
            Print the commands that would be executed, but do not execute them (except in certain circumstances).
"

Please note the "except in certain circumstances".
As adding -i seems to make -n work really in 'dry run', I propose to fix default src_test in portage accordingly.

@ulm
Is it worth worth adding reference default src_test in PMS?
Comment 1 Ulrich Müller gentoo-dev 2014-08-02 05:39:40 UTC
(In reply to Maciej Mrozowski from comment #0)
> @ulm
> Is it worth worth adding reference default src_test in PMS?

CCing PMS team. Any opinion?
Comment 2 Ulrich Müller gentoo-dev 2022-10-20 07:46:57 UTC
(In reply to Maciej Mrozowski from comment #0)
> PMS does not provide reference default_src_test implementation, stating just:
> "The default implementation used when the ebuild lacks the src_test function
> must, if tests are enabled, run emake check if and only if such a target is
> available, or if not run emake test if and only if such a target is
> available. In both cases, if emake returns non-zero the build must be
> aborted."

That seems pretty clear. Check if the target is available, but otherwise don't care what it does. Passing -i looks like the right thing to do.

> @ulm
> Is it worth worth adding reference default src_test in PMS?

Turning the argument around, if we had reference code there then most likely it would say "make -n" which maybe isn't correct. So having it only as a textual description is just fine.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-05-07 21:23:12 UTC
(In reply to Ulrich Müller from comment #2)
> That seems pretty clear. Check if the target is available, but otherwise
> don't care what it does. Passing -i looks like the right thing to do.

I'm going to test changing Portage to -i, given bug 955595.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2025-05-07 21:30:17 UTC
(In reply to Sam James from comment #3)
> (In reply to Ulrich Müller from comment #2)
> > That seems pretty clear. Check if the target is available, but otherwise
> > don't care what it does. Passing -i looks like the right thing to do.
> 
> I'm going to test changing Portage to -i, given bug 955595.

Or, rather, -i -n.
Comment 5 Eli Schwartz gentoo-dev 2025-05-08 07:46:13 UTC
I object to using -i, it "ignores errors" but if you're actually running commands then the results of those commands seem unspecified and could leave your build tree in an inconsistent state.


The bash-completion project has to solve the same issue: detect if targets exist, so they can be offered as tab completions. They run this command:


make -npq .DEFAULT

As no ".DEFAULT" target ever exists, no commands can ever run (but -n and -q provide extra assurance).

Due to -p, a dump of rules / targets is emitted. This is then parsed by /usr/share/bash-completion/helpers/make-extract-targets.awk to get a list of targets.

We could do something similar, to check for targets named "check" and "test".