-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation for empty kotlin.build.report.json.directory property
#KT-66314: Fixed (cherry picked from commit c202314)
- Loading branch information
1 parent
2f19d2e
commit f327391
Showing
3 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ctionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/report/ConfigureReportingTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
package org.jetbrains.kotlin.gradle.unitTests.report | ||
|
||
import org.gradle.api.internal.plugins.PluginApplicationException | ||
import org.jetbrains.kotlin.gradle.util.applyKotlinJvmPlugin | ||
import org.jetbrains.kotlin.gradle.util.buildProject | ||
import org.jetbrains.kotlin.gradle.util.propertiesExtension | ||
import org.junit.jupiter.api.assertThrows | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class ConfigureReportingTest { | ||
|
||
@Test | ||
fun validateMandatoryJsonDirectory() { | ||
val exception = | ||
assertThrows<PluginApplicationException>("The property 'kotlin.build.report.json.directory' is mandatory for JSON output. Validation should fail.") { | ||
buildProject { | ||
propertiesExtension.set("kotlin.build.report.output", "json") | ||
applyKotlinJvmPlugin() | ||
} | ||
} | ||
|
||
assertEquals("Can't configure json report: 'kotlin.build.report.json.directory' property is mandatory", exception.cause?.message) | ||
} | ||
|
||
@Test | ||
fun validateInvalidJsonDirectory() { | ||
val exception = | ||
assertThrows<PluginApplicationException>("The property 'kotlin.build.report.json.directory' should not be empty. Validation should fail.") { | ||
buildProject { | ||
propertiesExtension.set("kotlin.build.report.output", "json") | ||
propertiesExtension.set("kotlin.build.report.json.directory", "") | ||
applyKotlinJvmPlugin() | ||
} | ||
} | ||
|
||
assertEquals("The property 'kotlin.build.report.json.directory' must not be empty. Please provide a valid value.", exception.cause?.message) | ||
} | ||
} |