Skip to content

Commit 73d9401

Browse files
committed
Configure 'test' task to run against to all the tests in the TCK
Closes gh-133
1 parent 9b4fb50 commit 73d9401

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ plugins {
3232

3333
apply plugin: 'org.graceframework.grace-doc'
3434

35+
ext {
36+
isCiBuild = project.hasProperty("isCiBuild") || System.getenv().get("CI") as Boolean
37+
isBuildSnapshot = project.version.endsWith("-SNAPSHOT")
38+
isReleaseVersion = !isBuildSnapshot
39+
}
40+
3541
ext."signing.keyId" = project.hasProperty("signing.keyId") ? project.getProperty('signing.keyId') : System.getenv('SIGNING_KEY')
3642
ext."signing.password" = project.hasProperty("signing.password") ? project.getProperty('signing.password') : System.getenv('SIGNING_PASSPHRASE')
3743
ext."signing.secretKeyRingFile" = project.hasProperty("signing.secretKeyRingFile") ? project.getProperty('signing.secretKeyRingFile') : ("${System.properties['user.home']}${File.separator}.gnupg${File.separator}secring.gpg")

grace-datastore-gorm-hibernate/build.gradle

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,75 @@ dependencies {
3838
testImplementation libs.tomcat.jdbc
3939
testRuntimeOnly libs.glassfish.expressly
4040
}
41+
42+
43+
test {
44+
systemProperty('hibernate5.gorm.suite', System.getProperty('hibernate5.gorm.suite') ?: true)
45+
useJUnitPlatform()
46+
if (isCiBuild) {
47+
maxParallelForks = 1
48+
forkEvery = 10
49+
}
50+
else {
51+
maxParallelForks = 1
52+
forkEvery = 30
53+
}
54+
55+
jvmArgs = ['-Xmx1028M']
56+
afterSuite {
57+
System.out.print('.')
58+
System.out.flush()
59+
}
60+
}
61+
62+
63+
test.doFirst {
64+
def toBaseClassRelativePathWithoutExtension = { String base, String classFile ->
65+
if (classFile.startsWith(base)) {
66+
def sansClass = classFile[0 .. classFile.size() - ".class".size() - 1]
67+
def dollarIndex = sansClass.indexOf('$')
68+
def baseClass = dollarIndex > 0 ? sansClass[0..dollarIndex - 1] : sansClass
69+
def relative = baseClass - base - '/'
70+
relative
71+
}
72+
else {
73+
null
74+
}
75+
}
76+
def tckClassesFile = project
77+
.configurations
78+
.testCompileClasspath
79+
.resolvedConfiguration
80+
.getResolvedArtifacts()
81+
.find { resolved ->
82+
resolved.moduleVersion.id.name == 'grace-datastore-gorm-tck'
83+
}.file
84+
85+
def tckClassesDir = project.file("${project.buildDir}/tck")
86+
copy {
87+
from zipTree(tckClassesFile)
88+
into tckClassesDir
89+
}
90+
copy {
91+
from tckClassesDir
92+
into sourceSets.test.output.classesDirs.find { it.path.contains('classes/groovy') }
93+
include "**/*.class"
94+
exclude { details ->
95+
// Do not copy across any TCK class (or nested classes of that class)
96+
// If there is a corresponding source file in the particular modules
97+
// test source tree. Allows a module to override a test/helper.
98+
99+
if (!details.file.isFile()) {
100+
return false
101+
}
102+
def candidatePath = details.file.absolutePath
103+
def relativePath = toBaseClassRelativePathWithoutExtension(tckClassesDir.absolutePath, candidatePath)
104+
105+
if (relativePath == null) {
106+
throw new IllegalStateException("$candidatePath does not appear to be in the TCK")
107+
}
108+
109+
project.file("src/test/groovy/${relativePath}.groovy").exists()
110+
}
111+
}
112+
}

0 commit comments

Comments
 (0)