Skip to content

Commit

Permalink
Round out ExtraTestMacros (#74)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
mjcarroll authored Jul 26, 2022
1 parent 41189fd commit 79345c6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
26 changes: 25 additions & 1 deletion include/gz/utils/ExtraTestMacros.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

#include <gz/utils/detail/ExtraTestMacros.hh>

/// \brief Restrict the execution of the test to just the Windows platform
/// Other platforms will get the test compiled but it won't be run
/// as part of the test suite execution.
/// The macro uses the Disabled_ prefix provided by googletest. See
/// https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md
#define GZ_UTILS_TEST_ENABLED_ONLY_ON_WINDOWS(TestName) \
DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_WINDOWS(TestName)

/// \brief Restrict the execution of the test for the Windows platform.
/// The test will be compiled on Windows too but will never be run as
/// part of the test suite. The macro uses the Disabled_ prefix provided
Expand All @@ -28,8 +36,16 @@
#define GZ_UTILS_TEST_DISABLED_ON_WIN32(TestName) \
DETAIL_GZ_UTILS_TEST_DISABLED_ON_WIN32(TestName)

/// \brief Restrict the execution of the test to just the MacOS platform
/// Other platforms will get the test compiled but it won't be run
/// as part of the test suite execution.
/// The macro uses the Disabled_ prefix provided by googletest. See
/// https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md
#define GZ_UTILS_TEST_ENABLED_ONLY_ON_MAC(TestName) \
DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_MAC(TestName)

/// \brief Restrict the execution of the test for the Mac platform.
/// The test will be compiled on Windows too but will never be run as
/// The test will be compiled on Mac too but will never be run as
/// part of the test suite. The macro uses the Disabled_ prefix provided
/// by googletest. See
/// https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md
Expand All @@ -44,4 +60,12 @@
#define GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName) \
DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName)

/// \brief Restrict the execution of the test for the Linux platform
/// The test will be compiled on Linux too but will never be run as
/// part of the test suite. The macro uses the Disabled_ prefix provided
/// by googletest. See
/// https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md
#define GZ_UTILS_TEST_DISABLED_ON_LINUX(TestName) \
DETAIL_GZ_UTILS_TEST_DISABLED_ON_LINUX(TestName)

#endif // GZ_UTILS_EXTRATESTMACROS_HH
12 changes: 12 additions & 0 deletions include/gz/utils/detail/ExtraTestMacros.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,45 @@

#define DETAIL_GZ_UTILS_TEST_DISABLED_ON_WIN32(TestName) \
DETAIL_GZ_UTILS_ADD_DISABLED_PREFIX(TestName)
#define DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_WIN32(TestName) \
TestName

#else

#define DETAIL_GZ_UTILS_TEST_DISABLED_ON_WIN32(TestName) \
TestName
#define DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_WIN32(TestName) \
DETAIL_GZ_UTILS_ADD_DISABLED_PREFIX(TestName)

#endif // defined _WIN32

#if defined __APPLE__

#define DETAIL_GZ_UTILS_TEST_DISABLED_ON_MAC(TestName) \
DETAIL_GZ_UTILS_ADD_DISABLED_PREFIX(TestName)
#define DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_MAC(TestName) \
TestName

#else

#define DETAIL_GZ_UTILS_TEST_DISABLED_ON_MAC(TestName) \
TestName
#define DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_MAC(TestName) \
DETAIL_GZ_UTILS_ADD_DISABLED_PREFIX(TestName)

#endif // defined __APPLE__

#if defined __linux__

#define DETAIL_GZ_UTILS_TEST_DISABLED_ON_LINUX(TestName) \
DETAIL_GZ_UTILS_ADD_DISABLED_PREFIX(TestName)
#define DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName) \
TestName

#else

#define DETAIL_GZ_UTILS_TEST_DISABLED_ON_LINUX(TestName) \
TestName
#define DETAIL_GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(TestName) \
DETAIL_GZ_UTILS_ADD_DISABLED_PREFIX(TestName)

Expand Down

0 comments on commit 79345c6

Please # to comment.