Bug 1134397 - RFE: %check-only requirements specification
Summary: RFE: %check-only requirements specification
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1394870 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-27 12:56 UTC by Pavel Raiskup
Modified: 2018-06-21 08:43 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)

Description Pavel Raiskup 2014-08-27 12:56:17 UTC
I am fairly sure that this was here before, sorry if that is the case.  But
something like 'CheckRequires:' or 'CheckBuildRequires:' would be nice to
have.  Such feature would allow 'rpmbuild --nocheck' not checking for %check
only requirements;  and it would speed up my workflow sometimes.

Also, that would make the new architecture bootstrapping easier probably --
failing just because of %check, because particular arch does not have some
%check requirement (yet) is not nice and results to a lot of respins.

As a complement RFE:  Please pollute the macro environment with some macro
saying that the --nocheck was (was not) passed.  Something like
%check_enabled equal to 0/1.

Comment 1 Pavel Raiskup 2016-10-05 04:57:18 UTC
Taskotron related discusses something like TestRequires, too:
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/FUWLJQYQJAGNGSSFTCA3ZEHAX43LJ7UU/

Comment 2 Jason Tibbitts 2016-10-05 21:25:39 UTC
This is a good idea and I'd definitely support such a change, but an issue should probably be filed upstream with RPM.

Comment 3 Igor Gnatenko 2016-10-06 06:31:23 UTC
(In reply to Jason Tibbitts from comment #2)
> This is a good idea and I'd definitely support such a change, but an issue
> should probably be filed upstream with RPM.
Unfortunately this IS RPM upstream.

anyhow I was trying to check if --nocheck defines some macro... Unfortunately I was not able to find that.

Comment 4 Panu Matilainen 2016-10-06 06:56:29 UTC
It doesn't. I remember committing the change (see bug 756531) and thinking "meh" because this is trivial to implement in specs without help from rpm (bcond with/without check) and that's how almost every spec does it already. OTOH the --nocheck and --noclean options are consistent with the other --nofoo options of rpmbuild so it's hard to argue against them either.

The de-facto way to do this in specs is:
---
# add option to build without check
%bcond_without check

%if {with check}
BuildRequires: foo
BuildRequires:  bar
%endif

[...]

%check
%if %{with check}
make test
%endif
---

It'd be nice to have --nocheck (and ditto for all the other sections) integrate with that, without breaking existing spec expectations.

Comment 5 Panu Matilainen 2016-11-15 07:30:24 UTC
*** Bug 1394870 has been marked as a duplicate of this bug. ***

Comment 6 Stephen Gallagher 2016-11-15 13:02:35 UTC
Just to note: the Base Runtime team would like to request that the priority on this be increased, as it's going to be important for our modularity efforts. (Right now, the buildroot for self-hosting the base runtime is enormous, in many cases much larger than it strictly needs to be due to pulling in test dependencies.)

Comment 7 Panu Matilainen 2016-11-15 14:55:14 UTC
Well, like pointed out in comment #4 you don't actually need anything new from rpm to achieve this, it's all doable with any old rpm from the last ~12 years.

An actual BuildRequires(check) implementation would break spec compatibility and be more complicated than what works already, so when the goal can already be trivially achieved it seems like nothing but colossal waste of time. If anything is to be done in rpm wrt this, it's likely just standardizing the "%bcond_with/without check" idiom.

Fedora has packaging standards for far stranger items. I'd suggest poking FPC to define the existing de-facto standard as an actual standard and update packages where necessary.

Comment 8 Jason Tibbitts 2016-11-15 16:49:23 UTC
If we're going to standardize on that (which is fine with me), then:

Can we hook the beginning of %check to exit automatically so that --nocheck just starts working on every spec (to at least not run the %check section)?  It should be possible to just emit "echo Skipping check because --nocheck was specified; exit 0" conditionally in %__spec_check_pre, shouldn't it?  Could also play with %__spec_check_shell or %__spec_check_template.  Which would be better?

A %checkonly macro which evaluates to its contents or nothing depending on the context would at least make one-liner buildrequires shorter than wrapping in %if/%endif:

%checkonly BuildRequires: foo bar

That's pretty easy to do and I can cook it up but I figured since Panu is listening I'd toss it out in case there's some corner case I'm missing which gets in the way of doing that kind of thing.

Comment 9 Jason Tibbitts 2016-11-15 16:52:53 UTC
Oh, and as item 0 on the list above, can't we just do the equivalent of %bcond_without check by default in redhat-rpm-config?  I've never been absolutely clear on just how those things actually work, but looking at the definitions, it's.... pretty trivial.  But again, just asking in case there's something I'm missing.

Comment 10 Igor Gnatenko 2016-11-15 16:56:55 UTC
I think BuildRequires(check) makes sense.

Comment 11 Pavel Raiskup 2016-11-16 07:08:20 UTC
I must say...  I'm now pretty confident that '--without check' is
sufficient for almost everybody (nobody claimed this is not truth).
Having 'CheckRequires:' or 'BuildRequires(build,check,...)' would make it
more "declarative" and more pretty (to me, so I'd like to have it some
day) but I don't think we should feel blocked by such feature request.

I originally wanted to "fix" '--nocheck' option (because installing
something just because %check needs it is useless if --nocheck is passed),
but now I see that '--nocheck' is pretty new and gives false promises:
There are lot of packages running testsuite in %build, simply because it
is impossible to run the testsuite properly in %check.  And this makes
%check and --nocheck pretty useless (from global, distribution POV).
And for bootstrapping the distribution, we need a more ultimate answer
(standard/guideline) to resolve this.

Note both '--without check' and '--nocheck' are now supported by both
'mock' and 'rpm'.  But '--without check' should work for everybody.

'--nocheck' could imply '--without check' and vice versa, but that sounds
like brittle thing, and people using one or both could experience
compatibility issues...

* Shouldn't we document in 'man rpmbuild' that --nocheck is just for
  testing purposes (not a production packager's tool), and that --with
  check is preferred?

* Mock says about --nocheck:  "pass --nocheck to rpmbuild to skip 'make
  check' tests", that should say "skip %check phase", makes sense?  I'll
  send a patch then.

* Can we standardize '%if %{with check}' (or %{with runtests} so it
  doesn't have a relation with %check) and have '%bcond_without check'
  defined _by default_?  And fix guidelines?

* We could think about nicer syntax for
  %if %{with check}
  BuildRequires: foo
  %endif

Comment 12 Panu Matilainen 2016-11-16 07:51:40 UTC
I'm not committing to any particular details here on rpm-side because I haven't thought about it that deeply, except that whatever (if anything) is done must play nice with the "with/without check" idiom. That would mean making --nocheck and --without check more or less aliases for eachother, and %check must be skipped by either whether the spec supports it or not. And this is specifically about %check section, so don't go inventing any new names for it. Note that the concept is easily expandaple to other sections, eg --noclean vs --without clean, and perhaps others too (as an alternative means of implementing short-circuit etc). Whether that will be done is another topic...

My point in outlining this is that you dont need to wait for rpm to implement anything at all, just use the with/without check system (packages WILL need changes to implement those check-only dependencies anyway, no matter what the syntax) and FWIW you have my word that rpm will play nice with it.

BTW, for a one-liner syntax you can also use
%{?with_check: BuildRequires: foo bar zoo >= 4.3}

It might not be very pretty but I'd rather not have any magic macros to obfuscate the fact that its fundamentally just a %bcond macro. Me, I find this far more readable even if it takes two more lines:
%if %{with check}
BuildRequires: foo
%endif


Note You need to log in before you can comment on or make changes to this bug.