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

Added ability to specify inclusion filter for source sets #726

Merged
merged 6 commits into from
Jan 8, 2025

Conversation

shanshin
Copy link
Collaborator

@shanshin shanshin commented Jan 7, 2025

Resolves #714

@shanshin shanshin requested a review from sandwwraith January 7, 2025 12:33
@shanshin shanshin force-pushed the sourceset-inclusion branch from 5ac91be to cd71b38 Compare January 7, 2025 12:42
}
```

This way, only classes from the `main` source set will be included in the report, but not from others.
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this includedSourceSets then?

Copy link
Member

Choose a reason for hiding this comment

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

Or at least excludeEverySourceSetExcept

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would like to get away from naming included. On the other hand, such things are now called included in the entire DSL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, let it be included for now

Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid we can move from this naming only for all functions at once, when we'll migrate whole Kover plugin

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I took this into account


val included = variant.excludedOtherSourceSets.get()
// if `test` is not included so we need to check it
if (compilationName == "test" && "test" !in included) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it the same condition as included.isNotEmpty() && compilationName !in included?

Also, you can add a test case for "test" source set name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, I was a little hasty to add a separate condition

@shanshin shanshin requested a review from sandwwraith January 7, 2025 17:03
assertTrue(buildResult.isSuccessful, "Build should be successful")
classCounter("kotlinx.kover.examples.sourcesets.MainClass").assertAbsent()
classCounter("kotlinx.kover.examples.sourcesets.FooClass").assertAbsent()
classCounter("kotlinx.kover.examples.sourcesets.ExtraClass").assertPresent()
Copy link
Member

Choose a reason for hiding this comment

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

Add classCounter("kotlinx.kover.examples.sourcesets.TestClasses") to this test and all above


val included = variant.includedSourceSets.get()

if (included.isEmpty() && compilationName == "test") {
Copy link
Member

Choose a reason for hiding this comment

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

Are tests excluded by default? Is it mentioned somewhere in the documentation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, test source set excluded by default.

@shanshin shanshin requested a review from sandwwraith January 7, 2025 20:10
val builder = StringBuilder()
koverBlocks.forEach { block ->
builder.appendLine()
builder.append(block(language, "8.12"))
Copy link
Member

Choose a reason for hiding this comment

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

Is 8.12 a Gradle version? Shouldn't it be some constant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, any version of Gradle with support for assign operator redefinition is needed here.

@shanshin shanshin merged commit 3f6745d into main Jan 8, 2025
@shanshin shanshin deleted the sourceset-inclusion branch January 8, 2025 12:26
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.

Explicitly included sourceSets (whitelist)
2 participants