You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apple Swift version 5.3-dev (LLVM d2c5a6fb91, Swift 4eac5a1f0f) Target: x86_64-apple-darwin19.5.0
swift build --version:
Swift Package Manager - Swift 5.3.0
Additional Detail from JIRA
Votes
7
Component/s
Package Manager
Labels
Bug
Assignee
Steven0351 (JIRA)
Priority
Medium
md5: a0e09b8dd3c59c4e33ec01211d8f9f6c
Issue Description:
When using resources in combination with testTargets, the resources cannot be found. This happens regardless if the resource is in a library which is being tested or in the test target itself. The resource is being loaded via the new Bundle.module.
This is where the xctest executable is located. Te loading happens in the resource_bundle_accessor.swift which the SPM writes. In there it uses Bundle.main.bundlePath to get the bundle path. According to https://forums.swift.org/t/bundle-main-path-pointing-to-odd-path/13814 it is correct that Bundle.main in case of test execution points to the directory of the xctest executable.
Therefor I think the resource_bundle_accessor.swift needs adjustment to find the correct bundle path in case of test targets. The resources are correctly copied to a bundle in the .build directory
Attachment: Download
Environment
swiftenv version
:swift version
:swift build --version
:Additional Detail from JIRA
md5: a0e09b8dd3c59c4e33ec01211d8f9f6c
Issue Description:
When using resources in combination with testTargets, the resources cannot be found. This happens regardless if the resource is in a library which is being tested or in the test target itself. The resource is being loaded via the new Bundle.module.
For minimal reproducible code including full debug output see https://github.com/Nef10/SPMResourcesInTest (or attachment)
The code tries to load the bundle from
This is where the xctest executable is located. Te loading happens in the resource_bundle_accessor.swift which the SPM writes. In there it uses Bundle.main.bundlePath to get the bundle path. According to https://forums.swift.org/t/bundle-main-path-pointing-to-odd-path/13814 it is correct that Bundle.main in case of test execution points to the directory of the xctest executable.
Therefor I think the resource_bundle_accessor.swift needs adjustment to find the correct bundle path in case of test targets. The resources are correctly copied to a bundle in the .build directory
See also https://forums.swift.org/t/swift-5-3-spm-resources-in-tests-uses-wrong-bundle-path/37051
The text was updated successfully, but these errors were encountered: