You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/11/22 15:11:29 UTC

[groovy] 13/18: fix test suite isolation

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

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4af20f99be63a1e8cfc4b61a19192f710433a3d1
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Nov 21 15:46:09 2019 -0600

    fix test suite isolation
    
    (cherry picked from commit 751a89d12efee0231d057a2064c2cc1ecacc068c)
---
 src/test/groovy/grape/GrabResolverTest.groovy | 43 ++++++++++-----------------
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/src/test/groovy/grape/GrabResolverTest.groovy b/src/test/groovy/grape/GrabResolverTest.groovy
index f7e4429..7181ab5 100644
--- a/src/test/groovy/grape/GrabResolverTest.groovy
+++ b/src/test/groovy/grape/GrabResolverTest.groovy
@@ -18,12 +18,12 @@
  */
 package groovy.grape
 
+import groovy.transform.CompileDynamic
 import groovy.transform.CompileStatic
 import org.codehaus.groovy.control.CompilationFailedException
 import org.junit.AfterClass
 import org.junit.Before
 import org.junit.BeforeClass
-import org.junit.Ignore
 import org.junit.Test
 
 import static groovy.test.GroovyAssert.assertScript
@@ -39,7 +39,7 @@ final class GrabResolverTest {
         originalGrapeRoot = System.getProperty('grape.root')
     }
 
-    @Before
+    @Before @CompileDynamic
     void setUp() {
         Grape.@instance = null // isolate each test
 
@@ -48,6 +48,10 @@ final class GrabResolverTest {
         System.setProperty('grape.root', grapeRoot.path)
         assert grapeRoot.mkdir()
         grapeRoot.deleteOnExit()
+
+        Grape.instance.settings.getResolver('downloadGrapes').resolvers.removeAll {
+            it.name == 'jcenter' || it.name == 'localm2'
+        }
     }
 
     @AfterClass
@@ -61,32 +65,13 @@ final class GrabResolverTest {
         Grape.@instance = null // isolate these tests from other tests
     }
 
-    @Test @Ignore('manual')
-    void testChecksumsCanBeDisabled() {
-        // TODO someone has cleaned up the checksum info in the public repos that this test
-        // was relying on and so this test no longer fails unless you have the corrupt SHA1
-        // value cached in your local grapes repo, change test to not rely on that fact and
-        // then reinstate (use a local file repo?)
-        shouldFail RuntimeException, '''
-            @Grab('org.mvel:mvel2:2.1.3.Final')
-            import org.mvel2.MVEL
-            assert MVEL.name == 'org.mvel2.MVEL'
-        '''
-        assertScript '''
-            @Grab('org.mvel:mvel2:2.1.3.Final')
-            @GrabConfig(disableChecksums=true)
-            import org.mvel2.MVEL
-            assert MVEL.name == 'org.mvel2.MVEL'
-        '''
-    }
-
-    @Test // NOTE: 'org.restlet:org.restlet:1.1.6' must not be in local m2 repository for this test to pass
+    @Test
     void testResolverDefinitionIsRequired() {
         shouldFail CompilationFailedException, '''
             @Grab(group='org.restlet', module='org.restlet', version='1.1.6')
             import org.restlet.Application
-            class AnnotationHost {}
-            println 'hello world'
+
+            assert false : '"org.restlet:org.restlet:1.1.6" should not resolve without @GrabResolver'
         '''
     }
 
@@ -95,8 +80,9 @@ final class GrabResolverTest {
         assertScript '''
             @GrabResolver(name='restlet.org', root='http://maven.restlet.org')
             @Grab(group='org.restlet', module='org.restlet', version='1.1.6')
-            class AnnotationHost {}
-            assert org.restlet.Application.class.simpleName == 'Application'
+            import org.restlet.Application
+
+            assert Application.simpleName == 'Application'
         '''
     }
 
@@ -105,8 +91,9 @@ final class GrabResolverTest {
         assertScript '''
             @GrabResolver('http://maven.restlet.org')
             @Grab('org.restlet:org.restlet:1.1.6')
-            class AnnotationHost {}
-            assert org.restlet.Application.class.simpleName == 'Application'
+            import org.restlet.Application
+
+            assert Application.simpleName == 'Application'
         '''
     }
 }