Skip to content

Commit

Permalink
Fix the new Group/Pool tests linting (#136)
Browse files Browse the repository at this point in the history
The linting was failing on the new group/pool test.
This fixes it so it works properly.
  • Loading branch information
TrentHouliston authored Aug 23, 2024
1 parent c48d005 commit 84bbf21
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/tests/dsl/GroupPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::vector<std::string> events; // NOLINT(cppcoreguidelines-avoid-non-const-gl
/// @brief Add an event to the event list
void add_event(const std::string& event) {
static std::mutex events_mutex;
std::lock_guard<std::mutex> lock(events_mutex);
const std::lock_guard<std::mutex> lock(events_mutex);
events.push_back(event);
}

Expand All @@ -42,7 +42,7 @@ struct Synced {};
template <int id>
struct PoolFinished {};

static constexpr int POOL_COUNT = 10;
constexpr int POOL_COUNT = 10;

class TestReactor : public test_util::TestBase<TestReactor> {
public:
Expand All @@ -51,15 +51,23 @@ class TestReactor : public test_util::TestBase<TestReactor> {
static constexpr int thread_count = 1;
};

template <int... ID>
void register_callbacks(NUClear::util::Sequence<ID...>) {
void register_pool_callbacks(NUClear::util::Sequence<> /*unused*/) {}

NUClear::util::unpack(on<Trigger<Synced>, Pool<TestPool<ID>>, Sync<TestReactor>>().then([this] {
template <int ID, int... IDs>
void register_pool_callbacks(NUClear::util::Sequence<ID, IDs...> /*unused*/) {
on<Trigger<Synced>, Pool<TestPool<ID>>, Sync<TestReactor>>().then([this] {
add_event("Pool Message");
emit(std::make_unique<PoolFinished<ID>>());
})...);
});

register_pool_callbacks(NUClear::util::Sequence<IDs...>());
}

template <int... IDs>
void register_callbacks(NUClear::util::Sequence<IDs...> /*unused*/) {
register_pool_callbacks(NUClear::util::Sequence<IDs...>());

on<Trigger<PoolFinished<ID>>...>().then([this] {
on<Trigger<PoolFinished<IDs>>...>().then([this] {
add_event("Finished");
powerplant.shutdown();
});
Expand Down

0 comments on commit 84bbf21

Please sign in to comment.