Skip to content

Commit

Permalink
Update test assertions, fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
OdysseusLives committed Jun 14, 2019
1 parent 48ac5c6 commit e25ebbf
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
def expectedLocks = [
'annotationProcessor.lockfile',
'compileClasspath.lockfile',
'runtimeClasspath.lockfile',
'testAnnotationProcessor.lockfile',
'testCompileClasspath.lockfile',
'testRuntimeClasspath.lockfile'
] as String[]
def mavenrepo
Expand Down Expand Up @@ -64,7 +66,13 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
result.output.contains('coreLockingSupport feature enabled')
def actualLocks = new File(projectDir, '/gradle/dependency-locks/').list().toList()

actualLocks.containsAll(expectedLocks)
expectedLocks.each {
assert actualLocks.contains(it)
}
actualLocks.each {
assert expectedLocks.contains(it)
}

def lockFile = new File(projectDir, '/gradle/dependency-locks/compileClasspath.lockfile')
lockFile.text.contains('test.nebula:a:1.1.0')
lockFile.text.contains('test.nebula:b:1.1.0')
Expand All @@ -84,7 +92,13 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
result.output.contains('coreLockingSupport feature enabled')
def actualLocks = new File(projectDir, '/gradle/dependency-locks/').list().toList()

actualLocks.containsAll(expectedLocks)
expectedLocks.each {
assert actualLocks.contains(it)
}
actualLocks.each {
assert expectedLocks.contains(it)
}

def lockFile = new File(projectDir, '/gradle/dependency-locks/compileClasspath.lockfile')
lockFile.text.contains('test.nebula:a:1.1.0')
lockFile.text.contains('test.nebula:b:1.1.0')
Expand Down Expand Up @@ -142,7 +156,20 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
result.output.contains('coreLockingSupport feature enabled')
def actualLocks = new File(projectDir, '/gradle/dependency-locks/').list().toList()

actualLocks.containsAll(expectedLocks)
expectedLocks.each {
assert actualLocks.contains(it)
}
assert actualLocks.size() > expectedLocks.size()
def allExpectedLocks = ["compile.lockfile", "archives.lockfile", "testCompileClasspath.lockfile",
"compileOnly.lockfile", "annotationProcessor.lockfile", "runtime.lockfile",
"compileClasspath.lockfile", "jacocoAnt.lockfile", "testCompile.lockfile",
"default.lockfile", "testAnnotationProcessor.lockfile", "testRuntime.lockfile",
"jacocoAgent.lockfile", "testRuntimeClasspath.lockfile", "testCompileOnly.lockfile",
"runtimeClasspath.lockfile"]
allExpectedLocks.each {
assert actualLocks.contains(it)
}

def lockFile = new File(projectDir, '/gradle/dependency-locks/jacocoAgent.lockfile')
lockFile.exists()

Expand Down Expand Up @@ -178,7 +205,13 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
result.output.contains('coreLockingSupport feature enabled')
def actualLocks = new File(projectDir, '/gradle/dependency-locks/').list().toList()

actualLocks.containsAll(expectedLocks)
expectedLocks.each {
assert actualLocks.contains(it)
}
actualLocks.each {
assert expectedLocks.contains(it)
}

def lockFile = new File(projectDir, '/gradle/dependency-locks/jacocoAgent.lockfile')
!lockFile.exists()

