Skip to content
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

support combining inclusion & exclusion patterns #210

Merged
merged 4 commits into from
Jul 22, 2016

Conversation

kpbode
Copy link
Contributor

@kpbode kpbode commented Jul 14, 2016

A line with the content “!whitelist” can be added to the filter list in order to invert the filters. Only tests matching any of the given filter patterns will be run.

A line with the content “!whitelist” can be added to the filter list in order to invert the filters. Only tests matching any of the given filter patterns will be run.
@sarod sarod self-assigned this Jul 19, 2016
@sarod
Copy link
Member

sarod commented Jul 19, 2016

Hi @kpbode,

Thanks for the PR.

Supporting filtering by inclusion is definitely a feature that is missing (see #177).

However it would be better if we could support combining inclusion and exclusion.
A test would be executed if:

  • it matches any of the inclusion pattern or if no inclusion patterns are defined or if
  • it do not match any of the defined exclusion patterns

For instance user may want to configure like this:

include=com\.mycompany\.mypackage1\.*
include=com\.mycompany\.mypackage2\.*
exclude=.*IT
exclude=.*SlowTest

This would execute only tests contained in packages com.searchy.mypackage1 or com.searchy.mypackage2 but excluding the tests ending with IT or SlowTest.

RegexFileFilter should be mdified handle to handle those two new special line prefixes when parsing the infinitest.filters file.
If a line starts with include= the remaining line content should be considered as an inclusion pattern.
If a line starts with exclude= the remaining line content should be considered as an exclusion pattern.
For backward compatibility reason lines starting with unknown prefix will still be considered as exclusion pattern.

What do you think?

@kpbode
Copy link
Contributor Author

kpbode commented Jul 20, 2016

Hey @sarod,

I just updated my pull request. A filter can now contain "include" and "exclude" entries. Non-prefixed lines will result in exclusions to provide compatibility with legacy files.

Best,

Karl

}

private boolean isValidFilterLine(String line) {
return !Strings.isNullOrEmpty(line) && !line.startsWith("!") && !line.startsWith("#");
Copy link
Member

@sarod sarod Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& !line.startsWith("!") is not needed anymore right?

Forget it I didn't realize it was already here

@sarod
Copy link
Member

sarod commented Jul 21, 2016

Thanks @kpbode!

I did another review.
Things look good apart the 2 minor comments.

Best,
-Seb

@kpbode
Copy link
Contributor Author

kpbode commented Jul 22, 2016

@sarod, I integrated your remarks last night.

@sarod sarod merged commit 0b087aa into infinitest:master Jul 22, 2016
@sarod
Copy link
Member

sarod commented Jul 22, 2016

Thanks! @kpbode

@sarod sarod added this to the 5.2 milestone Jul 22, 2016
@sarod sarod changed the title Enabling whitelist-filtering support combining inclusion & exclusion patterns Jul 22, 2016
@sarod sarod mentioned this pull request Jul 22, 2016
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.

2 participants