Skip to content

Remove java/main from the path to the generated tests #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.utbot.common.FileUtil.findAllFilesOnly
import org.utbot.common.PathUtil.classFqnToPath
import org.utbot.common.PathUtil.replaceSeparator
import org.utbot.common.tryLoadClass
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.sarif.util.ClassUtil
import org.utbot.framework.plugin.sarif.TargetClassWrapper
import java.io.File
Expand Down Expand Up @@ -97,33 +96,22 @@ class SourceSetWrapper(

/**
* Creates and returns a file for a future SARIF report.
* For example, ".../main/com/qwerty/MainReport.sarif".
* For example, ".../com/qwerty/MainReport.sarif".
*/
private fun createSarifReportFile(classFqn: String): File {
val relativePath = "${sourceSet.name}/${classFqnToPath(classFqn)}Report.sarif"
val relativePath = "${classFqnToPath(classFqn)}Report.sarif"
val absolutePath = Paths.get(parentProject.generatedSarifDirectory.path, relativePath)
return absolutePath.toFile().apply { createNewFileWithParentDirectories() }
}

/**
* Creates and returns a file for future generated tests.
* For example, ".../java/main/com/qwerty/MainTest.java".
* For example, ".../com/qwerty/MainTest.java".
*/
private fun createTestsCodeFile(classFqn: String): File {
val fileExtension = parentProject.sarifProperties.codegenLanguage.extension
val sourceRoot = parentProject.sarifProperties.codegenLanguage.toSourceRootName()
val relativePath = "$sourceRoot/${sourceSet.name}/${classFqnToPath(classFqn)}Test$fileExtension"
val relativePath = "${classFqnToPath(classFqn)}Test$fileExtension"
val absolutePath = Paths.get(parentProject.generatedTestsDirectory.path, relativePath)
return absolutePath.toFile().apply { createNewFileWithParentDirectories() }
}

/**
* Returns the source root name by [CodegenLanguage].
*/
private fun CodegenLanguage.toSourceRootName(): String =
when (this) {
CodegenLanguage.JAVA -> "java"
CodegenLanguage.KOTLIN -> "kotlin"
else -> "unknown"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class MavenProjectWrapper(

/**
* Creates and returns a file for future generated tests.
* For example, ".../java/main/com/qwerty/MainTest.java".
* For example, ".../com/qwerty/MainTest.java".
*/
private fun createTestsCodeFile(classFqn: String): File {
val fileExtension = sarifProperties.codegenLanguage.extension
Expand Down