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
Allow to not attach a debugger to the test process #3813
Allow to not attach a debugger to the test process #3813
Conversation
455934f
to
c90a3b8
Compare
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.
Excellent contribution @svenmuennich. Besides the comment that I left, I'd update the CHANGELOG.md
to mention that you are introducing this functionality. Moreover, I noticed the option exists in run action. Would you mind adding it there too for consistency reasons?
@@ -64,6 +70,7 @@ public struct TestAction: Equatable, Codable { | |||
public static func targets(_ targets: [TestableTarget], | |||
arguments: Arguments? = nil, | |||
configuration: ConfigurationName = .debug, | |||
attachDebugger: Bool = true, |
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.
Because by default we don't set the value, the default here should be false
. Otherwise it'll be a breaking change for users.
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.
Maybe I am missing something, but before my changes a debugger was always attached implicitly by not setting selectedDebuggerIdentifier
here and hence using its default value, which is XCScheme.defaultDebugger
. So to prevent this from breaking anything, the default here needs to be true
, does it not?
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.
You're right, to ensure it isn't a breaking change the default would need to be true
@all-contributors add @svenmuennich for code |
I've put up a pull request to add @svenmuennich! π |
@svenmuennich I made you contributor of the project so that you can push directly your branches to this repository. Doing contributions through forks is very annoying, so we don't want you to suffer from that :P |
For the run action the logic is a bit more complex, since we already have some logic for this option to treat normal schemes and schemes for app extensions differently. That is, currently the debugger is only attached for normal schemes but never for app extension schemes. I can add the option there too, which would lead to the following behaviour:
|
This would be awesome. If you think the behaviour might be misleading for users, we can add a note in the documentation explaining how the debugger is attached depending on the type of scheme. Thanks a lot @svenmuennich |
c90a3b8
to
4d47a01
Compare
@@ -1441,57 +1626,6 @@ final class SchemeDescriptorsGeneratorTests: XCTestCase { | |||
]) | |||
} | |||
|
|||
func test_generate_appExtensionSchemeLaunchAction() throws { |
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 renamed this test to test_schemeLaunchAction_for_app_extension
I added the functionality to |
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 for contributing this @svenmuennich !
Once we address the small issue this should be good to go π
debuggerIdentifier = "" | ||
} else { | ||
launchActionConstants = .default | ||
debuggerIdentifier = scheme.runAction?.attachDebugger == true ? XCScheme.defaultDebugger : "" |
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.
This has a subtle issue - by default many schemes may omit explicitly specifying a runAction
(i.e. it will be nil
) - as such we'd be disabling the debugger option for them whereas before it was enabled :/
An example of this is the automatically generated -Project
workspace scheme.
debuggerIdentifier = scheme.runAction?.attachDebugger == true ? XCScheme.defaultDebugger : "" | |
if let runAction = scheme.runAction { | |
debuggerIdentifier = runAction.attachDebugger ? XCScheme.defaultDebugger : "" | |
} else { | |
debuggerIdentifier = XCScheme.defaultDebugger | |
} |
It may be worth expanding the tests to cover this case if they don't already.
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.
Good find π² I fixed this as suggested and added a test for this π
4d47a01
to
5577e33
Compare
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 for the updates
Resolves n/a
Request for comments document (if applies): n/a
Short description π
In Xcode's scheme editor a test action can be configured to either attach a debugger to the test process or not:
Currently tuist always sets the configuration to attach the debugger and there is no way to prevent this. This PR adds a new field to
TestAction
for configuring whether a debugger will be attached or not. The field defaults totrue
to not change the behavior for existing projects.Why is this change necessary?
In our code base we make heavy use of assertion testing via Nimble's
throwAssertion()
matcher. This matcher does not work when a debugger is attached though (at least on Apple Silicon). Hence we want to be able to not attach a debugger to the test process by default to make the tests run smoothly.Checklist β
CHANGELOG.md
has been updated to reflect the changes. In case of a breaking change, it's been flagged as such.TuistGraph.Target
, theConstants.cacheVersion
has been updated.