Skip to content

Commit

Permalink
Introduced not applicable counter for FixPlugin (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls committed Aug 23, 2022
1 parent ff844eb commit c1c6eaa
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,24 @@ data class CountWarnings(
val matched: Int,
val expected: Int,
val unexpected: Int,
)
) {
companion object {
private const val NOT_APPLICABLE_COUNTER: Int = -99

/**
* [CountWarnings] is not applicable for current run
*/
val notApplicable = CountWarnings(
NOT_APPLICABLE_COUNTER,
NOT_APPLICABLE_COUNTER,
NOT_APPLICABLE_COUNTER,
NOT_APPLICABLE_COUNTER
)

/**
* @param counter value of counter to be checked
* @return true if provided value has value which means that current counter is not applicable (FixPlugin for example), otherwise -- false
*/
fun isNotApplicable(counter: Int): Boolean = NOT_APPLICABLE_COUNTER == counter
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.saveourtool.save.core.plugin.ExtraFlagsExtractor
import com.saveourtool.save.core.plugin.GeneralConfig
import com.saveourtool.save.core.plugin.Plugin
import com.saveourtool.save.core.plugin.resolvePlaceholdersFrom
import com.saveourtool.save.core.result.CountWarnings
import com.saveourtool.save.core.result.DebugInfo
import com.saveourtool.save.core.result.Fail
import com.saveourtool.save.core.result.Pass
Expand Down Expand Up @@ -123,7 +124,8 @@ class FixPlugin(
execCmd,
stdout.filter { it.contains(testCopy.name) }.joinToString("\n"),
stderr.filter { it.contains(testCopy.name) }.joinToString("\n"),
null
null,
CountWarnings.notApplicable,
)
)
}
Expand All @@ -139,7 +141,7 @@ class FixPlugin(
TestResult(
it,
Fail(ex.describe(), ex.describe()),
DebugInfo(execCmd, null, ex.message, null)
DebugInfo(execCmd, null, ex.message, null, CountWarnings.notApplicable)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.saveourtool.save.core.config.TestConfig
import com.saveourtool.save.core.files.createFile
import com.saveourtool.save.core.files.fs
import com.saveourtool.save.core.plugin.GeneralConfig
import com.saveourtool.save.core.result.CountWarnings
import com.saveourtool.save.core.result.DebugInfo
import com.saveourtool.save.core.result.Pass
import com.saveourtool.save.core.result.TestResult
Expand Down Expand Up @@ -61,6 +62,7 @@ class FixPluginTest {
assertEquals("Test2Expected.java", pairs.single().second.name)
}

@Suppress("TOO_LONG_FUNCTION")
@Test
fun `should calculate diff of discovered files`() {
val config = fs.createFile(tmpDir / "save.toml")
Expand Down Expand Up @@ -90,8 +92,14 @@ class FixPluginTest {
assertEquals(1, results.size, "Size of results should equal number of pairs")
val testResult = results.single()
assertEquals(
TestResult(FixPlugin.FixTestFiles(testFile, expectedFile), Pass(null), DebugInfo(
testResult.debugInfo?.execCmd, testResult.debugInfo?.stdout, testResult.debugInfo?.stderr, null)
TestResult(FixPlugin.FixTestFiles(testFile, expectedFile), Pass(null),
DebugInfo(
testResult.debugInfo?.execCmd,
testResult.debugInfo?.stdout,
testResult.debugInfo?.stderr,
null,
CountWarnings.notApplicable,
)
),
testResult
)
Expand Down

0 comments on commit c1c6eaa

Please sign in to comment.