Skip to content

Commit

Permalink
Added trim() for list of string test directories (#1537)
Browse files Browse the repository at this point in the history
* Added trim() for testDirs value

### What's done:
* added trim() for testDirs value
Closes #1288
  • Loading branch information
Cheshiriks authored Oct 28, 2022
1 parent 3beabb0 commit 0046681
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ data class CommonConfiguration(private val configuration: Map<String, String>?)
* List of directory names which will be used to detect test sources
*/
val testAnchors: List<String> by lazy {
val testDirs = (configuration ?: emptyMap()).getOrDefault("testDirs", "test").split(',')
val testDirs = (configuration ?: emptyMap()).getOrDefault("testDirs", "test").split(',').map { it.trim() }
if (testDirs.any { !it.lowercase(Locale.getDefault()).endsWith("test") }) {
log.error("test directory names should end with `test`")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ConfigReaderTest {
.readResource("src/test/resources/test-rules-config.yml")
requireNotNull(rulesConfigList)
assert(rulesConfigList.getCommonConfiguration().kotlinVersion == kotlinVersion)
assert(rulesConfigList.getCommonConfiguration().testAnchors.contains("androidUnitTest"))
assert(rulesConfigList.find { it.name == DIKTAT_COMMON }
?.configuration
?.get("kotlinVersion")
Expand Down
1 change: 1 addition & 0 deletions diktat-common/src/test/resources/test-rules-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
configuration:
domainName: org.cqfn.diktat
kotlinVersion: 1.4.21
testDirs: "test, androidUnitTest"
- name: CLASS_NAME_INCORRECT
enabled: true
- name: CONSTANT_UPPERCASE
Expand Down

0 comments on commit 0046681

Please sign in to comment.