#661 Formalize/standardize %check-optional packaging
Opened 5 years ago by tibbs. Modified 4 years ago

There's an existing idiom for skipping checks which some packages use. Basically you add the following bits in the right places:

%bcond_without check

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


%if %{with check}
make test

Then you call rpmbuild with --nocheck and things work as expected. (I guess that internally --nocheck does some popt magic so that internally it's equivalent to passing "--without check".) That wouldn't matter much to us, except that as part of the modularization effort (whatever that is) the buildsystem will be growing the ability to pass --nocheck. The idea is to reduce the minimal set of packages required to build the minimal set of packages, which means excluding (for some initial build pass) things needed only for running test suites. (Eventually documentation, too, but that's a separate thing.)

The idea is to formalize the way packagers make use of what RPM provides when --nocheck is passed, and if possible to simplify that.

Some additional info is in https://bugzilla.redhat.com/show_bug.cgi?id=1134397

I propose:

  1. We do the equivalent "%bcond_without check" directly in redhat-rpm-config. %bcond_without just does
%{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}

so we can just conditionally set "%with_check 1" directly.

  1. We modify the "spec_check_pre" macro (which has two underscores that trac will eat) to have
%{_without_check:echo "Skipping checks due to --nocheck.";exit 0}

(or whatever syntax works).

  1. We add a couple of convenience macros: %checkonly which evaluates to nothing if --nocheck was passed and to its arguments otherwise, and %ifcheck which does the same as %if %{with check}.

  2. I write up a draft adding a couple of paragraphs showing how this is all used.

The first just removes the need for packagers to add the %bcond_without line; it will always be there.

The second basically makes every %check in the system subject to --nocheck, which can be pretty useful in some situations. (I do a lot of mass builds, and it would save me a lot of time to be able to skip checks where appropriate, for example.)

The third just reduces line noise for packagers, letting you turn:

%if %{with check}
BuildRequires: foo bar

into either

%checkonly BuildRequires: foo bar


BuildRequires: foo bar

though I guess the latter one might not be worth it.

Anyway, these can technically be considered separately, but I think that regardless of any simplifications we make, we still need to tell people how to use whatever is implemented so that we don't have people doing random things. This stuff is going to start to work its way into more packages because of "modularization" so it would be good to get ahead of it.

We discussed this at this weeks meeting (http://meetbot.fedoraproject.org/fedora-meeting-1/2016-12-08/fpc.2016-12-08-17.00.txt):

Metadata Update from @james:
- Issue assigned to tibbs

5 years ago

Metadata Update from @tibbs:
- Issue close_status updated to: None
- Issue tagged with: committee

5 years ago

As the oldest untouched ticket, and since we have new committee members, I think it may be useful to dust this one off a bit.

To be honest, I can't remember all of the details and have to page it back in, but since @ignatenkobrain has more experience with RPM internals than I do, I thought he might have some ideas for how we can either leverage what RPM does when --nocheck is passed, or maybe standardize on --without check and redefine %__spec_check_pre to just exit 0 when that is passed. I know he commented in the bugzilla ticket related to this (which was https://bugzilla.redhat.com/show_bug.cgi?id=1134397).

I'll also edit the original ticket message to use pagure-style formatting so it's easier to read.

So maybe instead of hoping that rpm upstream does something, we just formalize --without check? I think other distros have done the same thing, and really all you need is a conditional exit 0 in %__spec_check_pre.

Login to comment on this ticket.