Skip to content

Commit c15f2e0

Browse files
authored
Merge pull request NVIDIA#1446 from vasama/catch-clang-workaround
Add workaround for Clang/Catch2/libstdc++ issue
2 parents 39966d6 + b39e04f commit c15f2e0

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

test/exec/test_just_from.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#include "exec/just_from.hpp"
18+
#include "test_common/tuple.hpp"
1819
#include "test_common/type_helpers.hpp"
1920

2021
#include <catch2/catch.hpp>
@@ -75,7 +76,7 @@ TEST_CASE("just_from with multiple completions", "[just_from]") {
7576
constexpr auto N = std::tuple_size_v<Tupl>;
7677
CHECK(N == 2);
7778
if constexpr (N == 2) {
78-
CHECK(tupl == std::tuple{43, 44});
79+
CHECK_TUPLE(tupl == std::tuple{43, 44});
7980
}
8081
},
8182
var);

test/stdexec/algos/consumers/test_sync_wait.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <test_common/schedulers.hpp>
2020
#include <test_common/senders.hpp>
2121
#include <test_common/receivers.hpp>
22+
#include <test_common/tuple.hpp>
2223
#include <test_common/type_helpers.hpp>
2324
#include <exec/static_thread_pool.hpp>
2425

@@ -134,7 +135,7 @@ namespace {
134135
sync_wait_with_variant(snd);
135136

136137
CHECK(res.has_value());
137-
CHECK(std::get<0>(std::get<0>(res.value())) == std::make_tuple(13));
138+
CHECK_TUPLE(std::get<0>(std::get<0>(res.value())) == std::make_tuple(13));
138139
}
139140

140141
TEST_CASE(
@@ -147,7 +148,7 @@ namespace {
147148
std::optional<std::tuple<std::variant<std::tuple<int>>>> res = sync_wait_with_variant(snd);
148149

149150
CHECK(res.has_value());
150-
CHECK(std::get<0>(std::get<0>(res.value())) == std::make_tuple(13));
151+
CHECK_TUPLE(std::get<0>(std::get<0>(res.value())) == std::make_tuple(13));
151152
}
152153

153154
TEST_CASE("sync_wait works if signaled from a different thread", "[consumers][sync_wait]") {

test/test_common/receivers.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#pragma once
1818

1919
#include <catch2/catch.hpp>
20+
#include <test_common/tuple.hpp>
2021
#include <test_common/type_helpers.hpp>
2122
#include <stdexec/execution.hpp>
2223

@@ -187,7 +188,7 @@ namespace {
187188
}
188189

189190
void set_value(const Ts&... vals) noexcept {
190-
CHECK(values_ == std::tie(vals...));
191+
CHECK_TUPLE(values_ == std::tie(vals...));
191192
this->set_called();
192193
}
193194

@@ -524,8 +525,8 @@ namespace {
524525
CHECK(res.has_value());
525526
std::tuple<Ts...> expected(static_cast<Ts&&>(val)...);
526527
if constexpr (std::tuple_size_v<std::tuple<Ts...>> == 1)
527-
CHECK(std::get<0>(res.value()) == std::get<0>(expected));
528+
CHECK_TUPLE(std::get<0>(res.value()) == std::get<0>(expected));
528529
else
529-
CHECK(res.value() == expected);
530+
CHECK_TUPLE(res.value() == expected);
530531
}
531532
} // namespace

test/test_common/tuple.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2024 Lauri Vasama
3+
*
4+
* Licensed under the Apache License Version 2.0 with LLVM Exceptions
5+
* (the "License"); you may not use this file except in compliance with
6+
* the License. You may obtain a copy of the License at
7+
*
8+
* https://llvm.org/LICENSE.txt
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include <catch2/catch.hpp>
20+
21+
#include <tuple>
22+
23+
// Workaround for https://github.com/llvm/llvm-project/issues/113087
24+
#if defined(__clang__) && defined(__cpp_lib_tuple_like)
25+
#define CHECK_TUPLE(...) CHECK((__VA_ARGS__))
26+
#else
27+
#define CHECK_TUPLE CHECK
28+
#endif

0 commit comments

Comments
 (0)