This is an automated email from the ASF dual-hosted git repository.
paulk-asert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 12f8434883 add Locale/TimeZone Jupiter isolation annotations - we
don't use parallel tests yet but this would safeguard us if we do
12f8434883 is described below
commit 12f8434883693782bd7eb4e426f9ade173d43848
Author: Paul King <[email protected]>
AuthorDate: Sun Jul 12 08:51:00 2026 +1000
add Locale/TimeZone Jupiter isolation annotations - we don't use parallel
tests yet but this would safeguard us if we do
---
src/test/groovy/groovy/PrintTest.groovy | 5 +++++
.../groovy-dateutil/src/test/groovy/groovy/DateTest.groovy | 13 +++++++++++++
.../dateutil/extensions/DateUtilExtensionsTest.groovy | 4 ++++
.../src/test/groovy/groovy/xml/XmlUtilTest.groovy | 4 ++++
4 files changed, 26 insertions(+)
diff --git a/src/test/groovy/groovy/PrintTest.groovy
b/src/test/groovy/groovy/PrintTest.groovy
index f0d3196c7c..7d659ca508 100644
--- a/src/test/groovy/groovy/PrintTest.groovy
+++ b/src/test/groovy/groovy/PrintTest.groovy
@@ -22,12 +22,17 @@ import groovy.io.GroovyPrintStream
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.parallel.ResourceLock
+import org.junit.jupiter.api.parallel.Resources
import java.text.NumberFormat
import static groovy.test.GroovyAssert.shouldFail
import static org.junit.jupiter.api.Assertions.assertEquals
+// setUp() mutates the JVM-wide default Locale; the lock is a no-op under
today's
+// sequential execution and guards these tests if in-JVM parallelism is ever
enabled.
+@ResourceLock(Resources.LOCALE)
class PrintTest {
PrintStream savedSystemOut
private locale
diff --git a/subprojects/groovy-dateutil/src/test/groovy/groovy/DateTest.groovy
b/subprojects/groovy-dateutil/src/test/groovy/groovy/DateTest.groovy
index b88b677fc3..87962986cc 100644
--- a/subprojects/groovy-dateutil/src/test/groovy/groovy/DateTest.groovy
+++ b/subprojects/groovy-dateutil/src/test/groovy/groovy/DateTest.groovy
@@ -19,6 +19,9 @@
package groovy
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.parallel.ResourceLock
+import org.junit.jupiter.api.parallel.ResourceLocks
+import org.junit.jupiter.api.parallel.Resources
import java.text.DateFormat
import java.text.SimpleDateFormat
@@ -95,6 +98,8 @@ class DateTest {
}
@Test
+ // mutates the JVM-wide default Locale and TimeZone; guards against future
in-JVM parallelism
+ @ResourceLocks([@ResourceLock(Resources.LOCALE),
@ResourceLock(Resources.TIME_ZONE)])
void testGDKDateMethods() {
Locale defaultLocale = Locale.default
TimeZone defaultTZ = TimeZone.default
@@ -117,6 +122,8 @@ class DateTest {
}
@Test
+ // mutates the JVM-wide default TimeZone; guards against future in-JVM
parallelism
+ @ResourceLock(Resources.TIME_ZONE)
void testStaticParse() {
TimeZone defaultTZ = TimeZone.default
try {
@@ -131,6 +138,8 @@ class DateTest {
}
@Test
+ // mutates the JVM-wide default TimeZone; guards against future in-JVM
parallelism
+ @ResourceLock(Resources.TIME_ZONE)
void testParseWithTimeZone() {
TimeZone defaultTZ = TimeZone.default
try {
@@ -157,6 +166,8 @@ class DateTest {
}
@Test
+ // mutates the JVM-wide default Locale and TimeZone; guards against future
in-JVM parallelism
+ @ResourceLocks([@ResourceLock(Resources.LOCALE),
@ResourceLock(Resources.TIME_ZONE)])
void testCalendarTimeZone() {
Locale defaultLocale = Locale.default
TimeZone defaultTZ = TimeZone.default
@@ -230,6 +241,8 @@ class DateTest {
/** GROOVY-4789 */
@Test
+ // mutates the JVM-wide default TimeZone; guards against future in-JVM
parallelism
+ @ResourceLock(Resources.TIME_ZONE)
void testStaticParseToStringDate() {
TimeZone tz = TimeZone.getDefault()
try {
diff --git
a/subprojects/groovy-dateutil/src/test/groovy/org/apache/groovy/dateutil/extensions/DateUtilExtensionsTest.groovy
b/subprojects/groovy-dateutil/src/test/groovy/org/apache/groovy/dateutil/extensions/DateUtilExtensionsTest.groovy
index d8099718da..9b2b20116f 100644
---
a/subprojects/groovy-dateutil/src/test/groovy/org/apache/groovy/dateutil/extensions/DateUtilExtensionsTest.groovy
+++
b/subprojects/groovy-dateutil/src/test/groovy/org/apache/groovy/dateutil/extensions/DateUtilExtensionsTest.groovy
@@ -22,6 +22,8 @@ import groovy.lang.Closure
import groovy.lang.GroovyRuntimeException
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.parallel.ResourceLock
+import org.junit.jupiter.api.parallel.Resources
import java.sql.Timestamp
import java.text.SimpleDateFormat
@@ -428,6 +430,8 @@ class DateUtilExtensionsTest {
// format tests
@Test
+ // mutates the JVM-wide default TimeZone; guards against future in-JVM
parallelism
+ @ResourceLock(Resources.TIME_ZONE)
void testFormatDate() {
def originalTz = TimeZone.getDefault()
try {
diff --git
a/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy
b/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy
index fc1517ffb2..c03a842d01 100644
--- a/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy
+++ b/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy
@@ -19,6 +19,8 @@
package groovy.xml
import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.parallel.ResourceLock
+import org.junit.jupiter.api.parallel.Resources
import org.xml.sax.ErrorHandler
import org.xml.sax.InputSource
@@ -58,6 +60,8 @@ class XmlUtilTest {
// GROOVY-5361
@Test
+ // mutates the JVM-wide default Locale; guards against future in-JVM
parallelism
+ @ResourceLock(Resources.LOCALE)
void schemaValidationUtilityMethod() {
Locale dl = Locale.getDefault()
Locale.setDefault(Locale.ENGLISH)