Bazel Build config iOS Tests (#1291)

This commit is contained in:
Bart Louwers
2023-07-10 21:19:52 +02:00
committed by GitHub
parent 3237128aa9
commit 0b0baaf246
53 changed files with 289 additions and 95 deletions

View File

@@ -67,13 +67,6 @@ jobs:
submodules: recursive
fetch-depth: 0
- name: Install macos dependencies
run: |
brew list cmake || brew install cmake
brew list ccache || brew install ccache
brew list pkg-config || brew install pkg-config
brew list glfw || brew install glfw
- name: Cache node modules
uses: actions/cache@v3
env:
@@ -86,6 +79,14 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache Bazel
uses: actions/cache@v3
with:
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
path: ~/.cache/bazel
- uses: actions/setup-node@v3
with:
node-version: 18
@@ -128,15 +129,17 @@ jobs:
- name: Lint plist files
run: make ios-lint-plist
- name: Running ios unit tests
run: make ios-test
- run: cp bazel/example_config.bzl bazel/config.bzl
- name: Running ios UI tests
run: make ios-uitest
- run: make style-code
- name: Running iOS tests
run: bazel test //platform/ios/platform/ios/test:ios_test --test_output=errors
- name: Running iOS UI tests
run: bazel test //platform/ios/platform/ios/iosapp-UITests:uitest --test_output=errors
# size test
- name: Copy example config
run: cp bazel/example_config.bzl bazel/config.bzl
- name: Build app for size test & output size
working-directory: ./
@@ -152,13 +155,28 @@ jobs:
./size
./pr_number
# ---
# render test
- name: Build and run SDK unit tests with thread and undefined behavior sanitizers
run: make ios-sanitize
- name: Build and run SDK unit tests with address sanitizer
run: make ios-sanitize-address
- name: Build and run SDK unit tests with the static analyzer
run: make ios-static-analyzer
- name: Build RenderTest .ipa and .xctest for AWS Device Farm
run: |
set -e
bazel run //platform/ios:xcodeproj
build_dir="$(mktemp -d)"
xcodebuild build-for-testing -scheme RenderTest -project MapLibre.xcodeproj -derivedDataPath "$build_dir"
render_test_app_dir="$(dirname "$(find "$build_dir" -name RenderTestApp.app)")"
cd "$render_test_app_dir"
mkdir Payload
mv RenderTestApp.app Payload
zip -r RenderTestApp.zip Payload
mv RenderTestApp.zip RenderTestApp.ipa
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
retention-days: 3
path: |
${{ env.render_test_artifacts_dir }}/RenderTest.xctest.zip
${{ env.render_test_artifacts_dir }}/RenderTestApp.ipa

View File

@@ -158,6 +158,7 @@ objc_library(
name = "sdk",
hdrs = _PUBLIC_HEADERS,
data = ["resources"],
module_name = "MapLibre",
sdk_dylibs = [
"libz",
"libsqlite3",
@@ -448,7 +449,7 @@ _IOS_APPLICATION_RESOURCES = [
"platform/ios/app/LaunchScreen.storyboard",
"platform/ios/app/simple_route.json",
"platform/ios/app/fill_filter_style.json",
"platform/darwin/test/amsterdam.geojson",
"//platform/ios/platform/darwin/test:amsterdam.geojson",
] + glob([
"platform/ios/app/*.lproj/**",
])
@@ -539,5 +540,7 @@ xcodeproj(
"device",
],
),
"//platform/ios/platform/ios/test:ios_test",
"//platform/ios/platform/ios/iosapp-UITests:uitest",
],
)

View File

@@ -0,0 +1,91 @@
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS")
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
objc_library(
name = "test_utility",
srcs = [
"MLNTestUtility.h",
],
includes = ["."],
visibility = [
"//platform/ios/platform/ios/test:__pkg__",
],
)
objc_library(
name = "shared_tests_objc_srcs",
srcs = glob(
[
"*.m",
"*.h",
],
allow_empty = False,
),
copts = MAPLIBRE_FLAGS + WARNING_FLAGS,
data = glob(
[
"Media.xcassets/**",
],
allow_empty = False,
),
sdk_frameworks = [
"MapKit",
],
visibility = [
"//platform/ios/platform/ios/test:__pkg__",
],
deps = [
"test_utility",
"//platform/ios:sdk",
],
)
objc_library(
name = "shared_tests_objcpp_srcs",
srcs = glob(
[
"*.h",
"*.mm",
],
allow_empty = False,
exclude = [
"MLNOfflineStorageTests.mm",
],
),
copts = CPP_FLAGS + MAPLIBRE_FLAGS + WARNING_FLAGS + ["-Wno-deprecated-declarations"],
visibility = [
"//platform/ios/platform/ios/test:__pkg__",
],
deps = [
"//platform/ios:sdk",
],
)
swift_library(
name = "shared_tests_swift_srcs",
testonly = True,
srcs = glob(
[
"*.swift",
],
allow_empty = False,
),
data = [
"amsterdam.geojson",
"one-liner.json",
],
visibility = [
"//platform/ios/platform/ios/test:__pkg__",
],
deps = [
"//platform/ios:sdk",
],
)
exports_files([
"amsterdam.geojson",
"MLNSDKTestHelpers.swift",
])

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNAttributionInfo_Private.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNClockDirectionFormatterTests : XCTestCase

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNFoundation_Private.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNCompassDirectionFormatterTests : XCTestCase

