diff --git a/.github/workflows/ios-ci.yml b/.github/workflows/ios-ci.yml index 5d2108f51..3f623bc3d 100644 --- a/.github/workflows/ios-ci.yml +++ b/.github/workflows/ios-ci.yml @@ -169,7 +169,7 @@ jobs: cd Payload/RenderTestApp.app/PlugIns zip -r "$render_test_app_dir"/RenderTest.xctest.zip RenderTest.xctest echo render_test_artifacts_dir="$render_test_app_dir" >> "$GITHUB_ENV" - + - uses: actions/upload-artifact@v3 with: name: ios-render-test @@ -177,3 +177,29 @@ jobs: path: | ${{ env.render_test_artifacts_dir }}/RenderTest.xctest.zip ${{ env.render_test_artifacts_dir }}/RenderTestApp.ipa + + # C++ unit tests + + - name: Build CppUnitTests .ipa and .xctest for AWS Device Farm + run: | + set -e + bazel run //platform/ios:xcodeproj + build_dir="$(mktemp -d)" + xcodebuild build-for-testing -scheme CppUnitTests -project MapLibre.xcodeproj -derivedDataPath "$build_dir" + ios_cpp_test_app_dir="$(dirname "$(find "$build_dir" -name CppUnitTestsApp.app)")" + cd "$ios_cpp_test_app_dir" + mkdir Payload + mv CppUnitTestsApp.app Payload + zip -r CppUnitTestsApp.zip Payload + mv CppUnitTestsApp.zip CppUnitTestsApp.ipa + cd Payload/CppUnitTestsApp.app/PlugIns + zip -r "$ios_cpp_test_app_dir"/CppUnitTests.xctest.zip CppUnitTests.xctest + echo ios_cpp_test_artifacts_dir="$ios_cpp_test_app_dir" >> "$GITHUB_ENV" + + - uses: actions/upload-artifact@v3 + with: + name: ios-cpp-unit-tests + retention-days: 3 + path: | + ${{ env.ios_cpp_test_artifacts_dir }}/CppUnitTests.xctest.zip + ${{ env.ios_cpp_test_artifacts_dir }}/CppUnitTestsApp.ipa diff --git a/.github/workflows/ios-render-test.yml b/.github/workflows/ios-device-test.yml similarity index 76% rename from .github/workflows/ios-render-test.yml rename to .github/workflows/ios-device-test.yml index aeddc1a2a..32ae024c1 100644 --- a/.github/workflows/ios-render-test.yml +++ b/.github/workflows/ios-device-test.yml @@ -1,4 +1,4 @@ -name: ios-render-test +name: ios-device-test on: workflow_run: @@ -7,7 +7,15 @@ on: - completed jobs: - ios-render-test: + ios-device-test: + strategy: + matrix: + test: [ + {artifactName: ios-render-test, xcTestFile: RenderTest.xctest.zip, ipaFile: RenderTestApp.ipa, name: "iOS Render Tests"}, + {artifactName: ios-cpp-unit-tests, xcTestFile: CppUnitTests.xctest.zip, ipaFile: CppUnitTestsApp.ipa, name: "iOS C++ Unit Tests"}, + ] + max-parallel: 1 + fail-fast: true runs-on: ubuntu-22.04 if: github.repository_owner == 'maplibre' steps: @@ -15,9 +23,8 @@ jobs: - uses: ./.github/actions/download-workflow-run-artifact with: - artifact-name: ios-render-test - expect-files: "RenderTest.xctest.zip, RenderTestApp.ipa" - + artifact-name: ${{ matrix.test.artifactName }} + expect-files: "${{ matrix.test.xcTestFile }}, ${{ matrix.test.ipaFile }}" - name: Generate token id: generate_token @@ -32,7 +39,7 @@ jobs: token: ${{ steps.generate_token.outputs.token }} details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status: in_progress - name: iOS Render Test + name: ${{ matrix.test.name }} sha: ${{ github.event.workflow_run.head_sha }} - name: Configure AWS Credentials @@ -47,7 +54,7 @@ jobs: - name: Create upload app run: | - response=$(aws devicefarm create-upload --type IOS_APP --name RenderTestApp.ipa --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}) + response=$(aws devicefarm create-upload --type IOS_APP --name ${{ matrix.test.ipaFile }} --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}) echo "$response" arn="$(jq -r '.upload.arn' <<< "$response")" url="$(jq -r '.upload.url' <<< "$response")" @@ -56,17 +63,17 @@ jobs: - name: Create upload test package run: | - response=$(aws devicefarm create-upload --type XCTEST_TEST_PACKAGE --name RenderTest.xctest.zip --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}) + response=$(aws devicefarm create-upload --type XCTEST_TEST_PACKAGE --name ${{ matrix.test.xcTestFile }} --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}) echo "$response" arn="$(jq -r '.upload.arn' <<< "$response")" url="$(jq -r '.upload.url' <<< "$response")" echo "test_package_arn=$arn" >> "$GITHUB_ENV" echo "test_package_url=$url" >> "$GITHUB_ENV" - - name: Upload iOS Render test + - name: Upload ${{ matrix.test.name }} run: | - curl -T RenderTestApp.ipa "${{ env.app_url }}" - curl -T RenderTest.xctest.zip "${{ env.test_package_url }}" + curl -T ${{ matrix.test.ipaFile }} "${{ env.app_url }}" + curl -T ${{ matrix.test.xcTestFile }} "${{ env.test_package_url }}" max_checks=10 sleep_time=5 @@ -92,7 +99,7 @@ jobs: - name: Schedule test run uses: realm/aws-devicefarm/test-application@master with: - name: MapLibre Native iOS Render Test + name: MapLibre Native ${{ matrix.test.name }} project_arn: ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }} device_pool_arn: ${{ vars.AWS_DEVICE_FARM_IPHONE_DEVICE_POOL_ARN }} app_arn: ${{ env.app_arn }} diff --git a/platform/default/BUILD.bazel b/platform/default/BUILD.bazel index 4e237290a..8c8c662a2 100644 --- a/platform/default/BUILD.bazel +++ b/platform/default/BUILD.bazel @@ -97,6 +97,7 @@ cc_library( "//platform/darwin:__pkg__", "//platform/ios:__pkg__", "//platform/linux:__pkg__", + "//test:__pkg__", ], deps = [ "//:mbgl-core", diff --git a/platform/ios/BUILD.bazel b/platform/ios/BUILD.bazel index b9397ca57..538ab104e 100644 --- a/platform/ios/BUILD.bazel +++ b/platform/ios/BUILD.bazel @@ -7,7 +7,7 @@ load( "xcodeproj", ) load("//platform/ios/bazel:macros.bzl", "info_plist") -load("//platform/ios/bazel:config.bzl", "BUNDLE_ID_PREFIX") +load("//platform/ios/bazel:config.bzl", "BUILD_MODE", "BUNDLE_ID_PREFIX") load( "//platform/ios/bazel:files.bzl", "MLN_IOS_PRIVATE_HEADERS", @@ -213,7 +213,7 @@ genrule( xcodeproj( name = "xcodeproj", bazel_env = {"PATH": "/bin:/usr/bin:/usr/local/bin:/opt/homebrew/bin"}, - build_mode = "xcode", + build_mode = BUILD_MODE, default_xcode_configuration = "Debug", minimum_xcode_version = "14", project_name = "MapLibre", @@ -247,6 +247,13 @@ xcodeproj( "device", ], ), + top_level_target( + "//platform/ios/test/core:CppUnitTests", + target_environments = [ + "simulator", + "device", + ], + ), ], xcode_configurations = { "Debug": {"//command_line_option:compilation_mode": "dbg"}, diff --git a/platform/ios/README.md b/platform/ios/README.md index 3b856c97b..8c2138a4d 100644 --- a/platform/ios/README.md +++ b/platform/ios/README.md @@ -95,12 +95,6 @@ cp bazel/example_config.bzl bazel/config.bzl You need to set your `BUNDLE_ID_PREFIX` to be unique (ideally use a domain that you own in reverse domain name notation). -``` -APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID = "FFNX6834U8" -APPLE_MOBILE_PROVISIONING_PROFILE_NAME = "iOS Team Provisioning Profile: *" -BUNDLE_ID_PREFIX = "com.firstnamelastname" -``` - You can keep leave the `APPLE_MOBILE_PROVISIONING_PROFILE_NAME` alone. Set the Team ID to the Team ID of your Apple Developer Account (paid or unpaid both work). If you do not know your Team ID, enter the following command in the terminal: @@ -130,6 +124,8 @@ Confirm that no errors are shown: Try to run the example App in the simulator and on a device to confirm your setup works. +If no provisioning profile was found, you could try changing the `BUILD_MODE` in `config.bzl` to `"xcode"`. Try the steps in this section again afterwards. + #### Using Bazel from the Command Line It is also possible to build and run the test application in a simulator from the command line without opening Xcode. diff --git a/platform/ios/bazel/example_config.bzl b/platform/ios/bazel/example_config.bzl index 533bdae5d..e61a9bafc 100644 --- a/platform/ios/bazel/example_config.bzl +++ b/platform/ios/bazel/example_config.bzl @@ -1,3 +1,8 @@ APPLE_MOBILE_PROVISIONING_PROFILE_TEAM_ID = "TC45MCF93C" APPLE_MOBILE_PROVISIONING_PROFILE_NAME = "iOS Team Provisioning Profile: *" BUNDLE_ID_PREFIX = "com.firstnamelastname" + +# Change the BUILD_MODE to "xcode" below if you experience problems with +# not finding a provisioning profile when building. +# https://github.com/MobileNativeFoundation/rules_xcodeproj/blob/main/docs/bazel.md#xcodeproj-build_mode +BUILD_MODE = "bazel" diff --git a/platform/ios/test/common/BUILD.bazel b/platform/ios/test/common/BUILD.bazel index 28644ab39..84a112739 100644 --- a/platform/ios/test/common/BUILD.bazel +++ b/platform/ios/test/common/BUILD.bazel @@ -10,12 +10,13 @@ cc_library( ".", ], visibility = [ + "//platform/ios/test/core:__pkg__", "//render-test/ios:__pkg__", ], ) objc_library( - name = "render_test_app_srcs", + name = "test_app_srcs", srcs = [ "AppDelegate.h", "AppDelegate.m", @@ -25,6 +26,9 @@ objc_library( "LaunchScreen.storyboard", "Main.storyboard", ], + visibility = [ + "//platform/ios/test/core:__pkg__", + ], deps = [ "ios_test_runner_lib", ], @@ -43,7 +47,7 @@ ios_application( "//visibility:public", ], deps = [ - "render_test_app_srcs", + "test_app_srcs", "//render-test/ios:render_test_ios_src", ], ) diff --git a/platform/ios/test/common/iosTestRunner.mm b/platform/ios/test/common/iosTestRunner.mm deleted file mode 100644 index 67eca9d1d..000000000 --- a/platform/ios/test/common/iosTestRunner.mm +++ /dev/null @@ -1,84 +0,0 @@ -#import "iosTestRunner.h" - -#include - -#include - -@interface IosTestRunner () - -@property (nullable) TestRunner *runner; - -@property (copy, nullable) NSString *resultPath; - -@property BOOL testStatus; - -@end - -@implementation IosTestRunner - --(instancetype)init -{ - self = [super init]; - if (self) { - self.testStatus = NO; - self.runner = new TestRunner(); - NSError *error; - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; - - NSArray *bundleContents = [fileManager contentsOfDirectoryAtPath: bundleRoot error: &error]; - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *documentsDir = [paths objectAtIndex: 0]; - - for (uint32_t i = 0; i < bundleContents.count; i++) { - NSString *dirName = [bundleContents objectAtIndex: i]; - if ([dirName isEqualToString: dataDir]) { - NSString *destinationPath = [documentsDir stringByAppendingPathComponent: dirName]; - BOOL success = [fileManager fileExistsAtPath: destinationPath]; - if (success) { - [fileManager removeItemAtPath:destinationPath error:NULL]; - } - - success = [fileManager fileExistsAtPath: destinationPath]; - if (!success) { - NSString *copyDirPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: dirName]; - success = [fileManager copyItemAtPath: copyDirPath toPath: destinationPath error: &error]; - - if (!success) { - NSLog(@"Failed to copy file '%@'", dirName); - NSAssert1(0, @"Failed to copy file, error '%@'", [error localizedDescription]); - } else { - NSLog(@"File '%@' copied OK", dirName); - } - } else { - NSLog(@"Failed to remove file '%@'", dirName); - NSAssert1(0, @"Failed to remove file, error '%@'", [error localizedDescription]); - } - break; - } - } - NSString *baseDir = [documentsDir stringByAppendingPathComponent: dataDir]; - std::string basePath = std::string([baseDir UTF8String]); - self.testStatus = self.runner->startTest(basePath) ? YES : NO; - self.resultPath = [baseDir stringByAppendingPathComponent: resultFilePath]; - - BOOL fileFound = [fileManager fileExistsAtPath: self.resultPath]; - if (fileFound == NO) { - NSLog(@"Test result file '%@' does not exist", self.resultPath); - self.testStatus = NO; - } - - delete self.runner; - self.runner = nullptr; - } - return self; -} - -- (NSString*) getResultPath { - return self.resultPath; -} - -- (BOOL) getTestStatus { - return self.testStatus; -} -@end diff --git a/platform/ios/test/core/BUILD.bazel b/platform/ios/test/core/BUILD.bazel new file mode 100644 index 000000000..f3af526eb --- /dev/null +++ b/platform/ios/test/core/BUILD.bazel @@ -0,0 +1,68 @@ +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test") +load("//platform/ios/bazel:config.bzl", "BUNDLE_ID_PREFIX") +load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") +load("@build_bazel_rules_apple//apple:resources.bzl", "apple_resource_bundle") + +cc_library( + name = "test_cpp_srcs", + srcs = [ + "ios_test_runner.cpp", + ], + copts = CPP_FLAGS + MAPLIBRE_FLAGS, + deps = [ + "//platform:ios-sdk", + "//platform/ios/test/common:ios_test_runner_lib", + "//test:testlib", + "//test:tests", + ], +) + +apple_resource_bundle( + name = "TestData", + infoplists = [ + "//render-test/ios:Empty.plist", + ], + structured_resources = [ + "//test:fixtures", + "//:scripts/style-spec-reference/v8.json", + ], +) + +objc_library( + name = "test_objc_srcs", + srcs = [ + "Tests.m", + "iosTestRunner.h", + "iosTestRunner.mm", + ], + deps = [ + "TestData", + "test_cpp_srcs", + "//platform/ios/test/common:ios_test_runner_lib", + ], +) + +ios_application( + name = "CppUnitTestsApp", + bundle_id = "{}.maplibre.UnitTestsApp".format(BUNDLE_ID_PREFIX), + families = ["iphone"], + infoplists = [ + "Info.plist", + ], + minimum_os_version = "12.0", + provisioning_profile = "//platform/ios:xcode_profile", + deps = [ + "//platform/ios/test/common:test_app_srcs", + ], +) + +ios_unit_test( + name = "CppUnitTests", + minimum_os_version = "12.0", + provisioning_profile = "//platform/ios:xcode_profile", + test_host = "CppUnitTestsApp", + visibility = ["@rules_xcodeproj//xcodeproj:generated"], + deps = [ + "test_objc_srcs", + ], +) diff --git a/test/ios/Info.plist b/platform/ios/test/core/Info.plist similarity index 82% rename from test/ios/Info.plist rename to platform/ios/test/core/Info.plist index c53d0d06e..2fb1694c1 100644 --- a/test/ios/Info.plist +++ b/platform/ios/test/core/Info.plist @@ -1,5 +1,5 @@ - + CFBundleDevelopmentRegion @@ -8,16 +8,12 @@ ${PRODUCT_NAME} CFBundleExecutable UnitTestsApp - CFBundleIdentifier - com.mapbox.UnitTestsApp CFBundleGetInfoString com.mapbox.UnitTestsApp CFBundleInfoDictionaryVersion 1.0 CFBundleLongVersionString 1.0 - CFBundleName - com.mapbox.UnitTestsApp CFBundlePackageType APPL CFBundleShortVersionString @@ -30,8 +26,6 @@ NSHumanReadableCopyright © 2014–2020 Mapbox - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/platform/ios/test/common/Tests.m b/platform/ios/test/core/Tests.m similarity index 100% rename from platform/ios/test/common/Tests.m rename to platform/ios/test/core/Tests.m diff --git a/test/ios/iosTestRunner.h b/platform/ios/test/core/iosTestRunner.h similarity index 67% rename from test/ios/iosTestRunner.h rename to platform/ios/test/core/iosTestRunner.h index eefe2da3d..80ca625ff 100644 --- a/test/ios/iosTestRunner.h +++ b/platform/ios/test/core/iosTestRunner.h @@ -1,7 +1,6 @@ -#import +#pragma once -NSString *dataDir = @"test-data"; -NSString *resultFilePath = @"test/results.xml"; +#import __attribute__((visibility ("default"))) @interface IosTestRunner : NSObject diff --git a/platform/ios/test/core/iosTestRunner.mm b/platform/ios/test/core/iosTestRunner.mm new file mode 100644 index 000000000..a8b7f794b --- /dev/null +++ b/platform/ios/test/core/iosTestRunner.mm @@ -0,0 +1,92 @@ +#import "iosTestRunner.h" + +#include + +#include + +@interface IosTestRunner () + +@property (nullable) TestRunner *runner; + +@property (copy, nullable) NSString *resultPath; + +@property BOOL testStatus; + +@end + +@implementation IosTestRunner + +-(instancetype)init +{ + self = [super init]; + if (self) { + self.testStatus = NO; + self.runner = new TestRunner(); + + NSError *error; + NSFileManager *fileManager = [NSFileManager defaultManager]; + + NSString *xcTestBundleRoot = [[NSBundle bundleForClass:[self class]] resourcePath]; + NSString *testDataDir = [xcTestBundleRoot stringByAppendingString:@"/TestData.bundle"]; + + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDir = [paths objectAtIndex: 0]; + + NSString *destinationPath = [documentsDir stringByAppendingPathComponent: @"test"]; + + [self copyFileAtPath:testDataDir toPath:destinationPath]; + [self copyFileAtPath:[testDataDir stringByAppendingPathComponent: @"scripts"] toPath:[documentsDir stringByAppendingPathComponent: @"scripts"]]; + + NSLog(@"Starting test"); + std::string basePath = std::string([documentsDir UTF8String]); + self.testStatus = self.runner->startTest(basePath) ? YES : NO; + self.resultPath = [destinationPath stringByAppendingPathComponent: @"results.xml"]; + + BOOL fileFound = [fileManager fileExistsAtPath: self.resultPath]; + if (fileFound == NO) { + NSLog(@"Test result file '%@' does not exist", self.resultPath); + self.testStatus = NO; + } + + delete self.runner; + self.runner = nullptr; + } + return self; +} + +/** + Copies a file from the source path to the destination path. + + @param sourcePath The path of the source file to be copied. + @param destinationPath The destination path where the file should be copied. + */ +- (void)copyFileAtPath:(NSString *)sourcePath toPath:(NSString *)destinationPath { + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSError *error = nil; + BOOL success; + + // delete destinationPath if it exists + if ([fileManager fileExistsAtPath:destinationPath]) { + success = [fileManager removeItemAtPath: destinationPath error: &error]; + if (!success) { + NSAssert1(0, @"Failed to delete '%@'.", destinationPath); + } + } + + success = [fileManager copyItemAtPath:sourcePath toPath:destinationPath error:&error]; + if (!success) { + NSAssert1(0, @"Failed to copy file '%@'.", [error localizedDescription]); + NSLog(@"Failed to copy %@ file, error %@", sourcePath, [error localizedDescription]); + } else { + NSLog(@"File copied %@ OK", sourcePath); + } +} + +- (NSString*) getResultPath { + return self.resultPath; +} + +- (BOOL) getTestStatus { + return self.testStatus; +} +@end diff --git a/test/ios/ios_test_runner.cpp b/platform/ios/test/core/ios_test_runner.cpp similarity index 95% rename from test/ios/ios_test_runner.cpp rename to platform/ios/test/core/ios_test_runner.cpp index c99d8c3f3..c5a5ff046 100644 --- a/test/ios/ios_test_runner.cpp +++ b/platform/ios/test/core/ios_test_runner.cpp @@ -25,7 +25,7 @@ bool TestRunner::startTest(const std::string& basePath) { mbgl::Log::Info(mbgl::Event::General, "Start TestRunner"); int status = mbgl::runTests(static_cast(argv.size()), argv.data()); - mbgl::Log::Info(mbgl::Event::General, "TestRunner finished with status: '%d'", status); + mbgl::Log::Info(mbgl::Event::General, "TestRunner finished with status: '" + std::to_string(status) + "'"); return status == 0; } diff --git a/render-test/ios/BUILD.bazel b/render-test/ios/BUILD.bazel index 18afc682f..6225ee537 100644 --- a/render-test/ios/BUILD.bazel +++ b/render-test/ios/BUILD.bazel @@ -62,5 +62,6 @@ ios_unit_test( ) exports_files([ + "Empty.plist", "Info.plist", ]) diff --git a/src/mbgl/util/bounding_volumes.cpp b/src/mbgl/util/bounding_volumes.cpp index 742a33134..b57009a22 100644 --- a/src/mbgl/util/bounding_volumes.cpp +++ b/src/mbgl/util/bounding_volumes.cpp @@ -213,13 +213,15 @@ IntersectionResult Frustum::intersects(const AABB& aabb) const { bool fullyInside = true; + const auto epsilon = 1e-10; + for (const vec4& plane : planes) { size_t pointsInside = 0; - pointsInside += vec4Dot(plane, aabbPoints[0]) >= 0.0; - pointsInside += vec4Dot(plane, aabbPoints[1]) >= 0.0; - pointsInside += vec4Dot(plane, aabbPoints[2]) >= 0.0; - pointsInside += vec4Dot(plane, aabbPoints[3]) >= 0.0; + pointsInside += vec4Dot(plane, aabbPoints[0]) >= -epsilon; + pointsInside += vec4Dot(plane, aabbPoints[1]) >= -epsilon; + pointsInside += vec4Dot(plane, aabbPoints[2]) >= -epsilon; + pointsInside += vec4Dot(plane, aabbPoints[3]) >= -epsilon; if (!pointsInside) { // Separating axis found, no intersection diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 5c8798780..24c66d8f0 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -13,45 +13,84 @@ cc_library( cc_library( name = "testlib", - srcs = glob( - [ - "src/mbgl/test/*.cpp", - ], - exclude = [ - "src/mbgl/test/test.cpp", - "src/mbgl/test/http_server.cpp", - ], - ), + srcs = select({ + "//:ios": glob( + ["src/mbgl/test/*.cpp"], + allow_empty = False, + ), + "//conditions:default": glob( + ["src/mbgl/test/*.cpp"], + allow_empty = False, + exclude = ["src/mbgl/test/http_server.cpp"], + ), + }) + [ + "include/mbgl/test.hpp", + ], hdrs = glob([ "src/mbgl/test/*.hpp", ]), - copts = CPP_FLAGS + MAPLIBRE_FLAGS, + copts = CPP_FLAGS + MAPLIBRE_FLAGS + select({ + "//:ios": ["-DUSE_CPP_TEST_SERVER"], + "//conditions:default": [], + }), + includes = [ + "include", + ], strip_include_prefix = "src", + visibility = [ + "//platform/ios/test/core:__pkg__", + ], deps = [ "testutils", "//:mbgl-core", - ], + ] + select({ + "//:ios": ["//vendor:httplib"], + "//conditions:default": [], + }), ) -cc_test( - name = "core", +cc_library( + name = "tests", srcs = glob( [ "**/*.test.cpp", ], ), - args = [ - "--gtest_filter=-Map.StyleNetworkErrorRetry:Map.StyleNotFound:MainResourceLoader.CachedResourceLowPriority", - ], copts = CPP_FLAGS + MAPLIBRE_FLAGS, - data = glob(["fixtures/**/*"]) + [ - "//:scripts/style-spec-reference/v8.json", + visibility = [ + "//platform/ios/test/core:__pkg__", ], deps = [ "testlib", "testutils", "//:mbgl-core", - "//platform/linux:impl", + "//platform/default:mbgl-default", "//vendor/googletest:gtest_main", ], + alwayslink = True, +) + +filegroup( + name = "fixtures", + srcs = glob( + ["fixtures/**/*"], + allow_empty = False, + ), + visibility = [ + "//platform/ios/test/core:__pkg__", + ], +) + +cc_test( + name = "core", + args = [ + "--gtest_filter=-Map.StyleNetworkErrorRetry:Map.StyleNotFound:MainResourceLoader.CachedResourceLowPriority", + ], + data = glob(["fixtures/**/*"]) + [ + "//:scripts/style-spec-reference/v8.json", + ], + deps = [ + "tests", + "//platform/linux:impl", + ], ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 118fd100c..ae4a2036d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -187,18 +187,6 @@ target_include_directories( include(${PROJECT_SOURCE_DIR}/vendor/cpp-httplib.cmake) include(${PROJECT_SOURCE_DIR}/vendor/googletest.cmake) -if(CMAKE_SYSTEM_NAME STREQUAL iOS) - set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}") - set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") - set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode) - set_target_properties(mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) - - set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_DEPLOYMENT_TARGET}") - set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") - set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode) - set_target_properties(mbgl-test PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) -endif() - if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set_target_properties(mbgl-test mbgl-vendor-googletest PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH $<$:YES>) set_target_properties(mbgl-test mbgl-vendor-googletest diff --git a/test/src/mbgl/test/test.cpp b/test/src/mbgl/test/test.cpp index ad1f1491f..632d77497 100644 --- a/test/src/mbgl/test/test.cpp +++ b/test/src/mbgl/test/test.cpp @@ -7,7 +7,7 @@ namespace mbgl { int runTests(int argc, char *argv[]) { -#if TEST_HAS_SERVER && defined(__QT__) +#if (TEST_HAS_SERVER && defined(__QT__)) || USE_CPP_TEST_SERVER auto server = std::make_unique(); #endif diff --git a/test/storage/sync_file_source.test.cpp b/test/storage/sync_file_source.test.cpp index 5d108929b..8a87ba141 100644 --- a/test/storage/sync_file_source.test.cpp +++ b/test/storage/sync_file_source.test.cpp @@ -43,7 +43,7 @@ public: virtual void setClientOptions(ClientOptions) override {} - virtual ClientOptions getClientOptions() { return ClientOptions{}; } + virtual ClientOptions getClientOptions() override { return ClientOptions{}; } private: std::unordered_map> assets; diff --git a/vendor/BUILD.bazel b/vendor/BUILD.bazel index 29e84782b..8dc598375 100644 --- a/vendor/BUILD.bazel +++ b/vendor/BUILD.bazel @@ -137,6 +137,14 @@ cc_library( visibility = ["//visibility:public"], ) +cc_library( + name = "httplib", + hdrs = ["cpp-httplib/httplib.h"], + copts = CPP_FLAGS, + includes = ["cpp-httplib"], + visibility = ["//visibility:public"], +) + # vendor/protozero-files.json cc_library( name = "protozero",