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 simulated location support on testable target configuration #6187
Conversation
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.
Great work π
It would be amazing if we could test the location is added to the test action via an acceptance test. We can add an assertion similar to this that would check the simulated location is added for the test target and you would test that here.
Let me know if you need any help setting that up π€
fileElements.formUnion(runActionGPXFiles) | ||
|
||
let testActionGPXFiles = project.schemes.compactMap { scheme -> [GroupFileElement] in | ||
guard let testAction = scheme.testAction else { return [] } | ||
|
||
let elements = testAction.targets.compactMap { target -> GroupFileElement? in | ||
guard case let .gpxFile(path) = target.simulatedLocation else { | ||
return nil | ||
} | ||
|
||
return GroupFileElement(path: path, group: project.filesGroup) | ||
} | ||
|
||
return elements | ||
} | ||
.flatMap { $0 } | ||
|
||
fileElements.formUnion(testActionGPXFiles) |
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.
Can we test the logic here in ProjectFileElementsTests
?
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.
Added test cases for extracting GPX files.
try await run(BuildCommand.self, "App-Local") | ||
|
||
let xcodeprojPath = fixturePath.appending(components: ["App", "MainApp.xcodeproj"]) | ||
|
||
try XCTAssertSimulatedLocationAdded( | ||
xcodeprojPath: xcodeprojPath, |
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.
For this test case, I specified the path manually because the .xcodeproj
file is not generated in the root of the fixture. I would like to ask if this is a good way to do it.
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's fine π
I apologize for my force push. I didn't realize this would happen... π |
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.
Thanks a lot for adding the acceptance tests β€οΈ Just two nits, afterwards, we can merge this one π
try await run(BuildCommand.self, "App-Local") | ||
|
||
let xcodeprojPath = fixturePath.appending(components: ["App", "MainApp.xcodeproj"]) | ||
|
||
try XCTAssertSimulatedLocationAdded( | ||
xcodeprojPath: xcodeprojPath, |
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's fine π
/// - testTarget: A specific test target name. | ||
/// - simulatedLocation: A simulated location. This value can be passed a `location string` or a `GPX filename`. | ||
/// For example, "Rio de Janeiro, Brazil" or "Grand Canyon.gpx". | ||
public func XCTAssertSimulatedLocationAdded( |
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.
nit: Can we rename this to XCTAssertContainsSimulatedLocation
? It's more inline with how we name these custom assert methods.
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.
Sure! That makes sense!
line: UInt = #line | ||
) throws { | ||
if let xcodeprojPath { | ||
self.xcodeprojPath = xcodeprojPath |
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 wouldn't override the self.xcodeprojPath
, I would only use the custom one directly in this method.
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.
It's a great way to keep it simple π.
@all-contributors add @woin2ee for code |
I've put up a pull request to add @woin2ee! π |
Amazing work π |
I was able to finish it with your help. Thank you :) |
Resolves #5375
Short description π
This PR adds the
simulatedLocation
property to theTestableTarget
.The API looks like this
then...
How to test the changes locally π§
Run
tuist generate
in theios_app_with_custom_scheme
fixture. Then check the Simulated location setting for the test target in the test action of theApp-Debug
orApp-Release
scheme of the created project.Contributor checklist β
mise run lint:fix
Reviewer checklist β
changelog:added
,changelog:fixed
, orchangelog:changed
, and the title is usable as a changelog entry