-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Infra] Reduce test flakes due to async variable assignment #13610
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ class FakeBackendRPCIssuer: NSObject, AuthBackendRPCIssuer { | |
/** @property completeRequest | ||
@brief The last request to be processed by the backend. | ||
*/ | ||
var completeRequest: URLRequest? | ||
var completeRequest: Task<URLRequest, Never>! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the tests, it wouldn't make sense to access this property before doing |
||
|
||
/** @var _handler | ||
@brief A block we must invoke when @c respondWithError or @c respondWithJSON are called. | ||
|
@@ -148,12 +148,12 @@ class FakeBackendRPCIssuer: NSObject, AuthBackendRPCIssuer { | |
requestData = body | ||
// Use the real implementation so that the complete request can | ||
// be verified during testing. | ||
Task { | ||
self.completeRequest = await AuthBackend.request(withURL: requestURL!, | ||
contentType: contentType, | ||
requestConfiguration: request | ||
.requestConfiguration()) | ||
completeRequest = Task { | ||
await AuthBackend.request(withURL: requestURL!, | ||
Comment on lines
+151
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before, assigning this property in the task led to it being resolved later than the method returns, causing for the need to sleep since it was assigned as a side effect of the |
||
contentType: contentType, | ||
requestConfiguration: request.requestConfiguration()) | ||
} | ||
|
||
ncooke3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
decodedRequest = try? JSONSerialization.jsonObject(with: body) as? [String: Any] | ||
} | ||
if let respondBlock { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
I believe this leads to flakes on slower CI machines where this is not a long enough wait.