[groovy] branch master updated: minor refactor and make test a little more robust on CI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch master updated: minor refactor and make test a little more robust on CI

paulk
This is an automated email from the ASF dual-hosted git repository.

paulk 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 11e34b1  minor refactor and make test a little more robust on CI
11e34b1 is described below

commit 11e34b122e5a5b659c1276985f104ec10232adc6
Author: Paul King <[hidden email]>
AuthorDate: Mon Oct 12 23:42:12 2020 +1000

    minor refactor and make test a little more robust on CI
---
 .../ASTTransformationCustomizerTest.groovy         | 31 ++++++++++++----------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/test/org/codehaus/groovy/control/customizers/ASTTransformationCustomizerTest.groovy b/src/test/org/codehaus/groovy/control/customizers/ASTTransformationCustomizerTest.groovy
index 9dbcb5e..bbcc361 100644
--- a/src/test/org/codehaus/groovy/control/customizers/ASTTransformationCustomizerTest.groovy
+++ b/src/test/org/codehaus/groovy/control/customizers/ASTTransformationCustomizerTest.groovy
@@ -23,8 +23,6 @@ import groovy.transform.TimedInterrupt
 import groovy.util.logging.Log
 import org.codehaus.groovy.ast.ASTNode
 import org.codehaus.groovy.ast.ClassHelper
-import org.codehaus.groovy.ast.expr.ClassExpression
-import org.codehaus.groovy.ast.expr.PropertyExpression
 import org.codehaus.groovy.control.CompilePhase
 import org.codehaus.groovy.control.CompilerConfiguration
 import org.codehaus.groovy.control.SourceUnit
@@ -35,6 +33,9 @@ import java.util.concurrent.TimeUnit
 import java.util.concurrent.atomic.AtomicBoolean
 import java.util.logging.Logger
 
+import static org.codehaus.groovy.ast.tools.GeneralUtils.classX
+import static org.codehaus.groovy.ast.tools.GeneralUtils.propX
+
 /**
  * Tests the {@link ASTTransformationCustomizer}.
  */
@@ -121,21 +122,23 @@ class ASTTransformationCustomizerTest extends GroovyTestCase {
     }
 
     void testAnyExpressionAsParameterValue() {
-        customizer = new ASTTransformationCustomizer(value:100, unit: new PropertyExpression(new ClassExpression(ClassHelper.make(TimeUnit)),'MILLISECONDS'), TimedInterrupt)
+        customizer = new ASTTransformationCustomizer(value:200, unit: propX(classX(ClassHelper.make(TimeUnit)),'MILLISECONDS'), TimedInterrupt)
         configuration.addCompilationCustomizers(customizer)
         def shell = new GroovyShell(configuration)
-        def result = shell.evaluate '''import java.util.concurrent.TimeoutException
-
-boolean interrupted = false
-try {
-    200.times {
-        Thread.sleep(100)
-    }
-} catch (TimeoutException e) {
-    interrupted = true
-}
+        def result = shell.evaluate '''
+            import java.util.concurrent.TimeoutException
+
+            boolean interrupted = false
+            try {
+                10.times {
+                    sleep 100
+                }
+            } catch (TimeoutException ignore) {
+                interrupted = true
+            }
 
-interrupted'''
+            interrupted
+        '''
         assert result
     }