Skip to content

Commit

Permalink
finish configuration cache tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xvik committed Jan 16, 2025
1 parent a9cae70 commit ff223b0
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ class UpstreamAndroidConfigurationCacheKitTest extends AbstractAndroidKitTest {
result.task(':check').outcome == TaskOutcome.SUCCESS
result.task(':animalsnifferDebug').outcome == TaskOutcome.SUCCESS
result.task(':animalsnifferRelease').outcome == TaskOutcome.SUCCESS
result.output.contains('3 AnimalSniffer violations were found in 2 files')

then: "text report correct"
File file = file('/build/reports/animalsniffer/debug.text')
file.exists()
file.readLines() == [
"invalid.Sample:16 Undefined reference (android-api-level-21-5.0.1_r2): java.nio.file.Path java.nio.file.Paths.get(String, String[])",
"invalid.Sample2:11 Undefined reference (android-api-level-21-5.0.1_r2): java.nio.file.FileSystem java.nio.file.FileSystems.getDefault()",
"invalid.Sample2:11 Undefined reference (android-api-level-21-5.0.1_r2): Iterable java.nio.file.FileSystem.getFileStores()"
]


when: "run from cache"
Expand All @@ -87,9 +97,20 @@ class UpstreamAndroidConfigurationCacheKitTest extends AbstractAndroidKitTest {
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':check').outcome == TaskOutcome.SUCCESS
// result.task(':animalsnifferDebug').outcome == TaskOutcome.SUCCESS
// result.task(':animalsnifferRelease').outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':check').outcome == TaskOutcome.SUCCESS
result.task(':animalsnifferDebug').outcome == TaskOutcome.UP_TO_DATE
result.task(':animalsnifferRelease').outcome == TaskOutcome.UP_TO_DATE
// no output!
!result.output.contains('1 AnimalSniffer violations were found in 1 files.')

then: "text report correct"
file.exists()
file.readLines() == [
"invalid.Sample:16 Undefined reference (android-api-level-21-5.0.1_r2): java.nio.file.Path java.nio.file.Paths.get(String, String[])",
"invalid.Sample2:11 Undefined reference (android-api-level-21-5.0.1_r2): java.nio.file.FileSystem java.nio.file.FileSystems.getDefault()",
"invalid.Sample2:11 Undefined reference (android-api-level-21-5.0.1_r2): Iterable java.nio.file.FileSystem.getFileStores()"
]
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ class UpstreamAndroidMultiplatformConfigurationCacheKitTest extends AbstractAndr

then: "task successful"
result.task(':check').outcome == TaskOutcome.SUCCESS
result.output.contains('2 AnimalSniffer violations were found in 1 files.')

then: "text report correct"
File file = file('/build/reports/animalsniffer/debug.text')
file.exists()
file.readLines() == [
"invalid.Sample:11 Undefined reference: int Boolean.compare(boolean, boolean)",
"invalid.Sample:16 Undefined reference: java.nio.file.Path java.nio.file.Paths.get(String, String[])"
]

when: "run from cache"
println '\n\n------------------- FROM CACHE ----------------------------------------'
Expand All @@ -93,7 +102,17 @@ class UpstreamAndroidMultiplatformConfigurationCacheKitTest extends AbstractAndr
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':check').outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':check').outcome == TaskOutcome.SUCCESS
// no output!
!result.output.contains('2 AnimalSniffer violations were found in 1 files.')

