Skip to content

Commit

Permalink
Add test case that enables dependency verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Feb 7, 2020
1 parent d89628a commit 8e3dd10
Showing 1 changed file with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ final class DifferentGradleVersionsSpec extends Specification {
'5.4.1',
'5.5.1',
'5.6',
'6.0'
'6.0',
'6.1.1',
]
}

Expand Down Expand Up @@ -175,4 +176,91 @@ final class DifferentGradleVersionsSpec extends Specification {
NIGHTLY.id
]
}

def 'dependencyUpdates task works with dependency verification enabled'() {
given:
def classpathString = pluginClasspath
.collect { it.absolutePath.replace('\\', '\\\\') } // escape backslashes in Windows paths
.collect { "'$it'" }
.join(", ")
def mavenRepoUrl = getClass().getResource('/maven/').toURI()
def srdErrWriter = new StringWriter()

buildFile = testProjectDir.newFile('build.gradle')
buildFile <<
"""
buildscript {
dependencies {
classpath files($classpathString)
}
}
apply plugin: 'java'
apply plugin: "com.github.ben-manes.versions"
repositories {
maven {
url '${mavenRepoUrl}'
}
}
dependencies {
compile 'com.google.inject:guice:2.0'
}
""".stripIndent()

testProjectDir.newFolder("gradle")
def verificationFile = testProjectDir.newFile('gradle/verification-metadata.xml')
verificationFile <<
"""<?xml version="1.0" encoding="UTF-8"?>
<verification-metadata xmlns="https://schema.gradle.org/dependency-verification" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://schema.gradle.org/dependency-verification https://schema.gradle.org/dependency-verification/dependency-verification-1.0.xsd">
<configuration>
<verify-metadata>true</verify-metadata>
<verify-signatures>false</verify-signatures>
</configuration>
<components>
<component group="aopalliance" name="aopalliance" version="1.0">
<artifact name="aopalliance-1.0.jar">
<sha256 value="0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08" origin="Generated by Gradle"/>
</artifact>
<artifact name="aopalliance-1.0.pom">
<sha256 value="26e82330157d6b844b67a8064945e206581e772977183e3e31fec6058aa9a59b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google" name="google" version="1">
<artifact name="google-1.pom">
<sha256 value="cd6db17a11a31ede794ccbd1df0e4d9750f640234731f21cff885a9997277e81" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.inject" name="guice" version="2.0">
<artifact name="guice-2.0.jar">
<sha256 value="9fb545199584a41e8064e1232ca3f3c757366b27fc7aa488ac0fc98263642756" origin="Generated by Gradle"/>
</artifact>
<artifact name="guice-2.0.pom">
<sha256 value="6a121e2334b23884eb06bcdb4d0eb0dad3fab75d23029737a0e8dd65231a6899" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.google.inject" name="guice-parent" version="2.0">
<artifact name="guice-parent-2.0.pom">
<sha256 value="9c4b45c665b1e423de3e0be6491f10d3201c709d6cb96bf951a136d9061265b4" origin="Generated by Gradle"/>
</artifact>
</component>
</components>
</verification-metadata>
""".stripIndent()

when:
def result = GradleRunner.create()
.withGradleVersion('6.2-rc-1')
.withProjectDir(testProjectDir.root)
.withArguments('dependencyUpdates')
.forwardStdError(srdErrWriter)
.build()

then:
result.output.contains('Dependency verification is an incubating feature.')
result.output.contains('com.google.inject:guice [2.0 -> 3.1]')
srdErrWriter.toString().empty
}
}

0 comments on commit 8e3dd10

Please sign in to comment.