mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Compile unit tests for iOS and Android
While you can't easily run these unit tests, it's easy enough to still compile them so we don't need to go out of way to prohibit this. CMake has some support for running tests on the target OS so perhaps in the future we find a compelling way to run the test suite on a mobile OS.
This commit is contained in:
parent
30fcb3523c
commit
7bb97a85b1
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@ -65,16 +65,16 @@ jobs:
|
|||||||
- platform: { name: macOS, os: macos-12 }
|
- platform: { name: macOS, os: macos-12 }
|
||||||
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
|
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
|
||||||
- platform: { name: Android, os: ubuntu-22.04 }
|
- platform: { name: Android, os: ubuntu-22.04 }
|
||||||
config: { name: x86 (API 21), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: x86, api: 21 }
|
config: { name: x86 (API 21), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: x86, api: 21 }
|
||||||
type: { name: Release }
|
type: { name: Release }
|
||||||
- platform: { name: Android, os: ubuntu-22.04 }
|
- platform: { name: Android, os: ubuntu-22.04 }
|
||||||
config: { name: x86_64 (API 24), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=24 -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: x86_64, api: 24 }
|
config: { name: x86_64 (API 24), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=24 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: x86_64, api: 24 }
|
||||||
type: { name: Release }
|
type: { name: Release }
|
||||||
- platform: { name: Android, os: ubuntu-22.04 }
|
- platform: { name: Android, os: ubuntu-22.04 }
|
||||||
config: { name: armeabi-v7a (API 29), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=29 -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: armeabi-v7a, api: 29 }
|
config: { name: armeabi-v7a (API 29), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=29 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: armeabi-v7a, api: 29 }
|
||||||
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug }
|
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug }
|
||||||
- platform: { name: Android, os: ubuntu-22.04 }
|
- platform: { name: Android, os: ubuntu-22.04 }
|
||||||
config: { name: arm64-v8a (API 33), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=33 -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: arm64-v8a, api: 33 }
|
config: { name: arm64-v8a (API 33), flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=33 -DCMAKE_ANDROID_NDK=$ANDROID_SDK_ROOT/ndk/26.1.10909125 -DBUILD_SHARED_LIBS=TRUE -DCMAKE_ANDROID_STL_TYPE=c++_shared, arch: arm64-v8a, api: 33 }
|
||||||
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug }
|
type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug }
|
||||||
- platform: { name: macOS , os: macos-12 }
|
- platform: { name: macOS , os: macos-12 }
|
||||||
config: { name: System Deps, flags: -GNinja -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_SYSTEM_DEPS=TRUE }
|
config: { name: System Deps, flags: -GNinja -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_SYSTEM_DEPS=TRUE }
|
||||||
@ -202,7 +202,7 @@ jobs:
|
|||||||
run: cmake --build build --target runtests --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
|
run: cmake --build build --target runtests --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }}
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
if: runner.os != 'Windows' || contains(matrix.platform.name, 'MinGW')
|
if: (runner.os != 'Windows' || contains(matrix.platform.name, 'MinGW')) && !contains(matrix.platform.name, 'iOS') && !contains(matrix.platform.name, 'Android')
|
||||||
run: |
|
run: |
|
||||||
ctest --test-dir build --output-on-failure -C ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --repeat until-pass:3
|
ctest --test-dir build --output-on-failure -C ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --repeat until-pass:3
|
||||||
# Run gcovr to extract coverage information from the test run
|
# Run gcovr to extract coverage information from the test run
|
||||||
@ -211,7 +211,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload Coverage Report to Coveralls
|
- name: Upload Coverage Report to Coveralls
|
||||||
if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' # Disable upload in forks
|
if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' && !contains(matrix.platform.name, 'iOS') && !contains(matrix.platform.name, 'Android') # Disable upload in forks
|
||||||
uses: coverallsapp/github-action@v2
|
uses: coverallsapp/github-action@v2
|
||||||
with:
|
with:
|
||||||
file: ./build/coverage.out
|
file: ./build/coverage.out
|
||||||
@ -269,7 +269,7 @@ jobs:
|
|||||||
- { name: Linux OpenGL ES, os: ubuntu-22.04, flags: -DSFML_OPENGL_ES=ON }
|
- { name: Linux OpenGL ES, os: ubuntu-22.04, flags: -DSFML_OPENGL_ES=ON }
|
||||||
- { name: macOS, os: macos-12 }
|
- { name: macOS, os: macos-12 }
|
||||||
- { name: iOS, os: macos-12, flags: -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 }
|
- { name: iOS, os: macos-12, flags: -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 }
|
||||||
- { name: Android, os: ubuntu-22.04, flags: -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DCMAKE_ANDROID_STL_TYPE=c++_shared }
|
- { name: Android, os: ubuntu-22.04, flags: -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DCMAKE_ANDROID_STL_TYPE=c++_shared }
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
|
@ -517,9 +517,7 @@ sfml_set_option(SFML_BUILD_TEST_SUITE FALSE BOOL "TRUE to build the SFML test su
|
|||||||
sfml_set_option(SFML_ENABLE_COVERAGE FALSE BOOL "TRUE to enable coverage reporting, FALSE to ignore it")
|
sfml_set_option(SFML_ENABLE_COVERAGE FALSE BOOL "TRUE to enable coverage reporting, FALSE to ignore it")
|
||||||
|
|
||||||
if(SFML_BUILD_TEST_SUITE)
|
if(SFML_BUILD_TEST_SUITE)
|
||||||
if(SFML_OS_IOS)
|
if(SFML_BUILD_WINDOW AND SFML_BUILD_GRAPHICS AND SFML_BUILD_NETWORK AND SFML_BUILD_AUDIO)
|
||||||
message(WARNING "Unit testing not supported on iOS")
|
|
||||||
elseif(SFML_BUILD_WINDOW AND SFML_BUILD_GRAPHICS AND SFML_BUILD_NETWORK AND SFML_BUILD_AUDIO)
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
else()
|
else()
|
||||||
|
@ -365,6 +365,11 @@ function(sfml_add_test target SOURCES DEPENDS)
|
|||||||
add_dependencies(${target} "install-mesa3d")
|
add_dependencies(${target} "install-mesa3d")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Delay test registration when cross compiling to avoid running crosscompiled app on host OS
|
||||||
|
if(CMAKE_CROSSCOMPILING)
|
||||||
|
set(CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add the test
|
# Add the test
|
||||||
catch_discover_tests(${target} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
|
catch_discover_tests(${target} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -87,7 +87,8 @@ std::vector<std::byte> loadIntoMemory(const std::filesystem::path& path)
|
|||||||
const auto size = file.tellg();
|
const auto size = file.tellg();
|
||||||
file.seekg(0, std::ios::beg);
|
file.seekg(0, std::ios::beg);
|
||||||
std::vector<std::byte> buffer(static_cast<std::size_t>(size));
|
std::vector<std::byte> buffer(static_cast<std::size_t>(size));
|
||||||
[[maybe_unused]] const auto& result = file.read(reinterpret_cast<char*>(buffer.data()), size);
|
[[maybe_unused]] const auto& result = file.read(reinterpret_cast<char*>(buffer.data()),
|
||||||
|
static_cast<std::streamsize>(size));
|
||||||
assert(result);
|
assert(result);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user