Skip to content

Commit c1cbb41

Browse files
authored
Fix iPhone simulator CI (microsoft#981)
* Run iOS simulator CI * Fix link errors - scope function linkage using anonymous namespace * Update noexcept test for consistency
1 parent ef0ffef commit c1cbb41

File tree

5 files changed

+47
-56
lines changed

5 files changed

+47
-56
lines changed

.github/workflows/ios.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
-GXcode \
2626
-DCMAKE_SYSTEM_NAME=iOS \
2727
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \
28-
-DCMAKE_OSX_DEPLOYMENT_TARGET=8 \
28+
-DCMAKE_OSX_DEPLOYMENT_TARGET=9 \
2929
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
3030
"-DMACOSX_BUNDLE_GUI_IDENTIFIER=GSL.\$(EXECUTABLE_NAME)" \
31-
-DMACOSX_BUNDLE_BUNDLE_VERSION=3.0.1 \
32-
-DMACOSX_BUNDLE_SHORT_VERSION_STRING=3.0.1 \
31+
-DMACOSX_BUNDLE_BUNDLE_VERSION=3.1.0 \
32+
-DMACOSX_BUNDLE_SHORT_VERSION_STRING=3.1.0 \
3333
..
3434
3535
- name: Build

tests/CMakeLists.txt

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(ExternalProject)
1010
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1111

1212
if(IOS)
13-
add_compile_definitions(GTEST_HAS_DEATH_TEST=1)
13+
add_compile_definitions(GTEST_HAS_DEATH_TEST=1 IOS_PROCESS_DELAY_WORKAROUND=1)
1414
endif()
1515

1616
pkg_search_module(GTestMain gtest_main)
@@ -164,36 +164,27 @@ target_include_directories(gsl_tests_config SYSTEM INTERFACE
164164
googletest/googletest/include
165165
)
166166

167-
set_property(TARGET PROPERTY FOLDER "GSL_tests")
168-
169-
function(add_gsl_test name)
170-
add_executable(${name} ${name}.cpp)
171-
target_link_libraries(${name}
172-
Microsoft.GSL::GSL
173-
gsl_tests_config
174-
${GTestMain_LIBRARIES}
175-
)
176-
add_test(
177-
${name}
178-
${name}
179-
)
180-
# group all tests under GSL_tests
181-
set_property(TARGET ${name} PROPERTY FOLDER "GSL_tests")
182-
endfunction()
183-
184-
add_gsl_test(span_tests)
185-
add_gsl_test(span_ext_tests)
186-
add_gsl_test(span_compatibility_tests)
187-
add_gsl_test(string_span_tests)
188-
add_gsl_test(at_tests)
189-
add_gsl_test(notnull_tests)
190-
add_gsl_test(assertion_tests)
191-
add_gsl_test(utils_tests)
192-
add_gsl_test(owner_tests)
193-
add_gsl_test(byte_tests)
194-
add_gsl_test(algorithm_tests)
195-
add_gsl_test(strict_notnull_tests)
167+
add_executable(gsl_tests
168+
algorithm_tests.cpp
169+
assertion_tests.cpp
170+
at_tests.cpp
171+
byte_tests.cpp
172+
notnull_tests.cpp
173+
owner_tests.cpp
174+
span_compatibility_tests.cpp
175+
span_ext_tests.cpp
176+
span_tests.cpp
177+
strict_notnull_tests.cpp
178+
string_span_tests.cpp
179+
utils_tests.cpp
180+
)
196181

182+
target_link_libraries(gsl_tests
183+
Microsoft.GSL::GSL
184+
gsl_tests_config
185+
${GTestMain_LIBRARIES}
186+
)
187+
add_test(gsl_tests gsl_tests)
197188

198189
# No exception tests
199190

@@ -268,19 +259,9 @@ else()
268259
)
269260
endif(MSVC)
270261

271-
function(add_gsl_test_noexcept name)
272-
add_executable(${name} ${name}.cpp)
273-
target_link_libraries(${name}
274-
Microsoft.GSL::GSL
275-
gsl_tests_config_noexcept
276-
${GTestMain_LIBRARIES}
277-
)
278-
add_test(
279-
${name}
280-
${name}
281-
)
282-
# group all tests under GSL_tests_noexcept
283-
set_property(TARGET ${name} PROPERTY FOLDER "GSL_tests_noexcept")
284-
endfunction()
285-
286-
add_gsl_test_noexcept(no_exception_ensure_tests)
262+
add_executable(gsl_noexcept_tests no_exception_ensure_tests.cpp)
263+
target_link_libraries(gsl_noexcept_tests
264+
Microsoft.GSL::GSL
265+
gsl_tests_config_noexcept
266+
)
267+
add_test(gsl_noexcept_tests gsl_noexcept_tests)

tests/no_exception_ensure_tests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
//
1515
///////////////////////////////////////////////////////////////////////////////
1616

17+
#include <chrono>
1718
#include <cstdlib> // for std::exit
1819
#include <gsl/span> // for span
20+
#include <iostream>
21+
#include <thread>
1922

2023
int operator_subscript_no_throw() noexcept
2124
{
@@ -42,6 +45,10 @@ void setup_termination_handler() noexcept
4245

4346
int main() noexcept
4447
{
48+
std::cout << "Running main() from " __FILE__ "\n";
49+
#if defined(IOS_PROCESS_DELAY_WORKAROUND)
50+
std::this_thread::sleep_for(std::chrono::seconds(1));
51+
#endif
4552
setup_termination_handler();
4653
operator_subscript_no_throw();
4754
return -1;

tests/notnull_tests.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ using namespace gsl;
2929

3030
namespace
3131
{
32-
static constexpr char deathstring[] = "Expected Death";
33-
} //namespace
32+
constexpr char deathstring[] = "Expected Death";
33+
} // namespace
3434

3535
struct MyBase
3636
{
@@ -118,12 +118,15 @@ struct NonCopyableNonMovable
118118
NonCopyableNonMovable& operator=(NonCopyableNonMovable&&) = delete;
119119
};
120120

121+
namespace
122+
{
121123
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
122124
bool helper(not_null<int*> p) { return *p == 12; }
123125
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
124126
bool helper_const(not_null<const int*> p) { return *p == 12; }
125127

126128
int* return_pointer() { return nullptr; }
129+
} // namespace
127130

128131
TEST(notnull_tests, TestNotNullConstructors)
129132
{

tests/strict_notnull_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
#include <gtest/gtest.h>
1818
#include <gsl/pointers> // for not_null, operator<, operator<=, operator>
1919

20-
namespace gsl
21-
{
22-
struct fail_fast;
23-
} // namespace gsl
24-
2520
using namespace gsl;
2621

22+
namespace
23+
{
2724
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
2825
bool helper(not_null<int*> p) { return *p == 12; }
2926

@@ -36,8 +33,11 @@ bool strict_helper(strict_not_null<int*> p) { return *p == 12; }
3633
GSL_SUPPRESS(f.4) // NO-FORMAT: attribute
3734
bool strict_helper_const(strict_not_null<const int*> p) { return *p == 12; }
3835

36+
#ifdef CONFIRM_COMPILATION_ERRORS
3937
int* return_pointer() { return nullptr; }
4038
const int* return_pointer_const() { return nullptr; }
39+
#endif
40+
} // namespace
4141

4242
TEST(strict_notnull_tests, TestStrictNotNull)
4343
{

0 commit comments

Comments
 (0)