Skip to content

Commit 791bcfc

Browse files
authored
Merge branch 'master' into SpyStatic
2 parents 3c5beab + ac06a53 commit 791bcfc

File tree

9 files changed

+84
-28
lines changed

9 files changed

+84
-28
lines changed

.github/renovate.json5

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
matchCurrentValue: "/^5\\./",
2626
allowedVersions: "(,6.0)"
2727
},
28+
{
29+
matchPackageNames: ["/^org.junit:/"],
30+
matchCurrentValue: "/^5\\./",
31+
allowedVersions: "(,6.0)"
32+
},
33+
{
34+
matchPackageNames: ["/^org.junit:/"],
35+
matchCurrentValue: "/^6\\./",
36+
allowedVersions: "(,7.0)"
37+
},
2838
{
2939
matchPackageNames: ["/^org.mockito:/"],
3040
matchCurrentValue: "/^4\\./",

README.adoc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,24 @@ Java 12+).
3939
Releases are available from
4040
https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.spockframework%22[Maven
4141
Central]. Development snapshots are available from
42-
https://oss.sonatype.org/content/repositories/snapshots/org/spockframework/[Sonatype
43-
OSS].
42+
https://central.sonatype.com/repository/maven-snapshots/org/spockframework/spock-core/maven-metadata.xml[Sonatype
43+
Snapshot].
44+
45+
==== Snapshot Releases
46+
47+
Snapshots can be used by adding the Sonatype Snapshot repository:
48+
49+
[source,groovy,subs="attributes"]
50+
----
51+
repositories {
52+
// ...
53+
maven { url 'https://central.sonatype.com/repository/maven-snapshots/' }
54+
}
55+
56+
dependencies {
57+
testImplementation 'org.spockframework:spock-core:{spock-snapshot-version}-groovy-4.0-SNAPSHOT'
58+
}
59+
----
4460

