Skip to content

Commit

Permalink
Refactoring for integration-tests
Browse files Browse the repository at this point in the history
So that more files can be shared among similar projects.
  • Loading branch information
ting-yuan committed Mar 6, 2021
1 parent d5b309f commit 448910d
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 374 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.jar.*
class AndroidIT {
@Rule
@JvmField
val project: TemporaryTestProject = TemporaryTestProject("playground-android")
val project: TemporaryTestProject = TemporaryTestProject("playground-android", "playground")

@Test
fun testPlaygroundAndroid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package com.google.devtools.ksp.test
import org.junit.rules.TemporaryFolder
import java.io.File

class TemporaryTestProject(projectName: String) : TemporaryFolder() {
class TemporaryTestProject(projectName: String, baseProject: String? = null) : TemporaryFolder() {
private val testProjectSrc = File("src/test/resources", projectName)
private val baseProjectSrc = baseProject?.let { File("src/test/resources", baseProject) }

override fun before() {
super.before()

testProjectSrc.copyRecursively(root)
baseProjectSrc?.copyRecursively(root)
testProjectSrc.copyRecursively(root, true)

val kotlinVersion = System.getProperty("kotlinVersion")
val kspVersion = System.getProperty("kspVersion")
Expand All @@ -23,6 +25,13 @@ class TemporaryTestProject(projectName: String) : TemporaryFolder() {
}

fun restore(file: String) {
File(testProjectSrc, file).copyTo(File(root, file), true)
fun copySafe(src: File, dst: File) {
if (src.exists())
src.copyTo(dst, true)
}
baseProjectSrc?.let {
copySafe(File(baseProjectSrc, file), File(root, file))
}
copySafe(File(testProjectSrc, file), File(root, file))
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 448910d

Please sign in to comment.