Skip to content

Commit 2e237dd

Browse files
authored
test/cfg/runtests.sh: added support for include-what-you-use and integrated it with the CI / some refactoring (danmar#6855)
1 parent 46d9197 commit 2e237dd

File tree

13 files changed

+97
-27
lines changed

13 files changed

+97
-27
lines changed

.github/workflows/iwyu.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
dnf install -y p7zip-plugins # required as fallback for py7zr in Qt installation
8080
dnf install -y python3-pip # fixes missing pip module in jurplel/install-qt-action
8181
dnf install -y python3-devel # fixes building of wheels for jurplel/install-qt-action
82+
dnf install -y cairo-devel gtk3-devel libcurl-devel lua-devel openssl-devel python3-devel sqlite-devel boost-devel cppunit-devel libsigc++20-devel # for strict cfg checks
8283
dnf install -y iwyu
8384
ln -s iwyu_tool.py /usr/bin/iwyu_tool
8485
@@ -150,6 +151,16 @@ jobs:
150151
# TODO: remove -stdlib= - it should have been taken from the compilation database
151152
iwyu_tool -p cmake.output -j $(nproc) -- -w -Xiwyu --max_line_length=1024 -Xiwyu --comment_style=long -Xiwyu --quoted_includes_first -Xiwyu --update_comments -stdlib=${{ matrix.stdlib }} ${{ matrix.mapping_file_opt }} ${{ matrix.clang_inc }} > iwyu.log
152153
154+
# TODO: run with all configurations
155+
- name: test/cfg
156+
if: matrix.stdlib == 'libstdc++'
157+
run: |
158+
# TODO: redirect to log
159+
./test/cfg/runtests.sh
160+
env:
161+
IWYU: include-what-you-use
162+
IWYU_CLANG_INC: ${{ matrix.clang_inc }}
163+
153164
- uses: actions/upload-artifact@v4
154165
if: success() || failure()
155166
with:

test/cfg/boost.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99

1010
// cppcheck-suppress-file valueFlowBailout
1111

12-
#include <boost/config.hpp>
12+
#include <cstdio>
13+
#include <new>
14+
#include <tuple>
15+
16+
#include <boost/config.hpp> // IWYU pragma: keep
1317
#include <boost/math/special_functions/round.hpp>
14-
#include <boost/endian/conversion.hpp>
18+
#include <boost/endian/conversion.hpp> // IWYU pragma: keep
1519
#include <boost/bind/bind.hpp>
16-
#include <boost/function.hpp>
20+
#include <boost/function.hpp> // IWYU pragma: keep
1721
#include <boost/smart_ptr/scoped_array.hpp>
18-
#include <boost/thread/mutex.hpp>
22+
#include <boost/thread/mutex.hpp> // IWYU pragma: keep
1923
#include <boost/thread/lock_guard.hpp>
20-
#include <boost/test/unit_test.hpp>
24+
#include <boost/test/unit_test.hpp> // IWYU pragma: keep
2125
#include <boost/core/scoped_enum.hpp>
2226
#include <boost/foreach.hpp>
2327

test/cfg/cppunit.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
// cppcheck-suppress-file valueFlowBailout
1010

11+
#include <string>
12+
13+
#include <cppunit/Exception.h>
14+
#include <cppunit/Portability.h>
1115
#include <cppunit/TestAssert.h>
1216

1317
void cppunit_assert_equal(int x, double y)

test/cfg/gnu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <stdint.h>
1717
#include <stdio.h>
1818
#include <stdarg.h>
19-
#include <netdb.h>
20-
#include <sys/time.h>
2119
#include <sys/types.h>
2220
#include <pwd.h>
2321
#include <sys/mman.h>
@@ -36,7 +34,11 @@
3634
#include <netdb.h>
3735
#if !defined(__APPLE__)
3836
#include <byteswap.h>
37+
#include <features.h>
3938
#endif
39+
#include <sys/socket.h>
40+
#include <time.h>
41+
#include <stddef.h>
4042

4143
#ifdef __gnu_linux__
4244
void unreachableCode_error(void) // #11197

test/cfg/gtk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
88
//
99

10-
#include <stdlib.h>
11-
#include <gtk/gtk.h>
10+
#include <stdio.h>
1211
#include <glib.h>
12+
#include <glib/gtypes.h>
1313
#include <glib/gi18n.h>
1414

1515

test/cfg/libsigc++.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
88
//
99

10-
#include <sigc++/sigc++.h>
10+
#include <sigc++/sigc++.h> // IWYU pragma: keep
11+
#include <sigc++/functors/mem_fun.h>
12+
#include <sigc++/functors/slot.h>
13+
#include <sigc++/trackable.h>
1114

1215
struct struct1 : public sigc::trackable {
1316
void func1(int) const {}

test/cfg/openssl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
88
//
99

10-
#include <openssl/ssl.h>
1110
#include <openssl/bio.h>
11+
#include <openssl/evp.h>
12+
//#include <openssl/types.h>
13+
#include <stdio.h>
1214
#include <string.h>
1315

1416
void valid_code(BIO * bio)

test/cfg/posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <stdarg.h>
3434
#include <ctype.h>
3535
#include <stdbool.h>
36-
#include <time.h>
3736
#include <string.h>
3837
#include <strings.h>
3938
#if defined(__APPLE__)
@@ -47,6 +46,7 @@
4746
#include <wchar.h>
4847
#include <sys/stat.h>
4948
#include <utime.h>
49+
#include <stddef.h>
5050

5151

5252
#if !defined(__APPLE__)

test/cfg/python.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define PY_SSIZE_T_CLEAN
1111
#include <Python.h> // should be the first include
1212
#include <stdio.h>
13+
#include <stdlib.h>
1314

1415
void validCode(PyObject * pPyObjArg)
1516
{

test/cfg/qt.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <QStack>
1616
#include <QByteArray>
1717
#include <QList>
18-
#include <QLinkedList>
1918
#include <QMap>
2019
#include <QMultiMap>
2120
#include <QQueue>
@@ -34,6 +33,11 @@
3433
#include <QRegion>
3534
#include <QTransform>
3635

36+
// TODO: this is actually avilable via Core5Compat but I could not get it to work with pkg-config
37+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
38+
#include <QLinkedList>
39+
#endif
40+
3741
#include <cstdio>
3842

3943
int ignoredReturnValue_QSize_height(const QSize &s)
@@ -323,6 +327,7 @@ QList<int>::iterator QList3()
323327
return it;
324328
}
325329

330+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
326331
void QLinkedList1()
327332
{
328333
// cppcheck-suppress unreadVariable
@@ -359,6 +364,7 @@ QLinkedList<int>::iterator QLinkedList3()
359364
// cppcheck-suppress returnDanglingLifetime
360365
return it;
361366
}
367+
#endif
362368

363369
void QStringList1(QStringList stringlistArg)
364370
{
@@ -569,11 +575,13 @@ void MacroTest2_test()
569575
QByteArray ba = str.toLatin1();
570576
printf(ba.data());
571577

578+
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
572579
#ifndef QT_NO_DEPRECATED
573580
str = MacroTest2::trUtf8("test2");
574581
ba = str.toLatin1();
575582
printf(ba.data());
576583
#endif
584+
#endif
577585
}
578586

579587
void MacroTest3()
@@ -617,7 +625,7 @@ void validCode(int * pIntPtr, QString & qstrArg, double d)
617625
if (qstr1.length() == 1) {}
618626
}
619627
if (qstr1.length() == 1) {} else {
620-
qstr1.remove(1);
628+
qstr1.remove(1, 0);
621629
if (qstr1.length() == 1) {}
622630
}
623631
}

0 commit comments

Comments
 (0)