4561
==== Ad-Hoc Intermediate Releases
4662

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ subprojects {
165165
dependencies {
166166
api platform(projects.spockBom)
167167
implementation(project.name == "spock-gradle" ? [] : groovylibs.groovy)
168-
testImplementation(platform(libs.junit.bom))
168+
testImplementation(platform(libs.junit5.bom))
169169
testImplementation(libs.junit.platform.launcher)
170170
}
171171

gradle/libs.versions.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[versions]
2-
asciidoctorj = '3.0.0'
2+
asciidoctorj = '3.0.1'
33
groovy2 = '2.5.23'
44
groovy3 = '3.0.25'
55
groovy4 = '4.0.29'
66
groovy5 = '5.0.2'
77
jacoco = '0.8.14'
8-
junit = '5.14.1'
8+
junit5 = '5.14.1'
9+
junit6 = '6.0.1'
910
# The VersionRange used by OSGi to check compatibility with JUnit Platform.
1011
junitPlatformVersionRange = "[1.12,7)"
1112
asm = '9.9'
@@ -32,7 +33,8 @@ mockito5 = { module = "org.mockito:mockito-core", version.ref = "mockito5" }
3233
objenesis = "org.objenesis:objenesis:3.4"
3334
# This needs a classifier, but it has to be specified on the usage end https://melix.github.io/blog/2021/03/version-catalogs-faq.html#_why_can_t_i_use_excludes_or_classifiers
3435
jacoco-agent = { module = "org.jacoco:org.jacoco.agent", version.ref = "jacoco" }
35-
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
36+
junit5-bom = { module = "org.junit:junit-bom", version.ref = "junit5" }
37+
junit6-bom = { module = "org.junit:junit-bom", version.ref = "junit6" }
3638
# to omit the version we have to use this syntax, the version is managed by the junit-bom
3739
junit-jupiter.module = "org.junit.jupiter:junit-jupiter"
3840
junit-platform-console.module = "org.junit.platform:junit-platform-console"

spock-core/core.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ configurations {
2222

2323
dependencies {
2424
api groovylibs.groovy // easiest way to add Groovy dependency to POM
25-
api platform(libs.junit.bom)
25+
api platform(libs.junit5.bom)
2626
api 'org.junit.platform:junit-platform-engine'
2727
api libs.hamcrest
2828
if (variant == 2.5) {

spock-core/src/main/java/org/spockframework/util/JavaProcessThreadDumpCollector.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616

1717
package org.spockframework.util;
1818

19+
import org.codehaus.groovy.runtime.ResourceGroovyMethods;
1920
import org.spockframework.runtime.SpockException;
2021
import org.spockframework.runtime.extension.builtin.ThreadDumpUtility;
2122
import org.spockframework.runtime.extension.builtin.ThreadDumpUtilityType;
2223

2324
import java.io.*;
2425
import java.lang.management.ManagementFactory;
26+
import java.nio.charset.StandardCharsets;
27+
import java.nio.file.Files;
2528
import java.nio.file.Path;
2629
import java.nio.file.Paths;
2730
import java.util.List;
@@ -66,21 +69,23 @@ public void appendThreadDumpOfCurrentJvm(StringBuilder builder) throws IOExcepti
6669
.append(TextUtil.repeatChar('-', utilityName.length()))
6770
.append("\n");
6871

72+
73+
File threadDumpFile = Files.createTempFile("Spock-threaddump", ".txt").toFile();
74+
6975
Process process = new ProcessBuilder(command)
7076
.redirectErrorStream(true)
77+
.redirectOutput(ProcessBuilder.Redirect.to(threadDumpFile))
7178
.start();
7279

73-
captureProcessOutput(process, builder);
7480
process.waitFor();
81+
82+
readAndDeleteFile(builder, threadDumpFile);
7583
}
7684

77-
private void captureProcessOutput(Process process, StringBuilder builder) throws IOException {
78-
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
79-
String line;
80-
while ((line = reader.readLine()) != null) {
81-
builder.append(line).append("\n");
82-
}
83-
}
85+
private void readAndDeleteFile(StringBuilder builder, File threadDumpFile) throws IOException {
86+
builder.append(ResourceGroovyMethods.getText(threadDumpFile, StandardCharsets.UTF_8.name()));
87+
//noinspection ResultOfMethodCallIgnored
88+
threadDumpFile.delete(); // We do not care if the temp file could not be deleted.
8489
}
8590

8691
private static Path getJavaHome() {

spock-spring/boot2-test/boot2-test.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencyManagement {
3232
}
3333

3434
// Spring dependency management downgrades the jupiter version to 5.7.2 otherwise
35-
ext['junit-jupiter.version'] = libs.versions.junit.get()
35+
ext['junit-jupiter.version'] = libs.versions.junit5.get()
3636

3737
dependencies {
3838
implementation "org.springframework.boot:spring-boot-starter-data-jpa"

spock-spring/boot3-test/boot3-test.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ plugins {
2020
}
2121

2222
// Spring dependency management downgrades the jupiter version to 5.7.2 otherwise
23-
ext['junit-jupiter.version'] = libs.versions.junit.get()
23+
ext['junit-jupiter.version'] = libs.versions.junit5.get()
2424

2525
java {
2626
toolchain {

spock-testkit/testkit.gradle

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
ext.displayName = "Spock Framework - Temp Specs for Core Module"
1+
plugins {
2+
id 'jvm-test-suite'
3+
}
24

3-
//configurations {
4-
// junit
5-
//}
5+
ext.displayName = "Spock Framework - Spock TestKit Specs for Core Module"
66

77
dependencies {
88
api projects.spockCore
99

10-
testRuntimeOnly libs.asm
11-
testRuntimeOnly libs.bytebuddy
12-
testRuntimeOnly libs.cglib
13-
testRuntimeOnly libs.objenesis
14-
testRuntimeOnly libs.h2database
1510
testRuntimeOnly libs.junit.platform.console
16-
testImplementation libs.junit.platform.testkit
1711

12+
testImplementation libs.junit.platform.testkit
1813
testImplementation libs.junit.jupiter
1914
}
2015

21-
tasks.named("test", Test) {
16+
tasks.withType(Test).configureEach {
2217
reports.junitXml.required = true
2318
reports.html.required = false
2419

@@ -43,3 +38,31 @@ tasks.register("consoleLauncherTest", JavaExec) {
4338
args("--reports-dir", reportsDir)
4439
// systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
4540
}
41+
42+
43+
if (javaVersion >= 17) {
44+
testing {
45+
suites {
46+
junit6Test(JvmTestSuite) {
47+
useJUnitJupiter(libs.versions.junit6)
48+
sources {
49+
groovy {
50+
srcDirs = ['src/test/groovy']
51+
}
52+
}
53+
54+
dependencies {
55+
implementation projects.spockCore
56+
57+
implementation platform(libs.junit6.bom)
58+
implementation libs.junit.platform.testkit
59+
implementation libs.junit.jupiter
60+
}
61+
}
62+
}
63+
}
64+
65+
tasks.named('check') {
66+
dependsOn(testing.suites.junit6Test)
67+
}
68+
}

0 commit comments

Comments
 (0)