-
Notifications
You must be signed in to change notification settings - Fork 141
Migrate from XCTest to Swift Testing #229
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
Conversation
3135ab1
to
d448cfa
Compare
80245da
to
a1f455d
Compare
Fix race condition in moveDownloadedFile Pass hubApiForTests to AutoTokenizer.from calls Consolidate BERT uncased tests Conditionalize integration tests on HF_TOKEN
This reverts commit 63eef12b1f3899a89dd7e0e376687fefd2f3f091.
a1f455d
to
2ff616f
Compare
3c181ca
to
6b95a5d
Compare
… conditions in tests
…avoid race conditions in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me from a quick look – I did visit the individual commits and the history makes sense to me.
Are parallel tokenizer tests still revealing race conditions?
XCTFail("Unexpected error: \(error)", file: file, line: line) | ||
} | ||
/// Check if two floating-point arrays are equal within a given accuracy | ||
func isClose<T: FloatingPoint>(_ lhs: [T], _ rhs: [T], accuracy: T) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. This could become a general utility function later, like Pytorch or MLX allClose
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would be nice. Official guidance from the Swift team for replacing the XCTest assertion with accuracy is to pull in swift-numerics to use their implementation of isApproximatelyEqual
. Pulling that in as a separate dependency just for tests is overkill, but we could certainly vendor it.
Ah, I see they work now! |
Yes, that's the race conditions I was mentioning before. There's a more comprehensive change we can do to make that reentrancy safe, but for now it's much easier to ensure that we don't have more than one test calling |
Ooh, nice — after making everything parallel again, we're now down to 3 minutes 40 seconds 🚀 |
This PR migrates most of our tests from XCTest to the new Swift Testing framework, which has better ergonomics and performance.