Skip to content

Commit

Permalink
Migrate diktat smoke tests to SAVE-cli mechanism
Browse files Browse the repository at this point in the history
### What's done:
* migrated diktat smoke tests to SAVE-cli mechanism
Closes #1383
  • Loading branch information
Cheshiriks committed Jul 5, 2022
1 parent 1764a4b commit 00628f7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ import org.junit.jupiter.api.Assertions
import java.io.File
import java.io.FileOutputStream
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.bufferedWriter
import kotlin.io.path.div
import kotlin.io.path.exists
import kotlin.io.path.listDirectoryEntries
import kotlin.io.path.name
import kotlin.io.path.pathString

/**
* @property resourceFilePath path to files which will be compared in tests
Expand All @@ -29,7 +34,6 @@ open class FixTestBase(
private val testComparatorUnit = TestComparatorUnit(resourceFilePath) { text, fileName ->
format(ruleSetProviderRef, text, fileName, rulesConfigList, cb = cb)
}
private val diktatVersion = "1.2.1-SNAPSHOT"

constructor(resourceFilePath: String,
ruleSupplier: (rulesConfigList: List<RulesConfig>) -> Rule,
Expand Down Expand Up @@ -86,17 +90,25 @@ open class FixTestBase(
* @param testPath path to file with code that will be transformed by formatter, relative to [resourceFilePath]
* @param configFilePath path of diktat-analysis file
*/
@Suppress("TOO_LONG_FUNCTION")
protected fun saveSmokeTest(
configFilePath: String,
expectedPath: String,
testPath: String
) {
val processBuilder = ProcessBuilder("src/test/resources/test/smoke/${getSaveForCurrentOs()}", "src/test/resources/test/smoke/src/main/kotlin", expectedPath, testPath)

val diktatDir: String =
Paths.get("../diktat-ruleset/target")
.takeIf { it.exists() }
?.listDirectoryEntries()
?.single { it.name.contains("diktat") }
?.pathString ?: ""

val file = File("tmpSave.txt")
val diktat = File("src/test/resources/test/smoke/diktat.jar")
val configFile = File("src/test/resources/test/smoke/diktat-analysis.yml")
val diktatFrom = File("../diktat-ruleset/target/diktat-$diktatVersion.jar")
val diktatFrom = File(diktatDir)
val save = File("src/test/resources/test/smoke/${getSaveForCurrentOs()}")
val ktlint = File("src/test/resources/test/smoke/ktlint")

Expand Down

0 comments on commit 00628f7

Please sign in to comment.