Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bazel build support for swift-snapshot-testing #191

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

luispadron
Copy link
Collaborator

@luispadron luispadron commented Jan 20, 2024

Refactors the Bazel support to better match the Package.swift structure:

  • The module AccessibilitySnapshot_SnapshotTesting uses swift-snapshot-testing and the AccessibilitySnapshot_iOSSnapshotTestCase modules use iOSSnapshotTestCase.
  • Adds custom BUILD file for swift-snapshot-testing to allow it to build with Bazel. I opted for this vs. registry because it's a simple BUILD files.
  • Adds includes so downstream targets can include the AccessibilitySnapshot headers via #import <>.

@luispadron luispadron requested a review from NickEntin January 20, 2024 20:50
@luispadron luispadron force-pushed the luis/add-support-for-swift-snapshot-testing branch 3 times, most recently from b28ea4c to df562e7 Compare January 20, 2024 21:05
@NickEntin
Copy link
Collaborator

NickEntin commented Jan 21, 2024

The module AccessibilitySnapshot uses swift-snapshot-testing and the FBSnapshotTestCase_Accessibility* modules use iOSSnapshotTestCase.

I think I'd rather be explicit about this (AccessibilitySnapshot_iOSSnapshotTestCase and AccessibilitySnapshot_SnapshotTesting) than assume the primary framework uses SnapshotTesting. The only reason the Package.swift defaults that way is iOSSnapshotTestCase didn't have SPM support when it was written. But seeing how things are going, I don't want to assume we'll stick with any particular snapshot engine for the long term. Eventually we may pull the snapshot comparison logic internally and only provide the SnapshotTesting integration as a convenience to use their method names.

@luispadron
Copy link
Collaborator Author

Ah that's fair, I was copying the Package setup but we can make this explicit on the impl used.

@luispadron luispadron force-pushed the luis/add-support-for-swift-snapshot-testing branch from df562e7 to 61a3519 Compare January 21, 2024 17:22
@luispadron
Copy link
Collaborator Author

luispadron commented Jan 21, 2024

@NickEntin I updated this to move the BUILD.bazel into the individual directories so its more explicit.

Bazel users can depend on either //Sources/Accessibility/SnapshotTesting/... targets or //Sources/Accessibility/iOSSnapshotTestCase/... targets. They would import it using the same module name import AccessibilitySnapshot (let me know if we instead prefer this import name to also be explicit, I assumed users wouldn't use both implementations in the same target)

Also updated the README with Bazel instructions

@luispadron luispadron force-pushed the luis/add-support-for-swift-snapshot-testing branch 2 times, most recently from 3169bd8 to 0cce641 Compare January 21, 2024 17:26
@luispadron luispadron force-pushed the luis/add-support-for-swift-snapshot-testing branch from 0cce641 to f234c83 Compare January 23, 2024 06:16
@NickEntin NickEntin linked an issue Jan 24, 2024 that may be closed by this pull request
Refactors the Bazel support to better match the Package.swift structure:

- Makes the following targets available: `AccessibilitySnapshotCore`, `AccessibilitySnapshotCore_ObjC`, `FBSnapshotTestCase_Accessibility`, `FBSnapshotTestCase_Accessibility_ObjC`, `AccessibilitySnapshot`.
- The module `AccessibilitySnapshot` uses `swift-snapshot-testing` and the `FBSnapshotTestCase_Accessibility*` modules use `iOSSnapshotTestCase`.
- Adds custom BUILD file for `swift-snapshot-testing` to allow it to build with Bazel. I opted for this vs. registry because it's a simple BUILD files.
@luispadron luispadron force-pushed the luis/add-support-for-swift-snapshot-testing branch from f234c83 to ba69788 Compare January 29, 2024 20:57
@NickEntin NickEntin merged commit 07c283f into master Feb 22, 2024
9 checks passed
@NickEntin NickEntin deleted the luis/add-support-for-swift-snapshot-testing branch February 22, 2024 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support installing natively via Bazel
2 participants