Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail CI if clazy fails #73

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v4

- name: Install ninja-build tool
uses: turtlesec-no/get-ninja@main
uses: aseprite/get-ninja@main

- name: Make sure MSVC is found when Ninja generator is in use
uses: ilammy/msvc-dev-cmd@v1
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ include(FeatureSummary)
option(${PROJECT_NAME}_TESTS "Build the tests" ON)
option(${PROJECT_NAME}_EXAMPLES "Build the examples" ON)
option(${PROJECT_NAME}_DOCS "Build the API documentation" OFF)
option(${PROJECT_NAME}_ERROR_ON_WARNING "Enable all compiler warnings and treat them as errors" OFF)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules)
Expand Down
15 changes: 12 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON"
"KDBindings_EXAMPLES" : "ON",
"KDBindings_ERROR_ON_WARNING": "ON"
}
},
{
Expand All @@ -23,7 +24,8 @@
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON",
"KDBindings_DOCS" : "ON"
"KDBindings_DOCS" : "ON",
"KDBindings_ERROR_ON_WARNING": "ON"
}
},
{
Expand All @@ -35,7 +37,8 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_COMPILER" : "clazy",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON"
"KDBindings_EXAMPLES" : "ON",
"KDBindings_ERROR_ON_WARNING" : "ON"
},
"warnings": {
"uninitialized": true
Expand Down Expand Up @@ -94,6 +97,12 @@
"configurePreset": "dev",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": false}
},
{
"name": "clazy",
"configurePreset": "clazy",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": false}
}
]
}
7 changes: 7 additions & 0 deletions src/kdbindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ target_include_directories(KDBindings INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
$<INSTALL_INTERFACE:include>
)
if(KDBindings_ERROR_ON_WARNING)
if(MSVC)
target_compile_options(KDBindings INTERFACE /W3 /WX)
else()
target_compile_options(KDBindings INTERFACE -Wall -Wextra -Wpedantic -Werror)
endif()
endif()

# Generate library version files
include(ECMSetupVersion)
Expand Down
4 changes: 4 additions & 0 deletions tests/binding/tst_binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest.h>

// The expansion of TEST_CASE from doctest leads to a clazy warning.
// As this issue originates from doctest, disable the warning.
// clazy:excludeall=non-pod-global-static

using namespace KDBindings;

static_assert(std::is_destructible<Binding<int>>{});
Expand Down
13 changes: 8 additions & 5 deletions tests/node/tst_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest.h>

// The expansion of TEST_CASE from doctest leads to a clazy warning.
// As this issue originates from doctest, disable the warning.
// clazy:excludeall=non-pod-global-static

using namespace KDBindings;

static_assert(std::is_destructible<Private::NodeInterface<float>>{});
Expand Down Expand Up @@ -404,15 +408,14 @@ TEST_CASE("bindable_value_type and operator_node")
REQUIRE(node2.evaluate() == (OP(OP(VALUE)))); \
}

TEST_CASE("Test unary operators")
{
TEST_CASE("Test unary operators"){
KDBINDINGS_UNARY_OPERATOR_TEST(!, bool, true)

KDBINDINGS_UNARY_OPERATOR_TEST(~, uint8_t, 25)
KDBINDINGS_UNARY_OPERATOR_TEST(~, uint8_t, 25)

KDBINDINGS_UNARY_OPERATOR_TEST(+, int, -10)
KDBINDINGS_UNARY_OPERATOR_TEST(+, int, -10)

KDBINDINGS_UNARY_OPERATOR_TEST(-, int, 10)
KDBINDINGS_UNARY_OPERATOR_TEST(-, int, 10)
}

#define KDBINDINGS_BINARY_OPERATOR_TEST(OP, TYPE, VALUE, OTHER) \
Expand Down
4 changes: 4 additions & 0 deletions tests/property/tst_property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest.h>

// The expansion of TEST_CASE from doctest leads to a clazy warning.
// As this issue originates from doctest, disable the warning.
// clazy:excludeall=non-pod-global-static

using namespace KDBindings;

static_assert(std::is_nothrow_destructible<Property<int>>{});
Expand Down
4 changes: 4 additions & 0 deletions tests/signal/tst_signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest.h>

// The expansion of TEST_CASE from doctest leads to a clazy warning.
// As this issue originates from doctest, disable the warning.
// clazy:excludeall=non-pod-global-static

using namespace KDBindings;

static_assert(std::is_nothrow_destructible<Signal<int>>{});
Expand Down
4 changes: 4 additions & 0 deletions tests/utils/tst_gen_index_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

#include <doctest.h>

// The expansion of TEST_CASE from doctest leads to a clazy warning.
// As this issue originates from doctest, disable the warning.
// clazy:excludeall=non-pod-global-static

using namespace KDBindings::Private;

static_assert(std::is_nothrow_destructible<GenerationalIndexArray<int>>{});
Expand Down