Skip to content

AINFRA-778 - Make StorageTests a Swift package test target #15794

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Jun 21, 2025

Description

Now that all the frameworks sources are Swift packages (targets in the same Swift package to be precise) we can move the tests there, too. We didn't do that all in one go to avoid big diffs.

Notice:

  • The whole Storage/ folder has been removed, including the dedicated Xcode project
  • No changes in the test code

Testing information

See green CI.

Additionally, you can run the focused Hardware Storage tests by selecting the Hardware Storage scheme from Xcode.

Screenshots


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@mokagio mokagio added this to the 22.8 milestone Jun 21, 2025
@mokagio mokagio self-assigned this Jun 21, 2025
@mokagio mokagio added category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. Testing labels Jun 21, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Jun 21, 2025

2 Warnings
⚠️ Modules/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages as appropriate to your project setup (e.g. in Xcode or by running swift package resolve).
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Number30639
VersionPR #15794
Bundle IDcom.automattic.alpha.woocommerce
Commit552f49b
Installation URL66tcukolhp9jg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

"name" : "WooFoundationTests"
"containerPath" : "container:..\/Yosemite\/Yosemite.xcodeproj",
"identifier" : "B5C9DDFD2087FEC0006B910A",
"name" : "YosemiteTests"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beats me why Xcode changes the order almost every time there is an edit.

@mokagio mokagio marked this pull request as ready for review June 22, 2025 23:32
@mokagio mokagio requested review from a team June 22, 2025 23:33
Base automatically changed from ainfra-780-move-hardwaretests-to-modules to trunk June 23, 2025 02:24
@iamgabrielma iamgabrielma self-assigned this Jun 23, 2025
Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this @mokagio

It does pass CI but I get a crash when running the Storage suite as standalone, specifically on FileStorageTests.test_file_is_loaded() which crashes due force-unwrapping the URL for shipment-provider.plist that we load from the bundle:

Test Case '-[StorageTests.FileStorageTests test_file_is_loaded]' started.
StorageTests/FileStorageTests.swift:25: Fatal error: Unexpectedly found nil while unwrapping an Optional value

I do see the plist file in Tests/StorageTests/Resources, but perhaps the bundle address to FileStorageTests has changed when moving things around?

Separate question, related to the PR but for another time: The suite takes 120+ seconds to run, despite expected to take longer as we seem to write to disk in these tests and perform DB migrations, which makes me think a bunch of these are not needed anymore?

For example: We hold migration tests starting from model 26 to 27, which is 4years+ old and far from being supported when a user installs the app, as well as all the data models since model 1, which was created ~2018 and no user would interact with it now. Thoughts on clearing/deleting some of these?

@mokagio
Copy link
Contributor Author

mokagio commented Jun 23, 2025

@iamgabrielma

It does pass CI but I get a crash when running the Storage suite as standalone, specifically on FileStorageTests.test_file_is_loaded() which crashes due force-unwrapping the URL for shipment-provider.plist that we load from the bundle:

Interesting. It works fine on my end:

image

🤔

I assume you used the Storage scheme, right? I doubt that it would make a difference, but on which device?

@mokagio
Copy link
Contributor Author

mokagio commented Jun 23, 2025

Separate question, related to the PR but for another time: The suite takes 120+ seconds to run, despite expected to take longer as we seem to write to disk in these tests and perform DB migrations, which makes me think a bunch of these are not needed anymore?

I noticed the tests being very slow, too. See #15742 (comment) and p1748498088604749/1748498018.125619-slack-C6H8C3G23. But this conversation made me realize I never tracked the need to look into it. Now done with https://linear.app/a8c/issue/AINFRA-824

@iamgabrielma
Copy link
Contributor

For some reason I didn't get notified of you reply, I've approved it as seems to be on my end only and CI passes in any case, sorry for blocking this.

I assume you used the Storage scheme, right? I doubt that it would make a difference, but on which device?

Yeah, Storage scheme and simulator iPad (A16) - iOS 18.3.1 from Xcode 16.4 🤔

I noticed the tests being very slow, too. See #15742 (comment) and p1748498088604749/1748498018.125619-slack-C6H8C3G23. But this conversation made me realize I never tracked the need to look into it. Now done with https://linear.app/a8c/issue/AINFRA-824

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants