Skip to content

Commit 347ddd8

Browse files
committed
properly guard {Process|Thread}Executor implementations
1 parent 21163e8 commit 347ddd8

File tree

8 files changed

+39
-9
lines changed

8 files changed

+39
-9
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,12 @@ jobs:
571571
warnings="-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar"
572572
g++ $warnings -c -Ilib -Iexternals/tinyxml2 democlient/democlient.cpp
573573
574+
- name: Test disabled executors
575+
if: matrix.os == 'ubuntu-22.04'
576+
run: |
577+
g++ -Ilib -c cli/threadexecutor.cpp -DDISALLOW_THREAD_EXECUTOR
578+
test -z "$(nm threadexecutor.o)"
579+
574580
- name: Show all ignored files
575581
if: false # TODO: currently lists all the contents of ignored folders - we only need what actually matched
576582
run: |

cli/processexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "processexecutor.h"
2424

25-
#if !defined(_WIN32) && !defined(__MINGW32__)
25+
#ifdef HAS_THREADING_MODEL_FORK
2626

2727
#include "cppcheck.h"
2828
#include "errorlogger.h"

cli/processexecutor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#ifndef PROCESSEXECUTOR_H
2020
#define PROCESSEXECUTOR_H
2121

22+
#include "config.h"
23+
24+
#ifdef HAS_THREADING_MODEL_FORK
25+
2226
#include "cppcheck.h"
2327
#include "executor.h"
2428

@@ -72,4 +76,6 @@ class ProcessExecutor : public Executor {
7276

7377
/// @}
7478

79+
#endif // HAS_THREADING_MODEL_FORK
80+
7581
#endif // PROCESSEXECUTOR_H

cli/threadexecutor.cpp

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

1919
#include "threadexecutor.h"
2020

21+
#ifdef HAS_THREADING_MODEL_THREAD
22+
2123
#include "config.h"
2224
#include "cppcheck.h"
2325
#include "errorlogger.h"
@@ -219,3 +221,5 @@ unsigned int ThreadExecutor::check()
219221

220222
return result;
221223
}
224+
225+
#endif // HAS_THREADING_MODEL_THREAD

cli/threadexecutor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#ifndef THREADEXECUTOR_H
2020
#define THREADEXECUTOR_H
2121

22+
#include "config.h"
23+
24+
#ifdef HAS_THREADING_MODEL_THREAD
25+
2226
#include "cppcheck.h"
2327
#include "executor.h"
2428

