From abcdb8f0215fe27222fc0a81afa6b02a729be383 Mon Sep 17 00:00:00 2001 From: Vfrolov Date: Mon, 11 Jul 2022 12:44:02 +0300 Subject: [PATCH] Migrate diktat smoke tests to SAVE-cli mechanism ### What's done: * migrated diktat smoke tests to SAVE-cli mechanism Closes #1383 --- .../test/kotlin/org/cqfn/diktat/util/FixTestBase.kt | 12 ++++++++---- diktat-rules/src/test/resources/test/smoke/save.toml | 2 +- .../resources/test/smoke/src/main/kotlin/save.toml | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt index 48cf52ddeb..85043d2818 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/FixTestBase.kt @@ -75,10 +75,14 @@ open class FixTestBase( else -> "" } - private fun getProcessBuilder(expectedPath: String, testPath: String) = when { - System.getProperty("os.name").startsWith("Linux", ignoreCase = true) -> ProcessBuilder("chmod", "777", "src/test/resources/test/smoke/${getSaveForCurrentOs()}", "&", "src/test/resources/test/smoke/${getSaveForCurrentOs()}", "src/test/resources/test/smoke/src/main/kotlin", expectedPath, testPath) - System.getProperty("os.name").startsWith("Mac", ignoreCase = true) -> ProcessBuilder("chmod", "777", "src/test/resources/test/smoke/${getSaveForCurrentOs()}", "&", "src/test/resources/test/smoke/${getSaveForCurrentOs()}", "src/test/resources/test/smoke/src/main/kotlin", expectedPath, testPath) - else -> ProcessBuilder("src/test/resources/test/smoke/${getSaveForCurrentOs()}", "src/test/resources/test/smoke/src/main/kotlin", expectedPath, testPath) + private fun getProcessBuilder(expectedPath: String, testPath: String): ProcessBuilder { + val saveDir = "src/test/resources/test/smoke/${getSaveForCurrentOs()}" + val systemName = System.getProperty("os.name") + return when { + systemName.startsWith("Linux", ignoreCase = true) || systemName.startsWith("Mac", ignoreCase = true) -> + ProcessBuilder("chmod", "777", saveDir, "&", saveDir, "src/test/resources/test/smoke/src/main/kotlin", expectedPath, testPath) + else -> ProcessBuilder(saveDir, "src/test/resources/test/smoke/src/main/kotlin", expectedPath, testPath) + } } private fun downloadFile(url: String, file: File) { diff --git a/diktat-rules/src/test/resources/test/smoke/save.toml b/diktat-rules/src/test/resources/test/smoke/save.toml index 18bedb7070..d63828ecd1 100644 --- a/diktat-rules/src/test/resources/test/smoke/save.toml +++ b/diktat-rules/src/test/resources/test/smoke/save.toml @@ -1,5 +1,5 @@ [general] -execCmd="java -jar ktlint -R diktat.jar" +execCmd="chmod 777 ktlint & chmod 777 diktat.jar & java -jar ktlint -R diktat.jar" tags = ["smokeTest"] description = "SmokeTest" suiteName = "SmokeTest" diff --git a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/save.toml b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/save.toml index 8c86f032f7..0d4862aa87 100644 --- a/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/save.toml +++ b/diktat-rules/src/test/resources/test/smoke/src/main/kotlin/save.toml @@ -1,5 +1,5 @@ [general] -execCmd="java -jar ktlint -R diktat.jar" +execCmd="chmod 777 ktlint & chmod 777 diktat.jar & java -jar ktlint -R diktat.jar" tags = ["smokeTest"] description = "SmokeTest" suiteName = "SmokeTest"