Skip to content

Commit

Permalink
Polish KotlinScriptDependenciesResolverTest
Browse files Browse the repository at this point in the history
  • Loading branch information
bamboo committed Mar 12, 2019
1 parent bc4d6b1 commit e8c26f2
Showing 1 changed file with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.hamcrest.Matcher
import org.junit.Assert.assertSame
import org.junit.Assert.assertThat
import org.junit.Assert.assertTrue

import org.junit.Before
import org.junit.Test

import java.io.File
Expand All @@ -46,17 +46,21 @@ import kotlin.script.dependencies.ScriptDependenciesResolver.ReportSeverity

class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {

@Before
fun setUpSettings() {

withDefaultSettings()
}

@Test
fun `succeeds with no script`() {

withDefaultSettings()
assertSucceeds()
}

@Test
fun `succeeds on init script`() {

withDefaultSettings()
assertSucceeds(withFile("my.init.gradle.kts", """
require(this is Gradle)
"""))
Expand All @@ -79,7 +83,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
@Test
fun `succeeds on project script`() {

withDefaultSettings()
assertSucceeds(withFile("build.gradle.kts", """
require(this is Project)
"""))
Expand All @@ -96,8 +99,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {

withKotlinBuildSrc()

withDefaultSettings()

assertSucceeds(withFile("buildSrc/src/main/kotlin/my-plugin.init.gradle.kts", """
require(this is Gradle)
"""))
Expand All @@ -108,7 +109,7 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {

withKotlinBuildSrc()

withSettings("""
withDefaultSettings().appendText("""
apply(plugin = "my-plugin")
""")

Expand All @@ -122,7 +123,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {

withKotlinBuildSrc()

withDefaultSettings()
withBuildScript("""
plugins {
id("my-plugin")
Expand All @@ -138,7 +138,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
fun `report file fatality on TAPI failure`() {
// thus disabling syntax highlighting

withDefaultSettings()
val editedScript = withBuildScript("")

val wrongEnv = arrayOf("gradleHome" to existing("absent"))
Expand All @@ -155,7 +154,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
@Test
fun `report file error on TAPI failure when reusing previous dependencies`() {

withDefaultSettings()
val editedScript = withBuildScript("")

val previous = resolvedScriptDependencies(editedScript).apply {
Expand All @@ -182,7 +180,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
BOOM
""")

withDefaultSettings()
val editedScript = withBuildScript("")

resolvedScriptDependencies(editedScript).apply {
Expand All @@ -201,7 +198,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
withKotlinBuildSrc()
val buildSrcKotlinSource = withFile("buildSrc/src/main/kotlin/Foo.kt", "")

withDefaultSettings()
val editedScript = withBuildScript("")

val previous = resolvedScriptDependencies(editedScript).apply {
Expand All @@ -224,7 +220,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
fun `do not report file warning on script compilation failure in currently edited script`() {
// because the IDE already provides user feedback for those

withDefaultSettings()
val editedScript = withBuildScript("""
doNotExists()
""")
Expand All @@ -242,7 +237,7 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
@Test
fun `report file warning on script compilation failure in another script`() {

withSettings("""
withDefaultSettings().appendText("""
include("a", "b")
""")
withBuildScript("")
Expand All @@ -263,7 +258,7 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {

@Test
fun `report file warning on runtime failure in currently edited script`() {
withDefaultSettings()

val editedScript = withBuildScript("""
configurations.getByName("doNotExists")
""")
Expand All @@ -281,7 +276,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
@Test
fun `report line warning on runtime failure in currently edited script when location aware hints are enabled`() {

withDefaultSettings()
withFile("gradle.properties", """
${EditorReports.locationAwareEditorHintsPropertyName}=true
""")
Expand All @@ -302,7 +296,7 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
@Test
fun `report file warning on runtime failure in another script`() {

withSettings("""
withDefaultSettings().appendText("""
include("a", "b")
""")
withBuildScript("")
Expand Down

0 comments on commit e8c26f2

Please sign in to comment.