Skip to content

Commit 576c9a6

Browse files
authored
Remove java/main from the path to the generated tests (#321)
1 parent 1ac3a04 commit 576c9a6

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/wrappers/SourceSetWrapper.kt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import org.utbot.common.FileUtil.findAllFilesOnly
66
import org.utbot.common.PathUtil.classFqnToPath
77
import org.utbot.common.PathUtil.replaceSeparator
88
import org.utbot.common.tryLoadClass
9-
import org.utbot.framework.plugin.api.CodegenLanguage
109
import org.utbot.framework.plugin.sarif.util.ClassUtil
1110
import org.utbot.framework.plugin.sarif.TargetClassWrapper
1211
import java.io.File
@@ -97,33 +96,22 @@ class SourceSetWrapper(
9796

9897
/**
9998
* Creates and returns a file for a future SARIF report.
100-
* For example, ".../main/com/qwerty/MainReport.sarif".
99+
* For example, ".../com/qwerty/MainReport.sarif".
101100
*/
102101
private fun createSarifReportFile(classFqn: String): File {
103-
val relativePath = "${sourceSet.name}/${classFqnToPath(classFqn)}Report.sarif"
102+
val relativePath = "${classFqnToPath(classFqn)}Report.sarif"
104103
val absolutePath = Paths.get(parentProject.generatedSarifDirectory.path, relativePath)
105104
return absolutePath.toFile().apply { createNewFileWithParentDirectories() }
106105
}
107106

108107
/**
109108
* Creates and returns a file for future generated tests.
110-
* For example, ".../java/main/com/qwerty/MainTest.java".
109+
* For example, ".../com/qwerty/MainTest.java".
111110
*/
112111
private fun createTestsCodeFile(classFqn: String): File {
113112
val fileExtension = parentProject.sarifProperties.codegenLanguage.extension
114-
val sourceRoot = parentProject.sarifProperties.codegenLanguage.toSourceRootName()
115-
val relativePath = "$sourceRoot/${sourceSet.name}/${classFqnToPath(classFqn)}Test$fileExtension"
113+
val relativePath = "${classFqnToPath(classFqn)}Test$fileExtension"
116114
val absolutePath = Paths.get(parentProject.generatedTestsDirectory.path, relativePath)
117115
return absolutePath.toFile().apply { createNewFileWithParentDirectories() }
118116
}
119-
120-
/**
121-
* Returns the source root name by [CodegenLanguage].
122-
*/
123-
private fun CodegenLanguage.toSourceRootName(): String =
124-
when (this) {
125-
CodegenLanguage.JAVA -> "java"
126-
CodegenLanguage.KOTLIN -> "kotlin"
127-
else -> "unknown"
128-
}
129117
}

utbot-maven/src/main/kotlin/org/utbot/maven/plugin/wrappers/MavenProjectWrapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class MavenProjectWrapper(
141141

142142
/**
143143
* Creates and returns a file for future generated tests.
144-
* For example, ".../java/main/com/qwerty/MainTest.java".
144+
* For example, ".../com/qwerty/MainTest.java".
145145
*/
146146
private fun createTestsCodeFile(classFqn: String): File {
147147
val fileExtension = sarifProperties.codegenLanguage.extension

0 commit comments

Comments
 (0)