then: "text report correct"
File file2 = super.file('/build/reports/animalsniffer/debug.text')
file2.exists()
file2.readLines() == [
"invalid.Sample:11 Undefined reference: int Boolean.compare(boolean, boolean)",
"invalid.Sample:16 Undefined reference: java.nio.file.Path java.nio.file.Paths.get(String, String[])"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ class UpstreamBuildSignatureConfigurationCacheKitTest extends AbstractKitTest {
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':animalsnifferSignature').outcome == TaskOutcome.SUCCESS
//
// then: "validate signature"
// SignatureReader.readSignature(file("build/animalsniffer/signature/${projectName()}.sig")) == [
// 'ann.Sample',
// 'valid.Sample'
// ]
then: "task up to date"
result.task(':animalsnifferSignature').outcome == TaskOutcome.UP_TO_DATE

then: "validate signature"
SignatureReader.readSignature(file("build/animalsniffer/signature/${projectName()}.sig")) == [
'ann.Sample',
'valid.Sample'
]
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class UpstreamDebugOptionConfigurationCacheKitTest extends AbstractAndroidKitTes

then: "task successful"
result.task(':animalsnifferMain').outcome == TaskOutcome.SUCCESS
result.output.contains('2 AnimalSniffer violations were found in 1 files')
result.output.replace('\r', '').contains('\tsignatures:\n' +
'\t\tjava16-sun-1.0.signature\n' +
'\n' +
'\tsources:\n' +
'\t\tsrc/main/java')

when: "run from cache"
println '\n\n------------------- FROM CACHE ----------------------------------------'
Expand All @@ -55,8 +61,10 @@ class UpstreamDebugOptionConfigurationCacheKitTest extends AbstractAndroidKitTes
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':animalsnifferMain').outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':animalsnifferMain').outcome == TaskOutcome.UP_TO_DATE
// no output
!result.output.contains('2 AnimalSniffer violations were found in 1 files')
}

def "Check configuration cache compatibility"() {
Expand Down Expand Up @@ -125,6 +133,16 @@ class UpstreamDebugOptionConfigurationCacheKitTest extends AbstractAndroidKitTes
result.task(':check').outcome == TaskOutcome.SUCCESS
result.task(':animalsnifferDebug').outcome == TaskOutcome.SUCCESS
result.task(':animalsnifferRelease').outcome == TaskOutcome.SUCCESS
result.output.contains('3 AnimalSniffer violations were found in 2 files')
result.output.replace('\r', '').contains('signatures:\n' +
'\t\tjava18-1.0.signature\n' +
'\t\tandroid-api-level-21-5.0.1_r2.signature\n' +
'\n' +
'\tsources:\n' +
'\t\tsrc/debug/java\n' +
'\t\tsrc/debug/kotlin\n' +
'\t\tsrc/main/java\n' +
'\t\tsrc/main/kotlin')

when: "run from cache"
println '\n\n------------------- FROM CACHE ----------------------------------------'
Expand All @@ -133,9 +151,11 @@ class UpstreamDebugOptionConfigurationCacheKitTest extends AbstractAndroidKitTes
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':check').outcome == TaskOutcome.SUCCESS
// result.task(':animalsnifferDebug').outcome == TaskOutcome.SUCCESS
// result.task(':animalsnifferRelease').outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':check').outcome == TaskOutcome.SUCCESS
result.task(':animalsnifferDebug').outcome == TaskOutcome.UP_TO_DATE
result.task(':animalsnifferRelease').outcome == TaskOutcome.UP_TO_DATE
// no output
!result.output.contains('3 AnimalSniffer violations were found in 2 files')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,28 @@ class UpstreamDebugTaskConfigurationCacheKitTest extends AbstractDebugKitTest {
// debug()

when: "run task"
BuildResult result = runFailedVer(UpstreamKitTest.GRADLE_VERSION, PrintAnimalsnifferSourceInfoTask.NAME, '--configuration-cache')
BuildResult result = runVer(UpstreamKitTest.GRADLE_VERSION, PrintAnimalsnifferSourceInfoTask.NAME, '--configuration-cache', '--configuration-cache-problems=warn')

then: "no configuration cache incompatibilities"
result.output.contains("1 problem was found storing the configuration cache")
result.output.contains('Gradle runtime: support for using a Java agent with TestKit')
result.output.contains('Calculating task graph as no cached configuration is available for tasks:')

then: "task successful"
result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
result.output.contains('== [Plugins] =========================')


when: "run from cache"
println '\n\n------------------- FROM CACHE ----------------------------------------'
result = runVer(UpstreamKitTest.GRADLE_VERSION, PrintAnimalsnifferSourceInfoTask.NAME, '--configuration-cache', '--configuration-cache-problems=warn')

then: "configuration cache ok"
// testKit is incompatible with configuration cache, but I can check number of errors!
result.output.contains('1 problem was found storing the configuration cache.')
result.output.contains('support for using a Java agent with TestKit builds is not yet implemented with the configuration cache')
then: "cache used"
result.output.contains('Reusing configuration cache.')

then: "task successful"
result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
result.output.contains('== [Plugins] =========================')
}

