swift-argument-parser icon indicating copy to clipboard operation
swift-argument-parser copied to clipboard

Expose ArgumentParserTestHelpers

Open MartinP7r opened this issue 3 years ago • 6 comments

Sorry if this is a very naive question or what I'm trying to do is already possible with the current package setup.

I find the ArgumentParserTestHelpers target very helpful and it would be great to be able to add it as a dependency for the client's testTarget.

As a test, I tried to simply add a product target for it in a fork.


Note below error was solved by @KS1019's suggestion

However, I keep getting the following error:

product 'ArgumentParserTestHelpers' required by package 'MyApp' target 'MayAppTests' not found in package 'swift-argument-parser'.

(Here is a sample reproducing this error)


Best regards,
Martin

MartinP7r avatar Sep 17 '22 11:09 MartinP7r

My understanding is that it is not possible with the current setup of this project.

There have been similar issues from time to time like this one #255. I remember seeing @natecook1000 commenting they're not doing it because they cannot promise it will be maintained appropriately (but I couldn't find that particular issue so I'm not sure).

On the other hand, #255 is labeled as enhancement so maybe they are thinking of doing this.

cc @natecook1000 @rauhul Any clarification is much appreciated!

KS1019 avatar Sep 26 '22 00:09 KS1019

@KS1019 thank you for the details!

commenting they're not doing it because they cannot promise it will be maintained appropriately

I think I found this issue here: #303

Understood, I agree that guaranteeing maintainability is not really high priority for test helpers.
If it's something worthwhile, I'd love to help out in whatever capacity I can here.
However I seem to still fail at the basic understanding of why my sample is not finding the product even if I declare it in Package.swift. 😓

MartinP7r avatar Sep 26 '22 01:09 MartinP7r

@MartinP7r I'm not too sure but you might want to modify [email protected] too.

KS1019 avatar Sep 26 '22 02:09 KS1019

@MartinP7r I'm not too sure but you might want to modify [email protected] too.

Oh, wow. Thanks so much.
I didn't know there's a way to specify a Package.swift for different swift versions. (If that's what's happening here)

MartinP7r avatar Sep 26 '22 09:09 MartinP7r

👋🏻 We're definitely open to making ArgumentParserTestHelpers an exported target, but it really needs an API review before we're ready to do that, as it's mostly grown organically to support the specific kinds of tests that the library needs.

@MartinP7r, what parts are you finding useful?

natecook1000 avatar Sep 29 '22 16:09 natecook1000

Thank you for your time @natecook1000 👋🏼

AssertExecuteCommand is very useful.
I think the way you test the examples would naturally fit most apps that depend on ArgumentParser because integration testing is most practical for CLI tools of average size.

MartinP7r avatar Sep 29 '22 22:09 MartinP7r