@@ -52,4 +56,6 @@ class ThreadExecutor : public Executor {
5256

5357
/// @}
5458

59+
#endif // HAS_THREADING_MODEL_THREAD
60+
5561
#endif // THREADEXECUTOR_H

test/testprocessexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ class TestProcessExecutorBase : public TestFixture {
112112
}
113113

114114
void run() override {
115-
#if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
116115
mNewTemplate = true;
116+
#ifdef HAS_THREADING_MODEL_FORK
117117
TEST_CASE(deadlock_with_many_errors);
118118
TEST_CASE(many_threads);
119119
TEST_CASE(many_threads_showtime);
@@ -130,7 +130,7 @@ class TestProcessExecutorBase : public TestFixture {
130130
TEST_CASE(showtime_file_total);
131131
TEST_CASE(suppress_error_library);
132132
TEST_CASE(unique_errors);
133-
#endif // !WIN32
133+
#endif // HAS_THREADING_MODEL_FORK
134134
}
135135

136136
void deadlock_with_many_errors() {

test/testsuppressions.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ class TestSuppressions : public TestFixture {
5858
TEST_CASE(suppressionsFileNameWithExtraPath);
5959
TEST_CASE(suppressionsSettingsFiles);
6060
TEST_CASE(suppressionsSettingsFS);
61+
#ifdef HAS_THREADING_MODEL_THREAD
6162
TEST_CASE(suppressionsSettingsThreadsFiles);
6263
TEST_CASE(suppressionsSettingsThreadsFS);
63-
#if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
64+
#endif // HAS_THREADING_MODEL_THREAD
65+
#ifdef HAS_THREADING_MODEL_FORK
6466
TEST_CASE(suppressionsSettingsProcessesFiles);
6567
TEST_CASE(suppressionsSettingsProcessesFS);
66-
#endif
68+
#endif // HAS_THREADING_MODEL_FORK
6769
TEST_CASE(suppressionsMultiFileFiles);
6870
TEST_CASE(suppressionsMultiFileFS);
6971
TEST_CASE(suppressionsPathSeparator);
@@ -294,6 +296,7 @@ class TestSuppressions : public TestFixture {
294296
return exitCode;
295297
}
296298

299+
#ifdef HAS_THREADING_MODEL_THREAD
297300
unsigned int checkSuppressionThreadsFiles(const char code[], const std::string &suppression = "") {
298301
return _checkSuppressionThreads(code, false, suppression);
299302
}
@@ -341,8 +344,9 @@ class TestSuppressions : public TestFixture {
341344

342345
return exitCode;
343346
}
347+
#endif // HAS_THREADING_MODEL_THREAD
344348

345-
#if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
349+
#ifdef HAS_THREADING_MODEL_FORK
346350
unsigned int checkSuppressionProcessesFiles(const char code[], const std::string &suppression = "") {
347351
return _checkSuppressionProcesses(code, false, suppression);
348352
}
@@ -390,7 +394,7 @@ class TestSuppressions : public TestFixture {
390394

391395
return exitCode;
392396
}
393-
#endif
397+
#endif // HAS_THREADING_MODEL_FORK
394398

395399
// TODO: check all results
396400
void runChecks(unsigned int (TestSuppressions::*check)(const char[], const std::string &)) {
@@ -920,23 +924,25 @@ class TestSuppressions : public TestFixture {
920924
runChecks(&TestSuppressions::checkSuppressionFS);
921925
}
922926

927+
#ifdef HAS_THREADING_MODEL_THREAD
923928
void suppressionsSettingsThreadsFiles() {
924929
runChecks(&TestSuppressions::checkSuppressionThreadsFiles);
925930
}
926931

927932
void suppressionsSettingsThreadsFS() {
928933
runChecks(&TestSuppressions::checkSuppressionThreadsFS);
929934
}
935+
#endif // HAS_THREADING_MODEL_THREAD
930936

931-
#if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
937+
#ifdef HAS_THREADING_MODEL_FORK
932938
void suppressionsSettingsProcessesFiles() {
933939
runChecks(&TestSuppressions::checkSuppressionProcessesFiles);
934940
}
935941

936942
void suppressionsSettingsProcessesFS() {
937943
runChecks(&TestSuppressions::checkSuppressionProcessesFS);
938944
}
939-
#endif
945+
#endif // HAS_THREADING_MODEL_FORK
940946

941947
void suppressionsMultiFileInternal(unsigned int (TestSuppressions::*check)(std::map<std::string, std::string> &f, const std::string &)) {
942948
std::map<std::string, std::string> files;

test/testthreadexecutor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class TestThreadExecutorBase : public TestFixture {
114114

115115
void run() override {
116116
mNewTemplate = true;
117+
#ifdef HAS_THREADING_MODEL_THREAD
117118
TEST_CASE(deadlock_with_many_errors);
118119
TEST_CASE(many_threads);
119120
TEST_CASE(many_threads_showtime);
@@ -130,6 +131,7 @@ class TestThreadExecutorBase : public TestFixture {
130131
TEST_CASE(showtime_file_total);
131132
TEST_CASE(suppress_error_library);
132133
TEST_CASE(unique_errors);
134+
#endif // HAS_THREADING_MODEL_THREAD
133135
}
134136

135137
void deadlock_with_many_errors() {

0 commit comments

Comments
 (0)