def "Check java android application debug support"() {
Expand Down Expand Up @@ -105,6 +118,7 @@ class UpstreamDebugTaskConfigurationCacheKitTest extends AbstractDebugKitTest {

then: "task successful"
result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
result.output.contains('== [Plugins] =========================')

when: "run from cache"
println '\n\n------------------- FROM CACHE ----------------------------------------'
Expand All @@ -113,8 +127,9 @@ class UpstreamDebugTaskConfigurationCacheKitTest extends AbstractDebugKitTest {
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
result.output.contains('== [Plugins] =========================')

}

Expand Down Expand Up @@ -158,6 +173,7 @@ class UpstreamDebugTaskConfigurationCacheKitTest extends AbstractDebugKitTest {

then: "task successful"
result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
result.output.contains('== [Plugins] =========================')


when: "run from cache"
Expand All @@ -167,7 +183,8 @@ class UpstreamDebugTaskConfigurationCacheKitTest extends AbstractDebugKitTest {
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':' + PrintAnimalsnifferSourceInfoTask.NAME).outcome == TaskOutcome.SUCCESS
result.output.contains('== [Plugins] =========================')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ class UpstreamJavaConfigurationCacheKitTest extends AbstractKitTest {

then: "task successful"
result.task(':animalsnifferMain').outcome == TaskOutcome.SUCCESS
result.output.contains('2 AnimalSniffer violations were found in 1 files')

then: "text report correct"
File file = file('/build/reports/animalsniffer/main.text')
file.exists()
file.readLines() == [
"invalid.Sample:11 Undefined reference: int Boolean.compare(boolean, boolean)",
"invalid.Sample:16 Undefined reference: java.nio.file.Path java.nio.file.Paths.get(String, String[])"
]


when: "run from cache"
println '\n\n------------------- FROM CACHE ----------------------------------------'
Expand All @@ -52,8 +62,18 @@ class UpstreamJavaConfigurationCacheKitTest extends AbstractKitTest {
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':animalsnifferMain').outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':animalsnifferMain').outcome == TaskOutcome.UP_TO_DATE
// no output
!result.output.contains('2 AnimalSniffer violations were found in 1 files')

then: "text report correct"
File file2 = super.file('/build/reports/animalsniffer/main.text')
file2.exists()
file2.readLines() == [
"invalid.Sample:11 Undefined reference: int Boolean.compare(boolean, boolean)",
"invalid.Sample:16 Undefined reference: java.nio.file.Path java.nio.file.Paths.get(String, String[])"
]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ class UpstreanMultiplatformConfigurationCacheKitTest extends AbstractKitTest {

then: "task successful"
result.task(':check').outcome == TaskOutcome.SUCCESS
result.output.contains('2 AnimalSniffer violations were found in 1 files.')

then: "text report correct"
File file = file('/build/reports/animalsniffer/jvmMain.text')
file.exists()
file.readLines() == [
"invalid.Sample:11 Undefined reference: int Boolean.compare(boolean, boolean)",
"invalid.Sample:16 Undefined reference: java.nio.file.Path java.nio.file.Paths.get(String, String[])"
]


when: "run from cache"
Expand All @@ -60,7 +69,17 @@ class UpstreanMultiplatformConfigurationCacheKitTest extends AbstractKitTest {
then: "cache used"
result.output.contains('Reusing configuration cache.')

// then: "task successful"
// result.task(':check').outcome == TaskOutcome.SUCCESS
then: "task successful"
result.task(':check').outcome == TaskOutcome.UP_TO_DATE
// no output
!result.output.contains('2 AnimalSniffer violations were found in 1 files.')

then: "text report correct"
File file2 = super.file('/build/reports/animalsniffer/jvmMain.text')
file2.exists()
file2.readLines() == [
"invalid.Sample:11 Undefined reference: int Boolean.compare(boolean, boolean)",
"invalid.Sample:16 Undefined reference: java.nio.file.Path java.nio.file.Paths.get(String, String[])"
]
}
}

0 comments on commit ff223b0

Please sign in to comment.