Skip to content

[Commands] Allow skipping tests with a flag #2847

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

Merged
merged 2 commits into from
Aug 17, 2020
Merged

Conversation

finagolfin
Copy link
Member

@finagolfin finagolfin commented Aug 5, 2020

Multiple --skip invocations can be used to skip multiple tests. Keep the environment variable around till its users switch over.

@aciidb0mb3r added the functionality to skip tests in #2181 last summer, but it was only available from an environment variable. I was unaware of that and really wanted the option to skip tests, especially when segfaulting tests cause the whole test run to stop, so I looked into implementing it and found his code. Simply adding this flag surfaces his implementation to the user and works, but iswas incomplete.

I 'd gowent further and makemade it so that --filter and ---skip could be used at the same time (the naive implementation in this WIP pull causes the skip flag to override the filter flag), so one could --filter BuildTests --skip SwiftCompilerOutputParserTests and have much more fine-grained control of what tests are run. I simply reused the colon-separated scheme of the environment variable, but something like @keith's #2800, ie allowing multiple invocations of --skip, would be more consistent.

I figured I'd implemented it by moving the .skip case to its own function skippedTests which is a fileprivate extension to [UnitTest], similar to filteredTests, then changed all three invocations of filteredTests in this module to filteredTests().skippedTests().

Before I go down that road, I thought I'd post this minimal implementation and see what the maintainers think. @keith, let me know if this would help you too.

@keith
Copy link
Member

keith commented Aug 5, 2020

I think allowing multiple --skip invocations would be nicer than the : splitting for sure. I think in general this would be nice to have, but I'll leave that up to the maintainers!

@finagolfin
Copy link
Member Author

finagolfin commented Aug 6, 2020

@neonichu, I see that you asked for these features in SR-10800 last year, let me know what you think about the proposedthis implementation above.

@finagolfin
Copy link
Member Author

Updated with the full implementation I outlined, amended OP to reflect it. @aciidb0mb3r, I simply removed the now redundant environment variable, but can add it back if there's some user who needs that till they can shift over.

I will add some tests soon, any feedback on the new behavior would be good to have first.

@finagolfin
Copy link
Member Author

Added some tests, a couple more coming this evening.

@neonichu
Copy link
Contributor

We should keep the environment variable for compatibility, but I think it's fine to remove it from docs.

…on-mac platforms by adding '--enable-test-discovery' flag
Multiple '--skip' invocations can be used to skip multiple tests. Keep the environment
variable around till its users switch over.
@finagolfin finagolfin changed the title Allow skipping tests with a flag, instead of the environment variable [Commands] Allow skipping tests with a flag Aug 11, 2020
@finagolfin
Copy link
Member Author

Alright, added back the environment variable, another commit enabling some tests on non-mac platforms, and a couple more tests for this flag.

Ready for review and CI.

@MaxDesiatov
Copy link
Contributor

@swift-ci please smoke test

@finagolfin
Copy link
Member Author

The CI didn't run.

@MaxDesiatov
Copy link
Contributor

@swift-ci please smoke test

@finagolfin
Copy link
Member Author

Oh, wow, 3 min. turnaround on the self-hosted tests, this is great. 😆

@tomerd tomerd merged commit e028ef3 into swiftlang:master Aug 17, 2020
@tomerd
Copy link
Contributor

tomerd commented Aug 17, 2020

thank you @buttaface

@finagolfin
Copy link
Member Author

Thanks for getting this in, always wanted this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants