Martin Delille
Martin Delille

Reputation: 11780

Some code is not removed from the code coverage

I want to generate a code coverage report for my Qt/C++ project.

I have a short version with a class inheriting QObject:

#include <QObject>

class Baba : public QObject {
    Q_OBJECT

public:
    Baba();

    void mange(int a);

signals:
    void pouet();
};

I first add this compilation flag:

QMAKE_CXXFLAGS += --coverage
QMAKE_LFLAGS += --coverage

After executing my tests, I perform the following step:

$ gcov main.cpp
$ lcov --capture --directory . --output-file capture.info
$ lcov --remove capture.info "*Qt*.framework*" "*.h" "*Xcode.app*" "*moc_*" --output-file filtered.info
$ genhtml filtered.info --output-directory out 

Unfortunately I still have coverage for the file moc_Baba.cpp despite I added "*moc_*" during the remove step.

What am I missing?

Upvotes: 2

Views: 300

Answers (1)

Martin Delille
Martin Delille

Reputation: 11780

After inspecting the lcov source code, I manage to remove the moc_* files by replacing "*moc_*" by "$$OUT_PWD/moc_*".

Upvotes: 2

Related Questions