Skip to content

Commit

Permalink
Add coverage for running the task twice
Browse files Browse the repository at this point in the history
asserting up-to-dateness
exercising configuration cache reuse
  • Loading branch information
eskatos committed Sep 3, 2021
1 parent 4ce4018 commit d6da144
Show file tree
Hide file tree
Showing 11 changed files with 184 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/test/groovy/me/champeau/gradle/AnnotationFilteringTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class AnnotationFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED METHOD: PUBLIC void (<-int) stableMethod()')
def report = getReport('japi', 'txt').text
!report.contains('MODIFIED METHOD: PUBLIC void (<-int) betaMethod()')

when:
result = run 'japicmpOnlyCheckStableApi'

then:
result.task(":japicmpOnlyCheckStableApi").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding @BetaApi hides beta methods"() {
Expand All @@ -25,5 +31,11 @@ class AnnotationFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED METHOD: PUBLIC void (<-int) stableMethod()')
def report = getReport('japi', 'txt').text
!report.contains('MODIFIED METHOD: PUBLIC void (<-int) betaMethod()')

when:
result = run 'japicmpExcludeBetaApi'

then:
result.task(":japicmpExcludeBetaApi").outcome == TaskOutcome.UP_TO_DATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class Compare2JarsFunctionalTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED CLASS: PUBLIC org.apache.commons.lang3.AnnotationUtils')
noHtmlReport()
noRichReport()

when:
result = run 'japicmp'

then:
result.task(":japicmp").outcome == TaskOutcome.UP_TO_DATE
}

def "can compare 2 jars using explicit archives property"() {
Expand All @@ -25,5 +31,11 @@ class Compare2JarsFunctionalTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED CLASS: PUBLIC org.apache.commons.lang3.AnnotationUtils')
noHtmlReport()
noRichReport()

when:
result = run 'japicmpWithExplicitClasspath'

then:
result.task(":japicmpWithExplicitClasspath").outcome == TaskOutcome.UP_TO_DATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ class Compare2LibrariesFunctionalTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED CLASS: PUBLIC org.apache.commons.lang3.AnnotationUtils')
noHtmlReport()
noRichReport()

when:
result = run 'japicmp'

then:
result.task(":japicmp").outcome == TaskOutcome.UP_TO_DATE
}
}
14 changes: 14 additions & 0 deletions src/test/groovy/me/champeau/gradle/CustomFilteringTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class CustomFilteringTest extends BaseFunctionalTest {
hasTextReport('REMOVED FIELD: PUBLIC(-) java.lang.String someField')
hasTextReport('REMOVED METHOD: PUBLIC(-) void someMethod()')

when:
result = run 'japicmpAddCustomMatchTriggers'

then:
println(result.output)
result.task(":japicmpAddCustomMatchTriggers").outcome == TaskOutcome.UP_TO_DATE

when:
result = run 'japicmpRemoveCustomMatchTriggers'

Expand All @@ -28,5 +35,12 @@ class CustomFilteringTest extends BaseFunctionalTest {
result.task(":japicmpRemoveCustomMatchTriggers").outcome == TaskOutcome.SUCCESS
hasTextReport('NEW FIELD: PUBLIC(+) java.lang.String someField')
hasTextReport('NEW METHOD: PUBLIC(+) void someMethod()')

when:
result = run 'japicmpRemoveCustomMatchTriggers'

then:
println(result.output)
result.task(":japicmpRemoveCustomMatchTriggers").outcome == TaskOutcome.UP_TO_DATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class DefaultRulesRichReportFunctionalTest extends BaseFunctionalTest {
report =~ '<a class=\'navbar-brand\' href=\'#\'>Binary compatibility report</a>'
report =~ 'Class org.apache.commons.lang3.time.FastDateFormat: Is not binary compatible'
report =~ 'Class org.apache.commons.lang3.CharSetUtils: has been modified in source compatible way'

when:
result = fails "japicmp"

then:
result.task(":japicmp").outcome == TaskOutcome.FAILED
}

}
24 changes: 24 additions & 0 deletions src/test/groovy/me/champeau/gradle/FieldFilteringTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class FieldFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED FIELD: PUBLIC java.lang.String (<- int) bad')
def report = getReport('japi', 'txt').text
!report.contains('UNCHANGED FIELD: PUBLIC java.lang.String unchanged')

when:
result = run 'japicmpFieldIncludeOnlyBad'

then:
result.task(":japicmpFieldIncludeOnlyBad").outcome == TaskOutcome.UP_TO_DATE
}

