Skip to content

Commit 8d672ef

Browse files
committed
Simplify checks for jarPath
1 parent 6c89a12 commit 8d672ef

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/funcTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import kotlin.io.path.createFile
2525
import kotlin.io.path.createTempDirectory
2626
import kotlin.io.path.deleteRecursively
2727
import kotlin.io.path.exists
28-
import kotlin.io.path.isRegularFile
2928
import kotlin.io.path.readText
3029
import kotlin.io.path.toPath
3130
import kotlin.io.path.writeText
@@ -122,16 +121,12 @@ abstract class BasePluginTest {
122121
""".trimIndent() + System.lineSeparator()
123122
}
124123

125-
fun jarPath(path: String): JarPath {
126-
val realPath = projectRoot.resolve(path).also {
127-
check(it.exists()) { "Path not found: $it" }
128-
check(it.isRegularFile()) { "Path is not a regular file: $it" }
129-
}
130-
return JarPath(realPath)
124+
fun jarPath(relative: String, parent: Path = projectRoot): JarPath {
125+
return JarPath(parent.resolve(relative))
131126
}
132127

133-
fun path(path: String): Path {
134-
return projectRoot.resolve(path).also {
128+
fun path(relative: String, parent: Path = projectRoot): Path {
129+
return parent.resolve(relative).also {
135130
if (it.exists()) return@also
136131
it.parent.createDirectories()
137132
// We should create text file only if it doesn't exist.

src/funcTest/kotlin/com/github/jengelman/gradle/plugins/shadow/PublishingTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class PublishingTest : BasePluginTest() {
222222
}
223223

224224
private fun repoJarPath(path: String): JarPath {
225-
return JarPath(repoPath(path))
225+
return JarPath(remoteRepoPath.resolve(path))
226226
}
227227

228228
private fun publish(): BuildResult = run("publish")

src/funcTest/kotlin/com/github/jengelman/gradle/plugins/shadow/caching/BaseCachingTest.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.github.jengelman.gradle.plugins.shadow.caching
22

33
import assertk.assertThat
44
import com.github.jengelman.gradle.plugins.shadow.BasePluginTest
5+
import java.nio.file.NoSuchFileException
56
import java.nio.file.Path
67
import kotlin.io.path.ExperimentalPathApi
78
import kotlin.io.path.appendText
@@ -43,11 +44,10 @@ abstract class BaseCachingTest : BasePluginTest() {
4344
) {
4445
try {
4546
outputShadowJar.deleteExisting()
46-
} catch (ignored: IllegalStateException) {
47-
// ignore if the file does not exist
47+
} catch (ignored: NoSuchFileException) {
4848
}
4949
alternateDir.deleteRecursively()
50-
projectRoot.copyToRecursively(alternateDir, followLinks = false, overwrite = false)
50+
projectRoot.copyToRecursively(target = alternateDir, followLinks = false)
5151
// check that shadowJar pulls from cache in the original directory
5252
assertShadowJarHasResult(firstOutcome)
5353
// check that shadowJar pulls from cache in a different directory
@@ -62,8 +62,7 @@ abstract class BaseCachingTest : BasePluginTest() {
6262
fun assertShadowJarExecutes() {
6363
try {
6464
outputShadowJar.deleteExisting()
65-
} catch (ignored: IllegalStateException) {
66-
// ignore if the file does not exist
65+
} catch (ignored: NoSuchFileException) {
6766
}
6867
// task was executed and not pulled from cache
6968
assertShadowJarHasResult(SUCCESS)

0 commit comments

Comments
 (0)