@@ -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