Skip to content

Commit

Permalink
Change test storage from List to class in Fix plugin
Browse files Browse the repository at this point in the history
What's done:
* Change test storage from List to class in plugin
Closes #221
  • Loading branch information
Cheshiriks committed Sep 3, 2021
1 parent dba666d commit ea0a17a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FixAndWarnPlugin(
override fun handleFiles(files: Sequence<TestFiles>): Sequence<TestResult> {
// Need to update private fields after validation
initOrUpdateConfigs()
val expectedFiles = files.map { it as FixPlugin.FixTestFiles }.map { it.expected }
val expectedFiles = files.map { it as FixPlugin.Test }.map { it.expected }

// Remove (in place) warnings from test files before fix plugin execution
val filesAndTheirWarningsMap = removeWarningsFromExpectedFiles(expectedFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FixPlugin(
val fixPluginConfig = testConfig.pluginConfigs.filterIsInstance<FixPluginConfig>().single()
val generalConfig = testConfig.pluginConfigs.filterIsInstance<GeneralConfig>().single()

return files.map { it as FixTestFiles }.chunked(fixPluginConfig.batchSize!!.toInt()).map { chunk ->
return files.map { it as Test }.chunked(fixPluginConfig.batchSize!!.toInt()).map { chunk ->
val pathMap = chunk.map { it.expected to it.test }
val pathCopyMap = pathMap.map { (expected, test) -> expected to createTestFile(test, generalConfig) }
val testCopyNames =
Expand Down Expand Up @@ -172,19 +172,9 @@ class FixPlugin(
.toList()
.joinToString { (type, lines) -> "$type: $lines lines" }

/**
* @property expected expected file
*/
interface FixTestFiles : TestFiles {
/**
* path to expected file
*/
val expected: Path
}

/**
* @property test test file
* @property expected expected file
*/
class Test(override val test: Path, override val expected: Path) : FixTestFiles
class Test(override val test: Path, val expected: Path) : TestFiles
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class FixPluginTest {
useInternalRedirections = false
)
.discoverTestFiles(tmpDir)
.map { it as FixPlugin.FixTestFiles }
.map { it as FixPlugin.Test }
.map { it.expected to it.test }
.toList()
}

0 comments on commit ea0a17a

Please sign in to comment.