Skip to content

Commit

Permalink
chore: Add example showcasing modulemap issues
Browse files Browse the repository at this point in the history
Adds an example showing issues with modulemap logic in both sandboxed and non-sandboxed builds.
  • Loading branch information
luispadron committed Nov 26, 2024
1 parent e5c73a4 commit 3c0f64c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
14 changes: 14 additions & 0 deletions examples/interesting_deps/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_unit_test")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary")
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")

Expand Down Expand Up @@ -46,6 +47,19 @@ swift_binary(
],
)

objc_library(
name = "objc_test.lib",
srcs = ["objc_test.m"],
enable_modules = True,
deps = ["@swiftpkg_ocmock//:OCMock"],
)

macos_unit_test(
name = "objc_test",
minimum_os_version = "10.15",
deps = [":objc_test.lib"],
)

sh_test(
name = "simple_test",
srcs = ["simple_test.sh"],
Expand Down
6 changes: 6 additions & 0 deletions examples/interesting_deps/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ bazel_dep(
version = "2.2.4",
repo_name = "build_bazel_rules_swift",
)
bazel_dep(
name = "rules_apple",
version = "3.6.0",
repo_name = "build_bazel_rules_apple",
)

bazel_dep(
name = "bazel_skylib_gazelle_plugin",
Expand Down Expand Up @@ -70,6 +75,7 @@ use_repo(
"swiftpkg_cocoalumberjack",
"swiftpkg_geoswift",
"swiftpkg_libwebp_xcode",
"swiftpkg_ocmock",
"swiftpkg_opencombine",
"swiftpkg_swift_log",
)
21 changes: 15 additions & 6 deletions examples/interesting_deps/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/GEOSwift/geos.git",
"state" : {
"revision" : "f510e634c822116fca615064d889300dba40d761",
"version" : "8.1.0"
"revision" : "4d8af495e7507f48f1ae9104102debdd2043917b",
"version" : "9.0.0"
}
},
{
"identity" : "geoswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/GEOSwift/GEOSwift",
"state" : {
"revision" : "2d23ede8c82c067655d3a9f0221bc73f08cd399a",
"version" : "10.1.0"
"revision" : "e42c062c2feb0df61373ae8cd6031a823a0dc981",
"version" : "11.0.0"
}
},
{
Expand All @@ -36,6 +36,15 @@
"version" : "1.3.2"
}
},
{
"identity" : "ocmock",
"kind" : "remoteSourceControl",
"location" : "https://github.com/erikdoe/ocmock",
"state" : {
"revision" : "2c0bfd373289f4a7716db5d6db471640f91a6507",
"version" : "3.9.4"
}
},
{
"identity" : "opencombine",
"kind" : "remoteSourceControl",
Expand All @@ -50,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log",
"state" : {
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
"version" : "1.6.2"
}
}
],
Expand Down
1 change: 1 addition & 0 deletions examples/interesting_deps/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ let package = Package(
.package(url: "https://github.com/OpenCombine/OpenCombine", from: "0.14.0"),
.package(url: "https://github.com/SDWebImage/libwebp-Xcode.git", from: "1.3.2"),
.package(url: "https://github.com/apple/swift-log", from: "1.6.1"),
.package(url: "https://github.com/erikdoe/ocmock", from: "3.9.0"),
]
)
10 changes: 7 additions & 3 deletions examples/interesting_deps/do_test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -o errexit -o nounset -o pipefail

# Use the Bazel binary specified by the integration test. Otherise, fall back
# Use the Bazel binary specified by the integration test. Otherwise, fall back
# to bazel.
bazel="${BIT_BAZEL_BINARY:-bazel}"

Expand All @@ -12,5 +12,9 @@ bazel="${BIT_BAZEL_BINARY:-bazel}"
# Test resolving the package via the `swift_package` repo.
"${bazel}" run @swift_package//:resolve

# Ensure that it builds and tests pass
"${bazel}" test //...
# Ensure that it builds in both sandbox and local strategies.
# This tests issues with modulemap generation.
bazel clean --expunge && \
"${bazel}" test //... --spawn_strategy=sandboxed
bazel clean --expunge && \
"${bazel}" test //... --spawn_strategy=local
16 changes: 16 additions & 0 deletions examples/interesting_deps/objc_test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#import <OCMock/OCMock.h>

@import Foundation;
@import XCTest;

@interface ObjcTest : XCTestCase
@end

@implementation ObjcTest

- (void)testMock {
OCMockObject *mock = [OCMockObject mockForClass:[NSObject class]];
XCTAssertNotNil(mock);
}

@end

0 comments on commit 3c0f64c

Please sign in to comment.