Skip to content

Commit

Permalink
Merge pull request #134 from chali/FixBrokenTest
Browse files Browse the repository at this point in the history
Fixed failing test missed due misconfiguration after upgrade to Gradle 7 milestone
  • Loading branch information
chali authored Mar 9, 2021
2 parents 0d8a850 + 442a9f1 commit 5582835
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.tasks.testing.Test

/*
* Copyright 2014-2019 Netflix, Inc.
*
Expand Down Expand Up @@ -42,4 +44,8 @@ dependencies {
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
}

tasks.withType(Test) {
useJUnitPlatform()
}

publishPlugins.enabled = false
1 change: 1 addition & 0 deletions src/main/groovy/nebula/test/Integration.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ abstract trait Integration extends IntegrationBase {
this.result = result
gradleHandle.disconnect()
checkOutput(result.standardOutput)
checkOutput(result.standardError)
return result
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/groovy/nebula/test/IntegrationBase.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ abstract trait IntegrationBase {
static void checkForMutableProjectState(String output) {
def mutableProjectStateWarnings = output.readLines().findAll {
it.contains("was resolved without accessing the project in a safe manner") ||
it.contains("This may happen when a configuration is resolved from a thread not managed by Gradle or from a different project")
it.contains("This may happen when a configuration is resolved from a thread not managed by Gradle or from a different project") ||
it.contains("was resolved from a thread not managed by Gradle.") ||
it.contains("was attempted from a context different than the project context")

}

Expand Down
14 changes: 10 additions & 4 deletions src/test/groovy/nebula/test/DeprecationCheckIntegrationSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ class DeprecationCheckIntegrationSpec extends IntegrationSpec {
buildFile << """
apply plugin: 'java'
tasks.jar.deleteAllActions()
repositories {
mavenCentral()
}
dependencies {
implementation('com.google.guava:guava:19.0') {
force = true
}
}
"""

gradleVersion = '4.7'

when:
runTasks()
runTasks('help')

then:
def e = thrown(IllegalArgumentException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import spock.lang.IgnoreIf
@IgnoreIf({ System.getenv('TITUS_TASK_ID') })
class MutableProjectStateWarningCheckIntegrationSpec extends IntegrationSpec {

def setup() {
gradleVersion = "5.1"
}

def 'mutable project state warning when configuration in another project is resolved unsafely'() {
given:
settingsFile << """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,26 @@ class SpecifiedGradleVersionIntegrationSpec extends IntegrationSpec {
writeHelloWorld('nebula.test.hello')
buildFile << '''
apply plugin: 'java'
task showVersion {
doLast {
println "Gradle Version: ${gradle.gradleVersion}"
}
}
'''.stripIndent()
and:
logLevel = LogLevel.DEBUG

and:
gradleVersion = requestedGradleVersion

when:
def result = runTasksSuccessfully('build')
def result = runTasksSuccessfully('showVersion')

then:

result.standardOutput.contains("gradle\\$requestedGradleVersion\\taskArtifacts")
result.standardOutput.contains("Gradle Version: $requestedGradleVersion")

where:
requestedGradleVersion << ['2.8', '2.9']
requestedGradleVersion << ['7.0-milestone-2']
}

@IgnoreIf({ OperatingSystem.current.windows || jvm.isJava9Compatible() })
Expand All @@ -59,23 +63,27 @@ class SpecifiedGradleVersionIntegrationSpec extends IntegrationSpec {
writeHelloWorld('nebula.test.hello')
buildFile << '''
apply plugin: 'java'
task showVersion {
doLast {
println "Gradle Version: ${gradle.gradleVersion}"
}
}
'''.stripIndent()
and:
logLevel = LogLevel.DEBUG

and:
gradleVersion = requestedGradleVersion

when:
def result = runTasksSuccessfully('build')
def result = runTasksSuccessfully('showVersion')

then:

result.standardOutput.contains("gradle/$requestedGradleVersion/taskArtifacts")
result.standardOutput.contains("Gradle Version: $requestedGradleVersion")


where:
requestedGradleVersion << ['2.8', '2.9']
requestedGradleVersion << ['7.0-milestone-2']
}

static final String CUSTOM_DISTRIBUTION = 'https://dl.bintray.com/nebula/gradle-distributions/1.12-20140608201532+0000/gradle-1.12-20140608201532+0000-bin.zip'
Expand Down

0 comments on commit 5582835

Please sign in to comment.