Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/GSL.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Maheshwari <tushar27192@gmail.com>2021-05-13 20:52:09 +0300
committerGitHub <noreply@github.com>2021-05-13 20:52:09 +0300
commitc1cbb41b428f15e53454682a45f03ea31f1da0a7 (patch)
tree8f696b9af923ef446fcf30b060302109a3d509d2
parentef0ffefe525a6219ff245d19a832ce06f3fd3504 (diff)
Fix iPhone simulator CI (#981)
* Run iOS simulator CI * Fix link errors - scope function linkage using anonymous namespace * Update noexcept test for consistency
-rw-r--r--.github/workflows/ios.yml6
-rw-r--r--tests/CMakeLists.txt73
-rw-r--r--tests/no_exception_ensure_tests.cpp7
-rw-r--r--tests/notnull_tests.cpp7
-rw-r--r--tests/strict_notnull_tests.cpp10
5 files changed, 47 insertions, 56 deletions
diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml
index 9d29bbc..0ef9fa3 100644
--- a/.github/workflows/ios.yml
+++ b/.github/workflows/ios.yml
@@ -25,11 +25,11 @@ jobs:
-GXcode \
-DCMAKE_SYSTEM_NAME=iOS \
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \
- -DCMAKE_OSX_DEPLOYMENT_TARGET=8 \
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=9 \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
"-DMACOSX_BUNDLE_GUI_IDENTIFIER=GSL.\$(EXECUTABLE_NAME)" \
- -DMACOSX_BUNDLE_BUNDLE_VERSION=3.0.1 \
- -DMACOSX_BUNDLE_SHORT_VERSION_STRING=3.0.1 \
+ -DMACOSX_BUNDLE_BUNDLE_VERSION=3.1.0 \
+ -DMACOSX_BUNDLE_SHORT_VERSION_STRING=3.1.0 \
..
- name: Build
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 368ce75..c05aaa7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,7 +10,7 @@ include(ExternalProject)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(IOS)
- add_compile_definitions(GTEST_HAS_DEATH_TEST=1)
+ add_compile_definitions(GTEST_HAS_DEATH_TEST=1 IOS_PROCESS_DELAY_WORKAROUND=1)
endif()
pkg_search_module(GTestMain gtest_main)
@@ -164,36 +164,27 @@ target_include_directories(gsl_tests_config SYSTEM INTERFACE
googletest/googletest/include
)
-set_property(TARGET PROPERTY FOLDER "GSL_tests")
-
-function(add_gsl_test name)
- add_executable(${name} ${name}.cpp)
- target_link_libraries(${name}
- Microsoft.GSL::GSL
- gsl_tests_config
- ${GTestMain_LIBRARIES}
- )
- add_test(
- ${name}
- ${name}
- )
- # group all tests under GSL_tests
- set_property(TARGET ${name} PROPERTY FOLDER "GSL_tests")
-endfunction()
-
-add_gsl_test(span_tests)
-add_gsl_test(span_ext_tests)
-add_gsl_test(span_compatibility_tests)
-add_gsl_test(string_span_tests)
-add_gsl_test(at_tests)
-add_gsl_test(notnull_tests)
-add_gsl_test(assertion_tests)
-add_gsl_test(utils_tests)
-add_gsl_test(owner_tests)
-add_gsl_test(byte_tests)
-add_gsl_test(algorithm_tests)
-add_gsl_test(strict_notnull_tests)
+add_executable(gsl_tests
+ algorithm_tests.cpp
+ assertion_tests.cpp
+ at_tests.cpp
+ byte_tests.cpp
+ notnull_tests.cpp
+ owner_tests.cpp
+ span_compatibility_tests.cpp
+ span_ext_tests.cpp
+ span_tests.cpp
+ strict_notnull_tests.cpp
+ string_span_tests.cpp
+ utils_tests.cpp
+)
+target_link_libraries(gsl_tests
+ Microsoft.GSL::GSL
+ gsl_tests_config
+ ${GTestMain_LIBRARIES}
+)
+add_test(gsl_tests gsl_tests)
# No exception tests
@@ -268,19 +259,9 @@ else()
)
endif(MSVC)
-function(add_gsl_test_noexcept name)
- add_executable(${name} ${name}.cpp)
- target_link_libraries(${name}
- Microsoft.GSL::GSL
- gsl_tests_config_noexcept
- ${GTestMain_LIBRARIES}
- )
- add_test(
- ${name}
- ${name}
- )
- # group all tests under GSL_tests_noexcept
- set_property(TARGET ${name} PROPERTY FOLDER "GSL_tests_noexcept")
-endfunction()
-
-add_gsl_test_noexcept(no_exception_ensure_tests)
+add_executable(gsl_noexcept_tests no_exception_ensure_tests.cpp)
+target_link_libraries(gsl_noexcept_tests
+ Microsoft.GSL::GSL
+ gsl_tests_config_noexcept
+)
+add_test(gsl_noexcept_tests gsl_noexcept_tests)
diff --git a/tests/no_exception_ensure_tests.cpp b/tests/no_exception_ensure_tests.cpp
index 2ec0ebb..5fde41c 100644
--- a/tests/no_exception_ensure_tests.cpp
+++ b/tests/no_exception_ensure_tests.cpp
@@ -14,8 +14,11 @@
//
///////////////////////////////////////////////////////////////////////////////
+#include <chrono>
#include <cstdlib> // for std::exit
#include <gsl/span> // for span
+#include <iostream>
+#include <thread>
int operator_subscript_no_throw() noexcept
{
@@ -42,6 +45,10 @@ void setup_termination_handler() noexcept
int main() noexcept
{
+ std::cout << "Running main() from " __FILE__ "\n";
+#if defined(IOS_PROCESS_DELAY_WORKAROUND)
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+#endif
setup_termination_handler();
operator_subscript_no_throw();
return -1;
diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp
index b95bb01..d4258e8 100644
--- a/tests/notnull_tests.cpp
+++ b/tests/notnull_tests.cpp
@@ -29,8 +29,8 @@ using namespace gsl;
namespace
{
-static constexpr char deathstring[] = "Expected Death";
-} //namespace
+constexpr char deathstring[] = "Expected Death";
+} // namespace
struct MyBase
{
@@ -118,12 +118,15 @@ struct NonCopyableNonMovable
NonCopyableNonMovable& operator=(NonCopyableNonMovable&&) = delete;
};
+namespace
+{
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
bool helper(not_null<int*> p) { return *p == 12; }
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
bool helper_const(not_null<const int*> p) { return *p == 12; }
int* return_pointer() { return nullptr; }
+} // namespace
TEST(notnull_tests, TestNotNullConstructors)
{
diff --git a/tests/strict_notnull_tests.cpp b/tests/strict_notnull_tests.cpp
index 3cf6911..9de2760 100644
--- a/tests/strict_notnull_tests.cpp
+++ b/tests/strict_notnull_tests.cpp
@@ -17,13 +17,10 @@
#include <gtest/gtest.h>
#include <gsl/pointers> // for not_null, operator<, operator<=, operator>
-namespace gsl
-{
-struct fail_fast;
-} // namespace gsl
-
using namespace gsl;
+namespace
+{
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
bool helper(not_null<int*> p) { return *p == 12; }
@@ -36,8 +33,11 @@ bool strict_helper(strict_not_null<int*> p) { return *p == 12; }
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
bool strict_helper_const(strict_not_null<const int*> p) { return *p == 12; }
+#ifdef CONFIRM_COMPILATION_ERRORS
int* return_pointer() { return nullptr; }
const int* return_pointer_const() { return nullptr; }
+#endif
+} // namespace
TEST(strict_notnull_tests, TestStrictNotNull)
{