@@ -10,11 +10,17 @@ import utest.*
1010object  HelloGroovyTests  extends  TestSuite  {
1111
1212  val  groovy4Version  =  " 4.0.28" 
13+   val  groovy5Version  =  " 5.0.1" 
14+   val  groovyVersions  =  Seq (groovy4Version, groovy5Version)
1315  val  junit5Version  =  sys.props.getOrElse(" TEST_JUNIT5_VERSION"  , " 5.13.4"  )
1416  val  spockGroovy4Version  =  " 2.3-groovy-4.0" 
1517
1618  object  HelloGroovy  extends  TestRootModule  {
1719
20+     trait  GroovyVersionCross  extends  GroovyModule  with  Cross .Module [String ]{
21+       override  def  groovyVersion :  Task .Simple [String ] =  crossValue
22+     }
23+     
1824    lazy  val  millDiscover  =  Discover [this .type ]
1925
2026    //  needed for a special test where only the tests are written in Groovy while appcode remains Java
@@ -32,11 +38,22 @@ object HelloGroovyTests extends TestSuite {
3238
3339    }
3440
35-     object  `joint-compile`  extends  GroovyModule  {
41+     /**  
42+      * Currently Spock does not support Groovy 5, so that's why it's currently 
43+      * pulled out of the cross compilation. 
44+      */  
45+     object  spock  extends  GroovyModule  {
3646      override  def  groovyVersion :  T [String ] =  groovy4Version
37-       override  def  mainClass  =  Some (" jointcompile.JavaMain"  )
47+       
48+       object  tests  extends  GroovyTests  with  TestModule .Spock  {
49+         override  def  jupiterVersion :  T [String ] =  junit5Version
50+         override  def  spockVersion :  T [String ] =  spockGroovy4Version
51+       }
3852    }
3953
54+     /**  
55+      * Test to verify BOM-resolution only done starting with the minimal version 
56+      */  
4057    object  deps  extends  Module  {
4158
4259      object  groovyBom  extends  GroovyModule  {
@@ -61,34 +78,31 @@ object HelloGroovyTests extends TestSuite {
6178
6279    }
6380
64-     trait  Test  extends  GroovyModule  {
81+     trait  Test  extends  GroovyVersionCross  {
6582
6683      override  def  mainClass  =  Some (" hello.Hello"  )
6784
68-       object  test  extends  GroovyTests  with  TestModule .Junit5  {
69-         override  def  jupiterVersion :  T [String ] =  junit5Version
70-         override  def  junitPlatformVersion  =  " 1.13.4" 
71-       }
72- 
7385      object  script  extends  GroovyModule  {
74-         override  def  groovyVersion :  T [String ] =  groovy4Version 
86+         override  def  groovyVersion :  T [String ] =  crossValue 
7587        override  def  mainClass  =  Some (" HelloScript"  )
7688      }
7789
7890      object  staticcompile  extends  GroovyModule  {
79-         override  def  groovyVersion :  T [String ] =  groovy4Version 
91+         override  def  groovyVersion :  T [String ] =  crossValue 
8092        override  def  mainClass  =  Some (" hellostatic.HelloStatic"  )
8193      }
8294
83-       object  spock  extends  GroovyTests  with  TestModule .Spock  {
95+       object  `joint-compile`  extends  GroovyModule  {
96+         override  def  groovyVersion :  T [String ] =  crossValue
97+         override  def  mainClass  =  Some (" jointcompile.JavaMain"  )
98+       }
99+ 
100+       object  test  extends  GroovyTests  with  TestModule .Junit5  {
84101        override  def  jupiterVersion :  T [String ] =  junit5Version
85-         override  def  spockVersion :  T [String ] =  spockGroovy4Version
86-         override  def  groovyVersion :  T [String ] =  groovy4Version
102+         override  def  junitPlatformVersion  =  " 1.13.4" 
87103      }
88104    }
89-     object  main  extends  Test  {
90-       override  def  groovyVersion :  T [String ] =  groovy4Version
91-     }
105+     object  main  extends  Cross [Test ](groovyVersions) 
92106  }
93107
94108  val  resourcePath  =  os.Path (sys.env(" MILL_TEST_RESOURCE_DIR"  )) /  " hello-groovy" 
@@ -100,58 +114,84 @@ object HelloGroovyTests extends TestSuite {
100114
101115  def  tests :  Tests  =  Tests  {
102116
103-     def  m  =  HelloGroovy .main
117+     def  main  =  HelloGroovy .main
118+     def  spock  =  HelloGroovy .spock
104119    def  mixed  =  HelloGroovy .`groovy-tests`
105-     def  joint  =  HelloGroovy .`joint-compile`
106120    def  deps  =  HelloGroovy .deps
107121
108122    test(" running a Groovy script"  ) {
109123      testEval().scoped { eval => 
110-         val  Right (_) =  eval.apply(m.script.run()):  @ unchecked
124+         main.crossModules.foreach(m =>  {
125+           val  Right (_) =  eval.apply(m.script.run()):  @ unchecked  
126+         })
111127      }
112128    }
113129
114130    test(" running a Groovy script"  ) {
115131      testEval().scoped { eval => 
116-         val  Right (_) =  eval.apply(m.script.run()):  @ unchecked
132+         main.crossModules.foreach(m =>  {
133+           val  Right (_) =  eval.apply(m.script.run()):  @ unchecked
134+         })
117135      }
118136    }
119137
120138    test(" compile & run Groovy module"  ) {
121139      testEval().scoped { eval => 
122-         val  Right (result) =  eval.apply(m.compile):  @ unchecked
140+         main.crossModules.foreach(m =>  {
141+           val  Right (result) =  eval.apply(m.compile):  @ unchecked
123142
124-         assert(
125-           os.walk(result.value.classes.path).exists(_.last ==  " Hello.class"  )
126-         )
143+            assert(
144+              os.walk(result.value.classes.path).exists(_.last ==  " Hello.class"  )
145+            )
127146
128-         val  Right (_) =  eval.apply(m.run()):  @ unchecked
147+           val  Right (_) =  eval.apply(m.run()):  @ unchecked
148+         })
129149      }
130150    }
131151
132152    test(" compile & run Groovy JUnit5 test"  ) {
133153      testEval().scoped { eval => 
154+         main.crossModules.foreach(m =>  {
155+           val  Right (result) =  eval.apply(m.test.compile):  @ unchecked
134156
135-         val  Right (result) =  eval.apply(m.test.compile):  @ unchecked
157+           assert(
158+             os.walk(result.value.classes.path).exists(_.last ==  " HelloTest.class"  )
159+           )
136160
137-         assert(
138-           os.walk(result.value.classes.path).exists(_.last ==  " HelloTest.class"  )
139-         )
140- 
141-         val  Right (discovered) =  eval.apply(m.test.discoveredTestClasses):  @ unchecked
142-         assert(discovered.value ==  Seq (" hello.tests.HelloTest"  ))
161+           val  Right (discovered) =  eval.apply(m.test.discoveredTestClasses):  @ unchecked
162+           assert(discovered.value ==  Seq (" hello.tests.HelloTest"  ))
143163
144-         val  Right (_) =  eval.apply(m.test.testForked()):  @ unchecked
164+           val  Right (_) =  eval.apply(m.test.testForked()):  @ unchecked
165+         })
145166      }
146167    }
147168
148169    test(" compile & run a statically compiled Groovy"  ) {
149170      testEval().scoped { eval => 
150-         val  Right (result) =  eval.apply(m.staticcompile.compile):  @ unchecked
151-         assert(
152-           os.walk(result.value.classes.path).exists(_.last ==  " HelloStatic.class"  )
153-         )
154-         val  Right (_) =  eval.apply(m.staticcompile.run()):  @ unchecked
171+         main.crossModules.foreach(m =>  {
172+           val  Right (result) =  eval.apply(m.staticcompile.compile):  @ unchecked
173+           assert(
174+             os.walk(result.value.classes.path).exists(_.last ==  " HelloStatic.class"  )
175+           )
176+           val  Right (_) =  eval.apply(m.staticcompile.run()):  @ unchecked
177+         })
178+       }
179+     }
180+ 
181+     test(" compile joint (groovy <-> java cycle) & run"  ) {
182+       testEval().scoped { eval => 
183+         main.crossModules.foreach(m =>  {
184+           val  Right (result) =  eval.apply(m.`joint-compile`.compile):  @ unchecked
185+ 
186+           assert(
187+             os.walk(result.value.classes.path).exists(_.last ==  " JavaPrinter.class"  )
188+           )
189+           assert(
190+             os.walk(result.value.classes.path).exists(_.last ==  " GroovyGreeter.class"  )
191+           )
192+ 
193+           val  Right (_) =  eval.apply(m.`joint-compile`.run()):  @ unchecked
194+         })
155195      }
156196    }
157197
@@ -168,31 +208,15 @@ object HelloGroovyTests extends TestSuite {
168208
169209    test(" compile & run Spock test"  ) {
170210      testEval().scoped { eval => 
171- 
172-         val  Right (result1) =  eval.apply(m.spock.compile):  @ unchecked
211+         val  Right (result1) =  eval.apply(spock.tests.compile):  @ unchecked
173212        assert(
174213          os.walk(result1.value.classes.path).exists(_.last ==  " SpockTest.class"  )
175214        )
176215
177-         val  Right (discovered) =  eval.apply(m. spock.discoveredTestClasses):  @ unchecked
216+         val  Right (discovered) =  eval.apply(spock.tests .discoveredTestClasses):  @ unchecked
178217        assert(discovered.value ==  Seq (" hello.spock.SpockTest"  ))
179218
180-         val  Right (_) =  eval.apply(m.spock.testForked()):  @ unchecked
181-       }
182-     }
183- 
184-     test(" compile joint (groovy <-> java cycle) & run"  ) {
185-       testEval().scoped { eval => 
186-         val  Right (result) =  eval.apply(joint.compile):  @ unchecked
187- 
188-         assert(
189-           os.walk(result.value.classes.path).exists(_.last ==  " JavaPrinter.class"  )
190-         )
191-         assert(
192-           os.walk(result.value.classes.path).exists(_.last ==  " GroovyGreeter.class"  )
193-         )
194- 
195-         val  Right (_) =  eval.apply(joint.run()):  @ unchecked
219+         val  Right (_) =  eval.apply(spock.tests.testForked()):  @ unchecked
196220      }
197221    }
198222
0 commit comments