def "including only good field"() {
Expand All @@ -25,6 +31,12 @@ class FieldFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED FIELD: PUBLIC java.lang.String unchanged')
def report = getReport('japi', 'txt').text
!report.contains('MODIFIED FIELD: PUBLIC java.lang.String (<- int) bad')

when:
result = run 'japicmpFieldIncludeOnlyGood'

then:
result.task(":japicmpFieldIncludeOnlyGood").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding good field"() {
Expand All @@ -36,6 +48,12 @@ class FieldFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED FIELD: PUBLIC java.lang.String (<- int) bad')
def report = getReport('japi', 'txt').text
!report.contains('UNCHANGED FIELD: PUBLIC java.lang.String unchanged')

when:
result = run 'japiCmpFieldExcludeKeepBad'

then:
result.task(":japiCmpFieldExcludeKeepBad").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding bad field"() {
Expand All @@ -47,5 +65,11 @@ class FieldFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED FIELD: PUBLIC java.lang.String unchanged')
def report = getReport('japi', 'txt').text
!report.contains('MODIFIED FIELD: PUBLIC java.lang.String (<- int) bad')

when:
result = run 'japicmpFieldExcludeKeepGood'

then:
result.task(":japicmpFieldExcludeKeepGood").outcome == TaskOutcome.UP_TO_DATE
}
}
24 changes: 24 additions & 0 deletions src/test/groovy/me/champeau/gradle/MethodFilteringTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class MethodFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED METHOD: PUBLIC void (<-int) getInteger()')
def report = getReport('japi', 'txt').text
!report.contains('UNCHANGED METHOD: PUBLIC void unchanged()')

when:
result = run 'japicmpMethodIncludeOnlyBad'

then:
result.task(":japicmpMethodIncludeOnlyBad").outcome == TaskOutcome.UP_TO_DATE
}

def "including only good method"() {
Expand All @@ -25,6 +31,12 @@ class MethodFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED METHOD: PUBLIC void unchanged()')
def report = getReport('japi', 'txt').text
!report.contains('MODIFIED METHOD: PUBLIC void (<-int) getInteger()')

when:
result = run 'japicmpMethodIncludeOnlyGood'

then:
result.task(":japicmpMethodIncludeOnlyGood").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding good method"() {
Expand All @@ -36,6 +48,12 @@ class MethodFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED METHOD: PUBLIC void (<-int) getInteger()')
def report = getReport('japi', 'txt').text
!report.contains('UNCHANGED METHOD: PUBLIC void unchanged()')

when:
result = run 'japiCmpMethodExcludeKeepBad'

then:
result.task(":japiCmpMethodExcludeKeepBad").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding bad method"() {
Expand All @@ -47,5 +65,11 @@ class MethodFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED METHOD: PUBLIC void unchanged()')
def report = getReport('japi', 'txt').text
!report.contains('MODIFIED METHOD: PUBLIC void (<-int) getInteger()')

when:
result = run 'japicmpMethodExcludeKeepGood'

then:
result.task(":japicmpMethodExcludeKeepGood").outcome == TaskOutcome.UP_TO_DATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED CLASS: PUBLIC me.champeau.gradle.japicmp.bad.Bad')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.good.Good')

when:
result = run 'japicmpPackageIncludeOnlyBad'

then:
result.task(":japicmpPackageIncludeOnlyBad").outcome == TaskOutcome.UP_TO_DATE
}

def "including only good package"() {
Expand All @@ -25,6 +31,12 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED CLASS: PUBLIC me.champeau.gradle.japicmp.good.Good')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.bad.Bad')

when:
result = run 'japicmpPackageIncludeOnlyGood'

then:
result.task(":japicmpPackageIncludeOnlyGood").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding good package"() {
Expand All @@ -36,6 +48,12 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED CLASS: PUBLIC me.champeau.gradle.japicmp.bad.Bad')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.good.Good')

when:
result = run 'japiCmpPackageExcludeKeepBad'

then:
result.task(":japiCmpPackageExcludeKeepBad").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding bad package"() {
Expand All @@ -47,6 +65,12 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED CLASS: PUBLIC me.champeau.gradle.japicmp.good.Good')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.bad.Bad')

when:
result = run 'japicmpPackageExcludeKeepGood'

then:
result.task(":japicmpPackageExcludeKeepGood").outcome == TaskOutcome.UP_TO_DATE
}

def "including only bad class"() {
Expand All @@ -58,6 +82,12 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED CLASS: PUBLIC me.champeau.gradle.japicmp.bad.Bad')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.good.Good')

