Skip to content

Commit

Permalink
Consume a single conformance test ZIP (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
netdpb authored Dec 11, 2023
1 parent 935634c commit d80cf8a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
53 changes: 22 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ repositories {

configurations {
errorproneJavac
conformanceTestAssertions {
attributes {
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, DocsType.SOURCES))
}
}
conformanceTestDeps
conformanceTestSuite
}

ext {
Expand All @@ -46,19 +41,8 @@ dependencies {
testImplementation libs.jspecify.conformanceTestFramework
testRuntimeOnly libs.jsr305 // jsr305 annotations are in some of the samples

conformanceTestAssertions("org.jspecify.conformance:conformance-tests:0.0.0-SNAPSHOT") {
capabilities {
// Depend on the assertion sources
requireCapability "org.jspecify.conformance:conformance-tests-assertions"
}
}

conformanceTestDeps("org.jspecify.conformance:conformance-tests:0.0.0-SNAPSHOT") {
capabilities {
// Depend on the assertion dependencies
requireCapability "org.jspecify.conformance:conformance-tests-deps"
}
}
// TODO: Depend on a group:artifact:version rather than a file.
conformanceTestSuite files("${jspecify.projectDir}/conformance-tests/build/distributions/conformance-tests-0.0.0-SNAPSHOT.zip")

errorproneJavac libs.errorProne.javac
errorprone libs.errorProne.core
Expand Down Expand Up @@ -132,31 +116,38 @@ tasks.register('jspecifySamplesTest', Test) {
inputs.files("${jspecify.projectDir}/samples")
}

tasks.register('unzipConformanceTestAssertions', Copy) {
dependsOn configurations.conformanceTestAssertions
from zipTree(configurations.conformanceTestAssertions.singleFile)
tasks.register('unzipConformanceTestSuite', Copy) {
// TODO: Don't explicitly depend on an included build's task.
dependsOn jspecify.task(':conformance-tests:build')
dependsOn configurations.conformanceTestSuite
from zipTree(configurations.conformanceTestSuite.singleFile)
into layout.buildDirectory.dir("conformanceTests")
}

tasks.register('conformanceTests', Test) {
group = 'verification'
dependsOn 'unzipConformanceTestAssertions', configurations.conformanceTestDeps
include '**/ConformanceTest.class'

// Conformance tests
def conformanceTestsDir = tasks.named('unzipConformanceTestAssertions', Copy).get().destinationDir
inputs.dir(conformanceTestsDir)
inputs.files(unzipConformanceTestSuite)
inputs.files("tests/ConformanceTest-report.txt")
inputs.files(configurations.conformanceTestDeps)
systemProperty("JSpecifyConformanceTest.inputs", "$conformanceTestsDir/org/jspecify/conformance/tests")
systemProperty("JSpecifyConformanceTest.report", "tests/ConformanceTest-report.txt")
systemProperty("JSpecifyConformanceTest.deps", configurations.conformanceTestDeps.join(":"))
doFirst {
systemProperties([
"JSpecifyConformanceTest.inputs": "${unzipConformanceTestSuite.destinationDir}/assertions/org/jspecify/conformance/tests",
"JSpecifyConformanceTest.report": "tests/ConformanceTest-report.txt",
"JSpecifyConformanceTest.deps" : fileTree("${unzipConformanceTestSuite.destinationDir}/deps").join(":")
])
}

// Conformance tests run on the samples directory
inputs.dir("${jspecify.projectDir}/samples")
inputs.files("tests/ConformanceTestOnSamples-report.txt")
systemProperty("JSpecifyConformanceTest.samples.inputs", "${jspecify.projectDir}/samples")
systemProperty("JSpecifyConformanceTest.samples.report", "tests/ConformanceTestOnSamples-report.txt")
doFirst {
systemProperties([
"JSpecifyConformanceTest.samples.inputs": "${jspecify.projectDir}/samples",
"JSpecifyConformanceTest.samples.report": "tests/ConformanceTestOnSamples-report.txt"
])
}
}

tasks.named('check').configure {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/tests/ConformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public final class ConformanceTest {

private static final ImmutableList<Path> TEST_DEPS =
Stream.ofNullable(System.getProperty("JSpecifyConformanceTest.deps"))
.flatMap(Splitter.on(':')::splitToStream)
.flatMap(Splitter.on(':').trimResults().omitEmptyStrings()::splitToStream)
.map(Paths::get)
.collect(toImmutableList());

Expand Down
4 changes: 3 additions & 1 deletion tests/ConformanceTest-report.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 10 pass; 6 fail; 16 total; 62.5% score
# 12 pass; 6 fail; 18 total; 66.7% score
PASS: Basic.java:26 test:expression-type:Object?:nullable
PASS: Basic.java:26 test:sink-type:Object!:return
PASS: Basic.java:26 test:cannot-convert:Object? to Object!
Expand All @@ -15,3 +15,5 @@ FAIL: Irrelevant.java:43 test:irrelevant-annotation:Nullable
FAIL: Irrelevant.java:47 test:irrelevant-annotation:NullMarked
FAIL: Irrelevant.java:49 test:irrelevant-annotation:NullUnmarked
FAIL: Irrelevant.java: no unexpected facts
PASS: UsesDep.java:24 test:cannot-convert:null? to Dep*
PASS: UsesDep.java: no unexpected facts

0 comments on commit d80cf8a

Please sign in to comment.