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

Add tests for missing rules in a ruleset #477

Merged
merged 1 commit into from
Jul 5, 2019

Conversation

romtsn
Copy link
Collaborator

@romtsn romtsn commented Jun 10, 2019

This is a follow up for #476. I would suggest merging this after the .ktlintignore landed on master. Or I could also implement ignores list for this kind of tests for now, but I would rather wait for global ignores. It just grabs the source files from the specified location and then checks that all of them are being returned from the specified ruleset.


open class RuleSetProviderTest(
private val rulesetClass: Class<out RuleSetProvider>,
private val packageName: String
Copy link
Collaborator Author

@romtsn romtsn Jun 10, 2019

Choose a reason for hiding this comment

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

nit: We could, in theory, get the package name from rulesetClass and this would work with current ktlint structure, but in case of custom rulesets, the rules could be located in a different folder, so I would rather leave it like that

import org.junit.Test
import java.io.File

open class RuleSetProviderTest(
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'm not sure that this is the best way for the centralized test code - this could be just a simple top-level function, which may be called from within a test method (e.g. in case StandardRuleSetProviderTest contains other tests), so I'm open for changing this, but currently it works.

@shashachu
Copy link
Contributor

This looks like a reasonable approach to me. We can merge it in the future.

@shashachu
Copy link
Contributor

@rom4ek I just landed the rule disabling PR (#503) so this should be able to pass now.

@romtsn
Copy link
Collaborator Author

romtsn commented Jul 4, 2019

@shashachu updated the PR accordingly. Thanks!

@shashachu shashachu merged commit 657299b into pinterest:master Jul 5, 2019
@romtsn romtsn deleted the missing-rules-in-ruleset branch July 5, 2019 18:21
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this pull request Jul 18, 2019
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