Skip to content

Commit b5628e9

Browse files
committed
Fix macOS test
1 parent 628acf0 commit b5628e9

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/libutil-tests/fun.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <type_traits>
33

44
#include "nix/util/fun.hh"
5+
#include "util-tests-config.hh"
56

67
namespace nix {
78

@@ -39,19 +40,31 @@ TEST(fun, moveConstructFromStdFunction)
3940
TEST(fun, rejectsEmptyStdFunction)
4041
{
4142
std::function<int(int)> empty;
43+
#if HAVE_CXA_THROW
4244
ASSERT_DEATH((fun<int(int)>{empty}), "invalid_argument");
45+
#else
46+
EXPECT_THROW((fun<int(int)>{empty}), std::invalid_argument);
47+
#endif
4348
}
4449

4550
TEST(fun, rejectsEmptyStdFunctionMove)
4651
{
4752
std::function<int(int)> empty;
53+
#if HAVE_CXA_THROW
4854
ASSERT_DEATH((fun<int(int)>{std::move(empty)}), "invalid_argument");
55+
#else
56+
EXPECT_THROW((fun<int(int)>{std::move(empty)}), std::invalid_argument);
57+
#endif
4958
}
5059

5160
TEST(fun, rejectsNullFunctionPointer)
5261
{
5362
int (*nullFp)(int) = nullptr;
63+
#if HAVE_CXA_THROW
5464
ASSERT_DEATH((fun<int(int)>{nullFp}), "invalid_argument");
65+
#else
66+
EXPECT_THROW((fun<int(int)>{nullFp}), std::invalid_argument);
67+
#endif
5568
}
5669

5770
TEST(fun, nullptrDeletedAtCompileTime)

src/libutil-tests/meson.build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@ deps_private += gtest
3636
gmock = dependency('gmock')
3737
deps_private += gmock
3838

39+
subdir('nix-meson-build-support/common')
40+
3941
configdata = configuration_data()
4042
configdata.set_quoted('PACKAGE_VERSION', meson.project_version())
43+
configdata.set('HAVE_CXA_THROW', have_cxa_throw.to_int())
4144

4245
config_priv_h = configure_file(
4346
configuration : configdata,
4447
output : 'util-tests-config.hh',
4548
)
4649

47-
subdir('nix-meson-build-support/common')
48-
4950
sources = files(
5051
'alignment.cc',
5152
'archive.cc',

0 commit comments

Comments
 (0)