Test targets fail to build
setoelkahfi opened this issue · 2 comments
setoelkahfi commented
I'm trying to integrate this example into my project, but I got this error:
❯ bazel run //frontend/apple/modules/API:APITests
INFO: Invocation ID: 47436f24-94e6-46b1-a109-e72db4cba6c0
INFO: Streaming build results to: https://app.buildbuddy.io/invocation/47436f24-94e6-46b1-a109-e72db4cba6c0
ERROR: /setoelka/tauri-on-bazel/frontend/apple/modules/Models/BUILD.bazel:7:14: in @@rules_apple~//apple/internal/aspects:resource_aspect.bzl%apple_resource_aspect aspect on swift_library rule //frontend/apple/modules/Models:ModelsLib:
Traceback (most recent call last):
File "/private/var/tmp/_bazel_setoelka/55d40751772f9cc52358541c06338f83/external/rules_apple~/apple/internal/aspects/resource_aspect.bzl", line 146, column 47, in _apple_resource_aspect_impl
module_names = [x.name for x in target[SwiftInfo].direct_modules if x.swift]
Error: <target //frontend/apple/modules/Models:ModelsLib> (rule 'swift_library') doesn't contain declared provider 'SwiftInfo'
ERROR: Analysis of target '//frontend/apple/modules/Models:ModelsLib' failed
ERROR: Analysis of target '//frontend/apple/modules/API:APITests' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.196s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
They're the ios_unit_test
targets in the API
and Models
directory.
I moved the example folder to frontend/apple/
directory in my already setup project. They succeeded when I ran the same targets in the original example folder. Any pointers? I tried to update the external dependencies to the latest, but still no luck.
My BUILD files
API/BUILD.bazel
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("//frontend/apple/tools:shared.bzl", "versions")
# Code
swift_library(
name = "APILib",
srcs = [
"API/API.swift",
],
module_name = "API",
visibility = ["//frontend/apple/modules:default_library_visibility"],
deps = [
"//frontend/apple/modules/Models:ModelsLib",
],
)
# Tests
swift_library(
name = "APITestsLib",
testonly = True,
srcs = [
"Tests/APITests.swift",
],
module_name = "APITests",
deps = [
":APILib",
],
)
ios_unit_test(
name = "APITests",
minimum_os_version = versions.minimum_ios_version,
visibility = ["//frontend/apple/modules:default_test_visibility"],
deps = [":APITestsLib"],
)
Models/BUILD.bazel
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("//frontend/apple/tools:shared.bzl", "versions")
# Code
swift_library(
name = "ModelsLib",
srcs = [
"Models/Models.swift",
],
module_name = "Models",
visibility = ["//frontend/apple/modules:default_library_visibility"],
)
# Tests
swift_library(
name = "ModelsTestsLib",
testonly = True,
srcs = [
"Tests/ModelsTests.swift",
],
module_name = "ModelsTests",
deps = [
":ModelsLib",
],
)
ios_unit_test(
name = "ModelsTests",
minimum_os_version = versions.minimum_ios_version,
visibility = ["//frontend/apple/modules:default_test_visibility"],
deps = [":ModelsTestsLib"],
)
modules/BUILD.bazel
package_group(
name = "default_library_visibility",
includes = [
# Project generation.
"@rules_xcodeproj//xcodeproj:generated",
],
packages = [
# The application package.
"//frontend/apple/app",
# All other modules.
"//frontend/apple/modules/...",
],
)
package_group(
name = "default_test_visibility",
includes = [
# Project generation.
"@rules_xcodeproj//xcodeproj:generated",
],
)
mattrobmattrob commented
Can you upload a small repro project and/or the contents of MODULE.bazel.lock
? I'll try to take a look.
setoelkahfi commented
@mattrobmattrob my bad. My WORKSPACE
file was the problem. It works fine now.