[Rpm-maint] [rpm-software-management/rpm] Test a macro from a macro file that contains %ifxxx - %endif (#640)

Panu Matilainen notifications at github.com
Mon Mar 11 16:21:36 UTC 2019


To recap what was discussed on irc - simplify the test a bit:
- the macros can be defined in the spec directly
- put the mymacro expansions on separate lines like they would be in real world use (the %if's needs to be at beginning of line to work anyway) and then test and the output will be that much more readable
- no need to build, just use ```rpmspec -q --qf "%{description}\n" iftest.spec```

Then there's the issue of what it actually tries to test and what it expects - this is not really an expected failure but expected behavior, very similarly to how macros expanding in comments is. Normally you hardly notice it, but if there's a %define/%global in there... 

In these cases, the %if-%endif *are* processed as expected, but since the expansion (including the %global) occurs first, what the spec parser actually sees is just an empty %if-%endif. If we're adding such a test I think it then makes sense to observe the other behavior too, for example:

```
%define mymacro0 \
%if 0  \
%global bbb0 ccc0\
Summary: macro 0\
%endif \
%{nil}

%define mymacro1 \
%if 1  \
%global bbb1 ccc1 \
Summary: macro 1\
%endif
%{nil}

Name:           iftest
Version:        1.0
Release:        1
Group:          Testing
License:        GPL
BuildArch:      noarch

%mymacro0
%mymacro1

%description
%bbb0
%bbb1
```

...in which case you get:
```
rpmspec -q --qf "%{summary}\n%{description}\n" ~/rpmbuild/SPECS/iftest.spec 
macro 1
ccc0
ccc1
```
...and that is actually the expected outcome of the existing implementation, as weird as it is.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/640#issuecomment-471612286
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20190311/933a23fd/attachment.html>


More information about the Rpm-maint mailing list