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

Introduced not applicable counter for FixPlugin #437

Merged
merged 3 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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