Skip to content

Commit 2963552

Browse files
committed
Updates
1 parent 6325e33 commit 2963552

File tree

2 files changed

+45
-36
lines changed

2 files changed

+45
-36
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package co.touchlab.kmmbridge
2+
3+
import org.apache.commons.io.FileUtils
4+
import org.junit.jupiter.api.BeforeEach
5+
import org.junit.jupiter.api.io.TempDir
6+
import java.io.File
7+
import java.io.FileInputStream
8+
import java.util.*
9+
10+
abstract class BasePluginTest {
11+
@TempDir
12+
lateinit var testProjectDir: File
13+
internal val assumedRootProjectDir = File(File("..").absolutePath)
14+
private val testProjectSource = File(assumedRootProjectDir, testProjectPath())
15+
16+
internal lateinit var settingsFile: File
17+
internal lateinit var buildFile: File
18+
19+
abstract fun testProjectPath(): String
20+
21+
@BeforeEach
22+
fun setup() {
23+
FileUtils.copyDirectory(testProjectSource, testProjectDir)
24+
ProcessHelper.runSh("git init;git add .;git commit -m 'arst'", workingDir = testProjectDir)
25+
settingsFile = File(testProjectDir, "settings.gradle.kts")
26+
buildFile = File(testProjectDir, "build.gradle.kts")
27+
}
28+
29+
internal fun loadTestGradleProperties(): Properties {
30+
val properties = Properties()
31+
FileInputStream(File(testProjectDir, "gradle.properties")).use { stream ->
32+
properties.load(stream)
33+
}
34+
return properties
35+
}
36+
37+
internal fun logExecResult(result: ExecutionResult) {
38+
if (result.output.isNotEmpty())
39+
println(result.output)
40+
if (result.error.isNotEmpty())
41+
System.err.println(result.error)
42+
}
43+
}
Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,14 @@
11
package co.touchlab.kmmbridge
22

3-
import org.apache.commons.io.FileUtils
4-
import org.junit.jupiter.api.BeforeEach
53
import org.junit.jupiter.api.Test
6-
import org.junit.jupiter.api.io.TempDir
74
import java.io.File
8-
import java.io.FileInputStream
9-
import java.util.*
105
import kotlin.test.assertEquals
116
import kotlin.test.assertFalse
127
import kotlin.test.assertTrue
138

149

15-
class SimplePluginTest {
16-
@TempDir
17-
lateinit var testProjectDir: File
18-
private val assumedRootProjectDir = File(File("..").absolutePath)
19-
private val testProjectSource = File(assumedRootProjectDir, "test-projects/basic")
20-
21-
private lateinit var settingsFile: File
22-
private lateinit var buildFile: File
23-
24-
@BeforeEach
25-
fun setup() {
26-
FileUtils.copyDirectory(testProjectSource, testProjectDir)
27-
ProcessHelper.runSh("git init;git add .;git commit -m 'arst'", workingDir = testProjectDir)
28-
settingsFile = File(testProjectDir, "settings.gradle.kts")
29-
buildFile = File(testProjectDir, "build.gradle.kts")
30-
}
10+
class SimplePluginTest : BasePluginTest() {
11+
override fun testProjectPath(): String = "test-projects/basic"
3112

3213
@Test
3314
fun runBasicBuild() {
@@ -71,19 +52,4 @@ class SimplePluginTest {
7152
logExecResult(result)
7253
assertEquals(0, result.status)
7354
}
74-
75-
private fun loadTestGradleProperties(): Properties {
76-
val properties = Properties()
77-
FileInputStream(File(testProjectDir, "gradle.properties")).use { stream ->
78-
properties.load(stream)
79-
}
80-
return properties
81-
}
82-
83-
private fun logExecResult(result: ExecutionResult) {
84-
if (result.output.isNotEmpty())
85-
println(result.output)
86-
if (result.error.isNotEmpty())
87-
System.err.println(result.error)
88-
}
8955
}

0 commit comments

Comments
 (0)