Skip to content

Commit 58bd68c

Browse files
committed
fix test issues with Linux and Windows
1 parent 54e9cc9 commit 58bd68c

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

tests/beman/execution/exec-spawn-future.test.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ struct throws {
4949
};
5050
static_assert(!std::is_nothrow_constructible_v<std::decay_t<throws>, throws>);
5151

52-
template <bool Expect, typename Sender, typename Token, typename Env = ::env>
53-
auto test_spawn_future_interface(Sender&& sndr, Token&& tok, Env&& e = Env{}) -> void {
52+
template <bool Expect, typename Env = ::env, typename Sender, typename Token>
53+
auto test_spawn_future_interface(Sender&& sndr, Token&& tok) -> void {
5454
if constexpr (!std::same_as<std::remove_cvref_t<Env>, non_env>) {
5555
static_assert(Expect ==
5656
requires { test_std::spawn_future(std::forward<Sender>(sndr), std::forward<Token>(tok)); });
5757
}
58-
static_assert(Expect == requires {
59-
test_std::spawn_future(std::forward<Sender>(sndr), std::forward<Token>(tok), std::forward<Env>(e));
58+
static_assert(Expect == requires(Env const& e){
59+
test_std::spawn_future(std::forward<Sender>(sndr), std::forward<Token>(tok), e);
6060
});
6161
}
6262

@@ -189,7 +189,8 @@ TEST(exec_spawn_future) {
189189
test_spawn_future_interface<true>(sender{}, token<true>{});
190190
test_spawn_future_interface<false>(non_sender{}, token<true>{});
191191
test_spawn_future_interface<false>(sender{}, token<false>{});
192-
test_spawn_future_interface<false>(sender{}, token<true>{}, *new non_env{});
192+
193+
test_spawn_future_interface<false, non_env>(sender{}, token<true>{});
193194

194195
test_state_base();
195196
test_receiver();

tests/beman/execution/include/test/execution.hpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
#ifndef _MSC_VER
1111
#include <cstdlib>
1212
#include <unistd.h>
13+
#include <sys/wait.h>
1314
#include <iostream>
14-
#include <source_location>
1515
#endif
16+
#include <source_location>
1617

1718
#undef NDEBUG
1819
#include <cassert>
@@ -27,6 +28,16 @@ namespace test_std = ::beman::execution;
2728
namespace test_detail = ::beman::execution::detail;
2829

2930
namespace test {
31+
#if 201907L <= __cpp_lib_source_location
32+
using source_location = ::std::source_location;
33+
#else
34+
struct source_location {
35+
static auto current() -> source_location { return {}; }
36+
auto file_name() const -> char const* { return "<unknown:no std::source_location>"; }
37+
auto line() const -> char const* { return "<unknown:no std::source_location>"; }
38+
};
39+
#endif
40+
3041
inline bool unreachable_helper() { return false; }
3142

3243
template <typename>
@@ -48,7 +59,7 @@ struct throws {
4859
};
4960

5061
inline auto death([[maybe_unused]] auto fun,
51-
[[maybe_unused]] ::std::source_location location = std::source_location::current()) noexcept
62+
[[maybe_unused]] ::std::source_location location = test::source_location::current()) noexcept
5263
-> void {
5364
#ifndef _MSC_VER
5465
switch (::pid_t rc = ::fork()) {

0 commit comments

Comments
 (0)