]> sourceware.org Git - libabigail.git/commit
Fix corpus_diff::has_net_changes for --leaf-changes-only mode
authorGiuliano Procida <gprocida@google.com>
Fri, 17 Jul 2020 12:01:01 +0000 (14:01 +0200)
committerDodji Seketeli <dodji@redhat.com>
Tue, 21 Jul 2020 06:53:19 +0000 (08:53 +0200)
commit697347e4029c6f4bfc933af28618f453913e1d68
tree98c39cd26f1162f788f2e70ca68345173fbae267
parente0d29a919d90a86ace7a3fb30f75c9ff22d413b2
Fix corpus_diff::has_net_changes for --leaf-changes-only mode

This function was not aware of --leaf-changes-only mode.

    - Stats counters for changed variables and types have
      different names in the different modes.
    - Net leaf type changes were not included in leaf mode.

For some inputs, this resulted in abidiff producing an empty report
but returning a non-zero exit status in --leaf-changes-only mode.

For other inputs the combination of both issues still resulted in the
correct return code. This included the following test-abidiff-exit
test cases:

    - test-leaf-peeling
    - test-leaf2
    - test-no-stray-comma

This patch makes corpus_diff::has_net_changes mirror emit_diff_stats,
modulo flags like --non-reachable-types which if absent can still
result in discrepancies between output and return code.

To achieve this in a more maintainable way, the patch introduces a new interface
reporter_base::diff_has_net_changes.  That interface is implemented by
all current reporters.  Each reporter focuses on its own
particularities to provide the required behavious. Then
corpus_diff:has_net_changes just has to invoke
reporter_base::diff_has_net_changes on the reporter that is currently
in used.

The tests below verify that the exit code is zero when all the changes
between the test files are suppressed.

* include/abg-reporter.h ({reporter_base, default_reporter,
leaf_reporter}::diff_has_net_changes): Add new virtual function.
This breaks binary compatibility but should conserve source
compatibility.
* src/abg-default-reporter.cc
(default_reporter::diff_has_net_changes): Define new member
function.
* src/abg-leaf-reporter.cc (leaf_reporter::diff_has_net_changes):
Likewise.
* src/abg-comparison.cc (corpus_diff::has_net_changes): Invoke
reporter_base::diff_has_net_changes on the current reporter,
rather than trying to handle all the different kinds of reporters
here.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Add a
TODO to possibly delegate the implementation of this function to
the reporters.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-net-change-report0.txt:
Normal mode, nothing suppressed.
* tests/data/test-abidiff-exit/test-net-change-report1.txt:
Normal mode, everything suppressed.
* tests/data/test-abidiff-exit/test-net-change-report2.txt:
Leaf mode, nothing suppressed.
* tests/data/test-abidiff-exit/test-net-change-report3.txt:
Leaf mode, everything suppressions.
* tests/data/test-abidiff-exit/test-net-change-v0.c: Test file
* tests/data/test-abidiff-exit/test-net-change-v0.o: Test file
* tests/data/test-abidiff-exit/test-net-change-v1.c: Test file
* tests/data/test-abidiff-exit/test-net-change-v1.o: Test file
* tests/data/test-abidiff-exit/test-net-change.abignore: This
suppresses changes for all variables, functions and types in
the test files, except for the 'victim' function.
* tests/test-abidiff-exit.cc: Run new test cases.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
15 files changed:
include/abg-reporter.h
src/abg-comparison.cc
src/abg-default-reporter.cc
src/abg-leaf-reporter.cc
tests/data/Makefile.am
tests/data/test-abidiff-exit/test-net-change-report0.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change-report1.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change-report2.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change-report3.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change-v0.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change-v0.o [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change-v1.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change-v1.o [new file with mode: 0644]
tests/data/test-abidiff-exit/test-net-change.abignore [new file with mode: 0644]
tests/test-abidiff-exit.cc
This page took 0.033805 seconds and 5 git commands to generate.