Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ jobs:
- name: Test
run: swift test

bazel:
runs-on: macOS-latest
strategy:
fail-fast: false
matrix:
MODE: [ "dbg", "opt" ]
env:
USE_BAZEL_VERSION: 8.x
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
bazelisk-cache: true
repository-cache: true
- name: bazel build
run: |
bazelisk build --enable_bzlmod -c "${{ matrix.MODE }}" //...
- name: bazel test
if: ${{ matrix.MODE == 'dbg' }}
run: |
bazelisk test --enable_bzlmod --build_tests_only -c "${{ matrix.MODE }}" --test_output=all --verbose_failures //...

cocoapods:
strategy:
matrix:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

Packages/
.build/
.swiftpm/
*.resolved
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

# Bazel

Expand Down
38 changes: 16 additions & 22 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ licenses(["notice"]) # Apache 2.0
exports_files(["LICENSE"])

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

OBJC_COPTS = [
Expand Down Expand Up @@ -81,7 +82,8 @@ objc_library(
ios_unit_test(
name = "Tests",
minimum_os_version = MINIMUM_OS_VERSION,
test_host = ":TestHostApp",
target_compatible_with = ["@platforms//os:ios"],
runner = "@rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
deps = [
":FBLPromisesInteroperabilityTests",
":FBLPromisesPerformanceTests",
Expand All @@ -92,30 +94,20 @@ ios_unit_test(
],
)

ios_application(
name = "TestHostApp",
testonly = 1,
bundle_id = "com.google.promises.TestHost",
families = [
"iphone",
"ipad",
],
infoplists = [
"Promises.xcodeproj/TestHost_Info.plist",
],
minimum_os_version = MINIMUM_OS_VERSION,
macos_unit_test(
name = "Tests_macOS",
minimum_os_version = "10.15",
target_compatible_with = ["@platforms//os:osx"],
deps = [
":TestHost",
":FBLPromisesInteroperabilityTests",
":FBLPromisesPerformanceTests",
":FBLPromisesTests",
":PromisesInteroperabilityTests",
":PromisesPerformanceTests",
":PromisesTests",
],
)

swift_library(
name = "TestHost",
testonly = 1,
srcs = glob([
"Tests/TestHost/*.swift",
]),
)

swift_library(
name = "PromisesTests",
Expand Down Expand Up @@ -172,8 +164,10 @@ objc_library(
]),
copts = OBJC_COPTS,
includes = [
"../Promises",
"Promises",
],
enable_modules = True,
module_name = "FBLPromisesInteroperabilityTests",
deps = [
":FBLPromisesTestHelpers",
":PromisesTestHelpers",
Expand Down
12 changes: 12 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module(name = "promises", version = "2.4.0")

bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_apple", version = "3.20.1", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "2.7.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "apple_support", version = "1.20.0")

apple_cc_configure = use_extension("@apple_support//crosstool:setup.bzl", "apple_cc_configure_extension")
use_repo(apple_cc_configure, "local_config_apple_cc", "local_config_apple_cc_toolchains")

register_toolchains("@local_config_apple_cc_toolchains//:all")
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
limitations under the License.
*/

// Currently this test does not work with Bazel.
// See https://github.com/bazelbuild/rules_apple/issues/2690 for more details.
#if defined(COCOAPODS) || defined(SWIFT_PACKAGE)

#import "FBLPromise+Catch.h"

#import <XCTest/XCTest.h>
Expand Down Expand Up @@ -65,3 +69,5 @@ - (void)testPromiseThrow {
}

@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
limitations under the License.
*/

// Currently this test does not work with Bazel.
// See https://github.com/bazelbuild/rules_apple/issues/2690 for more details.
#if defined(COCOAPODS) || defined(SWIFT_PACKAGE)

#import "FBLPromise+Then.h"

#import <XCTest/XCTest.h>
Expand Down Expand Up @@ -59,3 +63,5 @@ - (void)testPromiseFulfillNumberNonNil {
}

@end

#endif
6 changes: 3 additions & 3 deletions Tests/PromisesTests/Promise+ThenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ class PromiseThenTests: XCTestCase {
XCTAssertNil(postFinalPromise.error)
}

func testPromiseWhenNilBridgesToNSNullInThenChain() {
func testPromiseWhenNilBridgesToNilInThenChain() {
// Act.
let promise = Promise<Any?> { fulfill, _ in
fulfill(nil)
}.catch { _ in
XCTFail()
}.then { value in
XCTAssert(value is NSNull)
XCTAssertNil(value)
}

// Assert.
XCTAssert(waitForPromises(timeout: 10))
XCTAssertTrue(promise.isFulfilled)
XCTAssert(promise.value is NSNull)
XCTAssertNil(promise.value)
XCTAssertNil(promise.error)
}

Expand Down