diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-09-16 09:29:25 +0200 |
---|---|---|
committer | Kamil Doległo <9080183+kamildoleglo@users.noreply.github.com> | 2020-11-13 19:46:36 +0100 |
commit | 1a552c1f64fc15a94c298e50a3dd614f3794c0e3 (patch) | |
tree | 5aab050b712775ef98da5041e673100c75f9ee56 /integration-tests/src/main | |
parent | e03aed7331756eaef766c7306bd033c84f7fd815 (diff) | |
download | dokka-1a552c1f64fc15a94c298e50a3dd614f3794c0e3.tar.gz dokka-1a552c1f64fc15a94c298e50a3dd614f3794c0e3.tar.bz2 dokka-1a552c1f64fc15a94c298e50a3dd614f3794c0e3.zip |
Add integration tests for Kotlin projects
Diffstat (limited to 'integration-tests/src/main')
-rw-r--r-- | integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt | 16 | ||||
-rw-r--r-- | integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt | 40 |
2 files changed, 56 insertions, 0 deletions
diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt new file mode 100644 index 00000000..ee69ef62 --- /dev/null +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt @@ -0,0 +1,16 @@ +package org.jetbrains.dokka.it + +import org.junit.After +import java.io.File + +interface S3Project { + val projectOutputLocation: File + + @After + fun copyToLocation() { + System.getenv("DOKKA_IT_AWS_PATH")?.also { location -> + println("Copying to ${File(location).absolutePath}") + projectOutputLocation.copyRecursively(File(location)) + } ?: println("No copy path provided, skipping") + } +} diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt new file mode 100644 index 00000000..312ff21f --- /dev/null +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt @@ -0,0 +1,40 @@ +package org.jetbrains.dokka.it + +import org.eclipse.jgit.api.Git +import org.eclipse.jgit.storage.file.FileRepositoryBuilder +import java.io.File +import java.nio.file.Path + +fun AbstractIntegrationTest.copyAndApplyGitDiff(diffFile: File) = + copyGitDiffFileToParent(diffFile).let(::applyGitDiffFromFile) + +fun AbstractIntegrationTest.copyGitDiffFileToParent(originalDiffFile: File) = + originalDiffFile.copyTo(File(projectDir.parent, originalDiffFile.name)) + +fun AbstractIntegrationTest.applyGitDiffFromFile(diffFile: File) { + val projectGitFile = projectDir.resolve(".git") + val git = if (projectGitFile.exists()) { + if (projectGitFile.isFile) { + println(".git file inside project directory exists, removing") + removeGitFile(projectDir.toPath()) + Git.init().setDirectory(projectDir).call() + } else { + println(".git directory inside project directory exists, reusing") + FileRepositoryBuilder().apply { + isMustExist = true + gitDir = projectDir + }.let { Git(it.build()) } + } + } else { + Git.init().setDirectory(projectDir).call() + } + git.apply().setPatch(diffFile.inputStream()).call() +} + +private fun removeGitFile(repository: Path) = + repository.toFile() + .listFiles().orEmpty() + .filter { it.name.toLowerCase() == ".git" } + .forEach { it.delete() } + + |