Expand All @@ -191,6 +224,7 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {

@Unroll
def 'generate core lock file with #facet facet configurations'() {
// TODO: Lock all the facet configurations by default
given:
def sourceSetConfig
if (setParentSourceSet) {
Expand Down Expand Up @@ -258,11 +292,14 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
updatedExpectedLocks.each {
assert actualLocks.contains(it)
}
def lockFile = new File(projectDir, "/gradle/dependency-locks/${facet}compileClasspath.lockfile")
lockFile.text.contains('test.nebula:a:1.1.0')
lockFile.text.contains('test.nebula:b:1.1.0')
lockFile.text.contains('junit:junit:4.12')
lockFile.text.contains('org.hamcrest:hamcrest-core:1.3')
actualLocks.each {
assert updatedExpectedLocks.contains(it)
}
def lockFile = new File(projectDir, "/gradle/dependency-locks/${facet}CompileClasspath.lockfile")
assert lockFile.text.contains('test.nebula:a:1.1.0')
assert lockFile.text.contains('test.nebula:b:1.1.0')
assert lockFile.text.contains('junit:junit:4.12')
assert lockFile.text.contains('org.hamcrest:hamcrest-core:1.3')

where:
facet | plugin | setParentSourceSet
Expand All @@ -272,9 +309,10 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
}

@Unroll
def 'scala projects defining dependencies on base configuration "#conf" are locked - #working'() {
// the configurations `incrementalScalaAnalysisFor_x_ extend from `compile` and `implementation` rather than `compileClasspath`
def 'scala projects defining dependencies on base configuration "#conf" #areLocked'() {
// the configurations `incrementalScalaAnalysisFor_x_` are resolvable only from a scala context, and extend from `compile` and `implementation`
// https://github.com/gradle/gradle/blob/master/subprojects/scala/src/main/java/org/gradle/api/plugins/scala/ScalaBasePlugin.java#L143
// TODO: determine which of the scala configurations should be locked for project consistency
given:
setupScalaProject(conf)

Expand All @@ -286,14 +324,23 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
def actualLocks = new File(projectDir, '/gradle/dependency-locks/').list().toList()

assert actualLocks.size() > 0

def scalaRelatedLockfiles = [
"compileClasspath.lockfile"
"compile.lockfile",
"testCompile.lockfile"
]
def updatedExpectedLocks = expectedLocks + scalaRelatedLockfiles
updatedExpectedLocks.each {
assert actualLocks.contains(it)
}
actualLocks.each {
assert updatedExpectedLocks.contains(it)
}
def lockFile = new File(projectDir, "/gradle/dependency-locks/compile.lockfile")
if (conf == "compile") {
assert lockFile.text.contains('org.scala-lang:scala-library:')
} else {
assert !lockFile.text.contains('org.scala-lang:scala-library:')
}

result.output.contains("Cannot lock scala configurations based on the 'implementation' configuration.")

Expand All @@ -304,9 +351,9 @@ class DependencyLockPluginWithCoreSpec extends IntegrationTestKitSpec {
!cleanBuildResults.output.contains('FAILURE')

where:
conf | working
'compile' | true
'implementation' | false
conf | areLocked
'compile' | "are locked"
'implementation' | "are not locked"
}

def 'fails when generating Nebula locks and writing core locks together'() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class MigrateToCoreLocksTaskSpec extends IntegrationTestKitSpec {
def expectedLocks = [
'annotationProcessor.lockfile',
'compileClasspath.lockfile',
'runtimeClasspath.lockfile',
'testAnnotationProcessor.lockfile',
'testCompileClasspath.lockfile',
'testRuntimeClasspath.lockfile'
] as String[]
def mavenrepo
Expand Down Expand Up @@ -613,10 +615,10 @@ class MigrateToCoreLocksTaskSpec extends IntegrationTestKitSpec {
assert actualLocks.contains(it)
}

def lockFile = new File(projectDir, "/gradle/dependency-locks/${facet}compileClasspath.lockfile")
lockFile.text.contains('test.nebula:a:1.0.0')
lockFile.text.contains('junit:junit:4.12')
lockFile.text.contains('org.hamcrest:hamcrest-core:1.3')
def lockFile = new File(projectDir, "/gradle/dependency-locks/${facet}CompileClasspath.lockfile")
assert lockFile.text.contains('test.nebula:a:1.0.0')
assert lockFile.text.contains('junit:junit:4.12')
assert lockFile.text.contains('org.hamcrest:hamcrest-core:1.3')

where:
facet | plugin | setParentSourceSet
Expand Down Expand Up @@ -697,8 +699,8 @@ class MigrateToCoreLocksTaskSpec extends IntegrationTestKitSpec {
compileLockFile.text.contains('test.nebula:a:1.0.0')

// facet lock had been unlocked & resolved to different version
def facetLockFile = new File(projectDir, "/gradle/dependency-locks/${facet}compileClasspath.lockfile")
facetLockFile.text.contains('test.nebula:a:1.1.0')
def facetLockFile = new File(projectDir, "/gradle/dependency-locks/${facet}CompileClasspath.lockfile")
assert facetLockFile.text.contains('test.nebula:a:1.1.0')

where:
facet | plugin | setParentSourceSet
Expand Down

0 comments on commit e25ebbf

Please sign in to comment.