Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement ExtraTestMacros for all platforms #74

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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