You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/11/30 03:24:20 UTC
[groovy] branch GROOVY_2_5_X updated: make test more resilient on
CI servers
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
new db984dd make test more resilient on CI servers
db984dd is described below
commit db984ddb97dd1afb996ae67041ee7880acd55ecb
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Nov 30 11:11:44 2020 +1000
make test more resilient on CI servers
---
src/test/groovy/bugs/Groovy8060Bug.groovy | 41 ++++++++++++++++++++++---------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/src/test/groovy/bugs/Groovy8060Bug.groovy b/src/test/groovy/bugs/Groovy8060Bug.groovy
index f233012..e69d993 100644
--- a/src/test/groovy/bugs/Groovy8060Bug.groovy
+++ b/src/test/groovy/bugs/Groovy8060Bug.groovy
@@ -18,22 +18,39 @@
*/
package groovy.bugs
+/**
+ * Flaky on CI servers, so retry a few times. We should make most tests involving
+ * Grape more isolated but having at least one end-to-end functional test might still be okay.
+ */
class Groovy8060Bug extends GroovyTestCase {
+ private static final int MAX_RETRIES = 3
void testLoggingWithinClosuresThatAreMethodArgsShouldHaveGuards() {
- assertScript '''
- @Grab('org.slf4j:slf4j-simple:1.7.30')
- import groovy.util.logging.Slf4j
+ int retry = 0
+ boolean success = false
+ Exception maybeIgnore = null
+ while (retry++ < MAX_RETRIES && !success) {
+ try {
+ assertScript '''
+ @Grab('org.slf4j:slf4j-simple:1.7.30')
+ import groovy.util.logging.Slf4j
- @Slf4j
- class LogMain {
- public static int count = 0
+ @Slf4j
+ class LogMain {
+ public static int count = 0
- static void main(args) {
- assert !log.isTraceEnabled()
- 1.times { log.trace("${count++}") }
- assert !count
- }
+ static void main(args) {
+ assert !log.isTraceEnabled()
+ 1.times { log.trace("${count++}") }
+ assert !count
+ }
+ }
+ '''
+ success = true
+ } catch(Exception ex) {
+ maybeIgnore = ex
+ sleep 100 * retry
}
- '''
+ }
+ if (!success) throw new RuntimeException("Couldn't assert script after $MAX_RETRIES retries", maybeIgnore)
}
}