Add additional file assertions.
File does not exist, file exists in the tree, file does not exist in the tree. ^KT-45745 In Progress
This commit is contained in:
+1
-1
@@ -77,7 +77,7 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
)
|
||||
|
||||
build("build") {
|
||||
assertFileNotExists("build/js/packages/kotlin-js-nodejs/kotlin/")
|
||||
assertFileInProjectNotExists("build/js/packages/kotlin-js-nodejs/kotlin/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
||||
project("moduleName", gradleVersion) {
|
||||
build("build") {
|
||||
assertFileInProjectExists("build/classes/kotlin/main/META-INF/FLAG.kotlin_module")
|
||||
assertFileNotExists("build/classes/kotlin/main/META-INF/moduleName.kotlin_module")
|
||||
assertFileInProjectNotExists("build/classes/kotlin/main/META-INF/moduleName.kotlin_module")
|
||||
assertOutputDoesNotContain("Argument -module-name is passed multiple times")
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
||||
|
||||
build("build") {
|
||||
assertDirectoryInProjectExists("$customBuildDirName/classes")
|
||||
assertFileNotExists("build")
|
||||
assertFileInProjectNotExists("build")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+47
-4
@@ -36,18 +36,61 @@ fun GradleProject.assertFileInProjectExists(
|
||||
assertFileExists(projectPath.resolve(pathToFile))
|
||||
}
|
||||
|
||||
fun GradleProject.assertFileExistsInTree(
|
||||
pathToTreeRoot: Path,
|
||||
fileName: String
|
||||
) {
|
||||
val foundFile = pathToTreeRoot
|
||||
.toFile()
|
||||
.walk()
|
||||
.find {
|
||||
it.isFile && it.name == fileName
|
||||
}
|
||||
|
||||
assert(foundFile != null) {
|
||||
"File $fileName does not exists in $pathToTreeRoot!"
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Asserts file under [pathToFile] relative to the test project does not exist.
|
||||
*/
|
||||
fun GradleProject.assertFileNotExists(
|
||||
fun GradleProject.assertFileInProjectNotExists(
|
||||
pathToFile: String
|
||||
) {
|
||||
val filePath = projectPath.resolve(pathToFile)
|
||||
assert(!Files.exists(filePath)) {
|
||||
"File '${filePath}' exists!"
|
||||
assertFileNotExists(projectPath.resolve(pathToFile))
|
||||
}
|
||||
|
||||
fun GradleProject.assertFileNotExists(
|
||||
pathToFile: Path
|
||||
) {
|
||||
assert(!Files.exists(pathToFile)) {
|
||||
"File '${pathToFile}' exists!"
|
||||
}
|
||||
}
|
||||
|
||||
fun GradleProject.assertFileNotExistsInTree(
|
||||
pathToTreeRoot: Path,
|
||||
fileName: String
|
||||
) {
|
||||
val foundFile = pathToTreeRoot
|
||||
.toFile()
|
||||
.walk()
|
||||
.find {
|
||||
it.isFile && it.name == fileName
|
||||
}
|
||||
|
||||
assert(foundFile == null) {
|
||||
"File exists: ${foundFile!!.absolutePath}"
|
||||
}
|
||||
}
|
||||
|
||||
fun GradleProject.assertFileNotExistsInTree(
|
||||
pathToTreeRoot: String,
|
||||
fileName: String
|
||||
) {
|
||||
assertFileNotExistsInTree(projectPath.resolve(pathToTreeRoot), fileName)
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts directory under [pathToDir] relative to the test project exists and is a directory.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user