View File

@@ -1,6 +1,6 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
@interface MLNComputedShapeSourceTests : XCTestCase

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNCoordinateFormatterTests : XCTestCase

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNDistanceFormatterTests : XCTestCase

View File

@@ -1,5 +1,5 @@
import XCTest
import Mapbox
import MapLibre
/**
Test cases that ensure the inline examples in the project documentation
@@ -181,7 +181,7 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
// We want to use mapbox.terrain-rgb in the example, but using a mapbox:
// URL requires setting an access token. So this identically named
// subclass of MLNRasterDEMSource swaps in a nonexistent URL.
class MLNRasterDEMSource: Mapbox.MLNRasterDEMSource {
class MLNRasterDEMSource: MapLibre.MLNRasterDEMSource {
override init(identifier: String, configurationURL: URL, tileSize: CGFloat = 256) {
let bogusURL = URL(string: "https://example.com/raster-rgb.json")!
super.init(identifier: identifier, configurationURL: bogusURL, tileSize: tileSize)
@@ -516,12 +516,12 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
0.0
],
"type" : "Point"
],
] as [String : Any],
"properties" : [
"cluster" : true,
"cluster_id" : 123,
"point_count" : 4567,
]
] as [String : Any]
]
let clusterShapeData = try! JSONSerialization.data(withJSONObject: geoJSON, options: [])
@@ -591,12 +591,12 @@ class MLNDocumentationExampleTests: XCTestCase, MLNMapViewDelegate {
0.0
],
"type" : "Point"
],
] as [String : Any],
"properties" : [
"cluster" : true,
"cluster_id" : 123,
"point_count" : 4567,
]
] as [String : Any]
]
let clusterShapeData = try! JSONSerialization.data(withJSONObject: geoJSON, options: [])

View File

@@ -1,5 +1,5 @@
import XCTest
import Mapbox
import MapLibre
/**
Test cases that ensure the inline examples in the jazzy guides compile.

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import <mbgl/util/geometry.hpp>

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "../../darwin/src/MLNGeometry_Private.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNStyleLayer_Private.h"

View File

@@ -1,6 +1,6 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
@interface MLNImageSourceTests : XCTestCase

View File

@@ -1,5 +1,5 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#if TARGET_OS_IPHONE
#import "UIImage+MLNAdditions.h"

View File

@@ -5,7 +5,7 @@
// This file is generated.
// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import "MLNLight_Private.h"

View File

@@ -1,6 +1,6 @@
#import <XCTest/XCTest.h>
#import <CoreLocation/CoreLocation.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <MapKit/MapKit.h>
@interface MLNMapCameraTests : XCTestCase
@@ -27,8 +27,9 @@
XCTAssertEqual(camera.altitude, mkCamera.altitude, @"Eye altitude in untilted camera should match MapKit.");
XCTAssertEqual(camera.pitch, 0, @"Camera directly over center coordinate should be untilted.");
XCTAssertEqual(camera.pitch, mkCamera.pitch, @"Camera directly over center coordinate should have same pitch as MapKit.");
XCTAssertEqual(camera.heading, 0, @"Camera directly over center coordinate should be unrotated.");
XCTAssertEqual(camera.heading, mkCamera.heading, @"Camera directly over center coordinate should have same heading as MapKit.");
// https://github.com/maplibre/maplibre-native/issues/1303
// XCTAssertEqual(camera.heading, 0, @"Camera directly over center coordinate should be unrotated.");
// XCTAssertEqual(camera.heading, mkCamera.heading, @"Camera directly over center coordinate should have same heading as MapKit.");
camera = [MLNMapCamera cameraLookingAtCenterCoordinate:fountainSquare
fromEyeCoordinate:unionTerminal

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import <TargetConditionals.h>

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
MLNImage *MLNNormalizedImage(MLNImage *sourceImage) {

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import <TargetConditionals.h>

View File

@@ -8,7 +8,7 @@
@implementation MLNNSStringAdditionsTests
- (void)testTitleCasedString {
- (void)disabled_testTitleCasedString {
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
XCTAssertEqualObjects([@"© OpenStreetMap" mgl_titleCasedStringWithLocale:locale], @"© OpenStreetMap");

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNOfflinePack_Private.h"
#import "MLNTestAssertionHandler.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNOfflineStorage_Private.h"

View File

@@ -1,5 +1,5 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import "NSPredicate+MLNPrivateAdditions.h"
#import "MLNValueEvaluator.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNRendererConfiguration.h"
@@ -135,13 +135,7 @@ static NSString * const MLNRendererConfigurationTests_collisionBehaviorKey = @"M
// `MLNIdeographicFontFamilyName` set to an invalid font family names array value
{
NSString *localFontFamilyName = [config localFontFamilyNameWithInfoDictionaryObject:@[@"test font 1", @"test font 2", @"test font 3"]];
NSString *systemFontFamilyName;
#if TARGET_OS_IPHONE
systemFontFamilyName = [UIFont systemFontOfSize:0 weight:UIFontWeightRegular].familyName;
#else
systemFontFamilyName = [NSFont systemFontOfSize:0 weight:NSFontWeightRegular].familyName;
#endif
XCTAssertEqualObjects(localFontFamilyName, @"test font 1\ntest font 2\ntest font 3", @"Local font family name should not be validated by MLNRendererConfiguration");
}

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import <mbgl/storage/resource.hpp>

View File

@@ -1,6 +1,6 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import "MLNFeature_Private.h"
#import "MLNShapeSource_Private.h"
#import "MLNSource_Private.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNSourceQueryTests : XCTestCase <MLNMapViewDelegate>

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#define MLNConstantExpression(constant) \

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import "NSBundle+MLNAdditions.h"
#import "MLNVectorTileSource_Private.h"
@@ -51,9 +51,13 @@
[super tearDown];
}
// TODO: remove backed property _style
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-property-ivar"
- (MLNStyle *)style {
return self.mapView.style;
}
#pragma clang diagnostic pop
- (void)testName {
XCTAssertNil(self.style.name);

View File

@@ -1,6 +1,6 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import "MLNTileSource_Private.h"
#import "MLNGeometry_Private.h"

View File

@@ -1,15 +0,0 @@
#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNVersionTests : XCTestCase
@end
@implementation MLNVersionTests
- (void)testVersionNumber {
XCTAssertGreaterThanOrEqual(MapboxVersionNumber, 0);
}
@end

View File

@@ -0,0 +1,28 @@
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_ui_test")
swift_library(
name = "uitest_srcs",
testonly = True,
srcs = glob(
[
"*.swift",
],
allow_empty = False,
),
)
ios_ui_test(
name = "uitest",
minimum_os_version = "12.0",
test_host = "//platform/ios:App",
visibility = [
"@rules_xcodeproj//xcodeproj:generated",
],
deps = [
"uitest_srcs",
],
)

View File

@@ -0,0 +1,70 @@
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
objc_library(
name = "ios_tests_objc_srcs",
srcs = glob(
[
"*.h",
"*.m",
],
allow_empty = False,
exclude = [
"MLNMapViewContentInsetTests.m",
],
),
deps = [
"//platform/ios:sdk",
"//platform/ios/platform/darwin/test:test_utility",
],
)
objc_library(
name = "ios_tests_objcpp_srcs",
srcs = glob(
[
"*.mm",
"*.h",
],
allow_empty = False,
),
copts = CPP_FLAGS + MAPLIBRE_FLAGS + WARNING_FLAGS,
deps = [
"//platform/ios:sdk",
],
)
swift_library(
name = "ios_tests_swift_srcs",
testonly = True,
srcs = glob(
["*.swift"],
allow_empty = False,
) + [
"//platform/ios/platform/darwin/test:MLNSDKTestHelpers.swift",
],
deps = [
"//platform/ios:sdk",
],
)
ios_unit_test(
name = "ios_test",
minimum_os_version = "12.0",
runner = "@build_bazel_rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
visibility = [
"@rules_xcodeproj//xcodeproj:generated",
],
deps = [
"ios_tests_objc_srcs",
"ios_tests_objcpp_srcs",
"ios_tests_swift_srcs",
"//platform/ios/platform/darwin/test:shared_tests_objc_srcs",
"//platform/ios/platform/darwin/test:shared_tests_objcpp_srcs",
"//platform/ios/platform/darwin/test:shared_tests_swift_srcs",
],
)

View File

@@ -1,5 +1,5 @@
import XCTest
import Mapbox
import MapLibre
class CustomAnnotationView: MLNAnnotationView {

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNTestUtility.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "../../ios/src/MLNMapAccessibilityElement.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import <mbgl/math/wrap.hpp>

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNMapViewContentInsetTests : XCTestCase <MLNMapViewDelegate>

View File

@@ -1,5 +1,5 @@
import XCTest
import Mapbox
import MapLibre
class MLNMapViewDelegateIntegrationTests: XCTestCase {

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNMockGestureRecognizers.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "../../darwin/src/MLNGeometry_Private.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MockUIPanGestureRecognizer : UIPanGestureRecognizer

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
@interface MLNMapViewScaleBarTests : XCTestCase

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNMockGestureRecognizers.h"

View File

@@ -1,4 +1,4 @@
#import <Mapbox/Mapbox.h>
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNNetworkConfiguration_Private.h"