extras: ci: ignore vlc_qrc.cpp coverage

When parsing the coverage with the Qt module enabled, gcovr was failing
to parse the output for qt5-vlc_qrc.cpp, leading to the following error.

    $ gcovr -r build-meson --json gcovr.cov.json                                                      130 ↵
    (INFO) Reading coverage data...
    (WARNING) Unrecognized GCOV output for /home/alexandre/workspace/videolabs/vlc-master/build-meson/modules/gui/qt/qt5-vlc_qrc.cpp
                    37:60736-block  0
                    37:60751-block  0
                    37:60759-block  0
                    37:60767-block  0
                    37:60768-block  0
            This is indicative of a gcov output parse error.
            Please report this to the gcovr developers
            at <https://github.com/gcovr/gcovr/issues>.
    (WARNING) Exception during parsing:
            UnknownLineType:        37:60736-block  0
    (WARNING) Exception during parsing:
            UnknownLineType:        37:60751-block  0
    (WARNING) Exception during parsing:
            UnknownLineType:        37:60759-block  0
    (WARNING) Exception during parsing:
            UnknownLineType:        37:60767-block  0
    (WARNING) Exception during parsing:
            UnknownLineType:        37:60768-block  0
    (ERROR) Exiting because of parse errors.
            You can run gcovr with --gcov-ignore-parse-errors
            to continue anyway.
    (ERROR) Trouble processing 'vlc/build-meson/modules/libqt_plugin.so.p/meson-generated_.._gui_qt_qt5-vlc_qrc.cpp.gcda' with working directory '/home/alexandre/workspace/videolabs/vlc-master/build-meson'.
    Stdout of gcov was >>File 'modules/gui/qt/qt5-vlc_qrc.cpp'
    Lines executed:100.00% of 13
    No branches
    Calls executed:100.00% of 5
    Creating 'qt5-vlc_qrc.cpp##1ea0d75896cd542c555451d8b8bb4a44.gcov'

Previously, it was trying to merge lines and triggered a negative hit,
leading to the introduction of the gcovr parameter:
--gcov-ignore-parse-errors=negative_hits.warn_once_per_file.

    (INFO) - MainThread - Reading coverage data...
    (WARNING) - Thread-29 (worker) - Unrecognized GCOV output for /builds/alexandre-janniaux/vlc/modules/codec/subsdec.c
              branch  2 taken -1 (fallthrough)
            This is indicative of a gcov output parse error.
            Please report this to the gcovr developers
            at <https://github.com/gcovr/gcovr/issues>.
    (WARNING) - Thread-29 (worker) - Exception during parsing:
            NegativeHits: Got negative hit value in gcov line 'branch  2 taken -1 (fallthrough)' caused by a bug in gcov tool, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080. Use option --gcov-ignore-parse-errors with a value of negative_hits.warn, or negative_hits.warn_once_per_file.
    (ERROR) - Thread-29 (worker) - Exiting because of parse errors.
            You can run gcovr with --gcov-ignore-parse-errors
            to continue anyway.

This option seems to still be needed since it is impacted by how
coverage is computed by GCC.

Issue #28490 also mentioned the following assertion:

    AssertionError: Got function MainUI::getComponent() const on multiple lines: 26, 27.
            You can run gcovr with --merge-mode-functions=MERGE_MODE.
            The available values for MERGE_MODE are described in the documentation.

This assertion was due to --merge-mode-functions[^1] not being accounted,
which it now does in gcovr 7.0[^2], and files using Q_OBJECT and the MOC
code generator, duplicating some inline functions from headers.

    class MainUI : public QObject {
        Q_OBJECT
    public:
        /* The line below duplicates a function definition at two different
         * locations because of MOC. */
        inline QQmlComponent* getComponent() const {return m_component;}

We don't need this file to have its coverage checked since it's
generated from an XML file, so let's just ignore it from the coverage
entirely.

[^1]: https://github.com/gcovr/gcovr/pull/700
[^2]: https://github.com/gcovr/gcovr/pull/844

Fixes #28533 #28490
This commit is contained in:
Alexandre Janniaux 2024-02-20 10:17:15 +01:00 committed by Felix Paul Kühne
parent 4a0b1e06de
commit d58a95d8fb
1 changed files with 4 additions and 1 deletions

View File

@ -362,7 +362,10 @@ debian-meson:
- |
# We split in two different commands to handle the case where
# the coverage will be generated on different jobs later.
gcovr -r "${CI_PROJECT_DIR}/" --json "${CI_PROJECT_DIR}/${CI_JOB_NAME}.cov.json" -j$NCPU --gcov-ignore-parse-errors=negative_hits.warn_once_per_file
# Note: qt5-vlc_qrc.cpp needs to be remove from the report since its
# coverage should not be checked. It leads to gcovr having trouble
# parsing the coverage otherwise.
gcovr -r "${CI_PROJECT_DIR}/" --json "${CI_PROJECT_DIR}/${CI_JOB_NAME}.cov.json" -j$NCPU --gcov-ignore-parse-errors=negative_hits.warn_once_per_file --exclude build-meson/modules/gui/qt/qt5-vlc_qrc.cpp
- mkdir html-coverage
- >