when:
result = run 'japicmpClassIncludeOnlyBad'

then:
result.task(":japicmpClassIncludeOnlyBad").outcome == TaskOutcome.UP_TO_DATE
}

def "including only good class"() {
Expand All @@ -69,6 +99,12 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED CLASS: PUBLIC me.champeau.gradle.japicmp.good.Good')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.bad.Bad')

when:
result = run 'japicmpClassIncludeOnlyGood'

then:
result.task(":japicmpClassIncludeOnlyGood").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding good class"() {
Expand All @@ -80,6 +116,12 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('MODIFIED CLASS: PUBLIC me.champeau.gradle.japicmp.bad.Bad')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.good.Good')

when:
result = run 'japiCmpClassExcludeKeepBad'

then:
result.task(":japiCmpClassExcludeKeepBad").outcome == TaskOutcome.UP_TO_DATE
}

def "excluding bad class"() {
Expand All @@ -91,5 +133,11 @@ class PackageAndClassFilteringTest extends BaseFunctionalTest {
hasTextReport('UNCHANGED CLASS: PUBLIC me.champeau.gradle.japicmp.good.Good')
def report = getReport('japi', 'txt').text
!report.contains('me.champeau.gradle.japicmp.bad.Bad')

when:
result = run 'japicmpClassExcludeKeepGood'

then:
result.task(":japicmpClassExcludeKeepGood").outcome == TaskOutcome.UP_TO_DATE
}
}
12 changes: 12 additions & 0 deletions src/test/groovy/me/champeau/gradle/ReportsFunctionalTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class ReportsFunctionalTest extends BaseFunctionalTest {
hasHtmlReport('<a href="#org.apache.commons.lang3.event.EventListenerSupport">')
noTxtReport()
noRichReport()

when:
result = run 'japicmp'

then:
result.task(":japicmp").outcome == TaskOutcome.UP_TO_DATE
}

def "can generate rich report"() {
Expand All @@ -26,5 +32,11 @@ class ReportsFunctionalTest extends BaseFunctionalTest {
hasRichReport('A test of rich report')
noTxtReport()
noHtmlReport()

when:
result = run 'japicmpRich'

then:
result.task(":japicmpRich").outcome == TaskOutcome.UP_TO_DATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class RichReportFunctionalTest extends BaseFunctionalTest {

@Unroll("can generate rich report with #type rules")
def "can generate rich report with rules"() {
def task = "japicmp${type.capitalize()}"
when:
def result = run "japicmp${type.capitalize()}"
def result = run task

then:
result.task(":japicmp${type.capitalize()}").outcome == TaskOutcome.SUCCESS
Expand All @@ -18,6 +19,12 @@ class RichReportFunctionalTest extends BaseFunctionalTest {
report =~ 'A test of rich report'
report =~ 'This class is deprecated'

when:
result = run task

then:
result.task(":$task").outcome == TaskOutcome.UP_TO_DATE

where:
type << ['generic', 'status', 'change']
}
Expand Down
18 changes: 18 additions & 0 deletions src/test/groovy/me/champeau/gradle/SourceIncompatibleChange.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class SourceIncompatibleChangeTest extends BaseFunctionalTest {

then:
result.task(":japicmpIgnoresSourceCompatabilityByDefault").outcome == TaskOutcome.SUCCESS

when:
result = run 'japicmpIgnoresSourceCompatabilityByDefault'

then:
result.task(":japicmpIgnoresSourceCompatabilityByDefault").outcome == TaskOutcome.UP_TO_DATE
}

def "source incompatibility breaks build"() {
Expand All @@ -19,6 +25,12 @@ class SourceIncompatibleChangeTest extends BaseFunctionalTest {

then:
result.task(":japicmpFailsOnSourceIncompatability").outcome == TaskOutcome.FAILED

when:
result = fails 'japicmpFailsOnSourceIncompatability'

then:
result.task(":japicmpFailsOnSourceIncompatability").outcome == TaskOutcome.FAILED
}

def "source incompatibility breaks build (non-public access)"() {
Expand All @@ -27,5 +39,11 @@ class SourceIncompatibleChangeTest extends BaseFunctionalTest {
then:
result.task(":japicmpFailsOnSourceIncompatabilityNonPublic").outcome == TaskOutcome.FAILED
when:
result = fails 'japicmpFailsOnSourceIncompatabilityNonPublic'
then:
result.task(":japicmpFailsOnSourceIncompatabilityNonPublic").outcome == TaskOutcome.FAILED
}
}

0 comments on commit d6da144

Please sign in to comment.