@@ -8,6 +8,7 @@ import org.cqfn.diktat.util.prependPath
88import org.cqfn.diktat.util.retry
99
1010import mu.KotlinLogging
11+ import org.assertj.core.api.Assertions.assertThat
1112import org.assertj.core.api.Assertions.fail
1213import org.assertj.core.api.SoftAssertions.assertSoftly
1314import org.junit.jupiter.api.AfterAll
@@ -24,9 +25,7 @@ import kotlin.io.path.createDirectories
2425import kotlin.io.path.div
2526import kotlin.io.path.exists
2627import kotlin.io.path.listDirectoryEntries
27- import kotlin.io.path.name
2828import kotlin.io.path.outputStream
29- import kotlin.io.path.pathString
3029import kotlin.io.path.readText
3130import kotlin.io.path.relativeTo
3231import kotlin.system.measureNanoTime
@@ -99,6 +98,8 @@ class DiktatSaveSmokeTest : DiktatSmokeTestBase() {
9998
10099 @Suppress(" WRONG_ORDER_IN_CLASS_LIKE_STRUCTURES" ) // False positives
101100 companion object {
101+ private const val BUILD_DIRECTORY = " target"
102+ private const val FAT_JAR_GLOB = " diktat-rules-*-fat-jar-for-smoke-tests.jar"
102103 private const val KTLINT_VERSION = " 0.46.1"
103104
104105 @Suppress(" EMPTY_BLOCK_STRUCTURE_ERROR" )
@@ -164,22 +165,28 @@ class DiktatSaveSmokeTest : DiktatSmokeTestBase() {
164165 " The base directory for the smoke test is $baseDirectory ."
165166 }
166167
167- val diktatDir: String =
168- Path (" ../diktat-ruleset/target" )
169- .takeIf { it.exists() }
170- ?.listDirectoryEntries()
171- ?.single { it.name.contains(" diktat" ) }
172- ?.pathString ? : " "
168+ /*
169+ * The fat JAR should reside in the same directory as `ktlint` and
170+ * `save*` and be named `diktat.jar`
171+ * (see `diktat-rules/src/test/resources/test/smoke/save.toml`).
172+ */
173+ val diktatFrom = Path (BUILD_DIRECTORY )
174+ .takeIf (Path ::exists)
175+ ?.listDirectoryEntries(FAT_JAR_GLOB )
176+ ?.singleOrNull()
177+ assertThat(diktatFrom)
178+ .describedAs(diktatFrom?.toString() ? : " $BUILD_DIRECTORY /$FAT_JAR_GLOB " )
179+ .isNotNull
180+ .isRegularFile
173181
174- val diktatFrom = Path (diktatDir)
175182 val diktat = baseDirectory / " diktat.jar"
176183 val save = baseDirectory / getSaveForCurrentOs()
177184 val ktlint = baseDirectory / " ktlint"
178185
179186 downloadFile(URL (" https://github.com/saveourtool/save-cli/releases/download/v$SAVE_VERSION /${getSaveForCurrentOs()} " ), save)
180187 downloadFile(URL (" https://github.com/pinterest/ktlint/releases/download/$KTLINT_VERSION /ktlint" ), ktlint)
181188
182- diktatFrom.copyTo(diktat)
189+ diktatFrom? .copyTo(diktat)
183190 }
184191
185192 @AfterAll
0 commit comments