Skip to content

Commit

Permalink
fix(#2684): added groovy test to check dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Dec 14, 2023
1 parent deae72d commit 0e71889
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
13 changes: 13 additions & 0 deletions eo-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ SOFTWARE.
<groupId>com.yegor256</groupId>
<artifactId>jaxec</artifactId>
<!-- version from parent POM -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yegor256</groupId>
<artifactId>jhome</artifactId>
<!-- version from parent POM -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
Expand All @@ -88,16 +90,19 @@ SOFTWARE.
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<!-- version from parent POM -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<!-- version from parent POM -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<!-- version from parent POM -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -201,6 +206,7 @@ SOFTWARE.
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>project-validate</id>
Expand All @@ -213,6 +219,13 @@ SOFTWARE.
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>3.0.19</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
38 changes: 38 additions & 0 deletions eo-runtime/src/test/groovy/check-runtime-deps.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016-2023 Objectionary.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation directories (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/


import groovy.xml.XmlSlurper

def pom = new File("pom.xml").text
def project = new XmlSlurper().parseText(pom)

println 'Verify that there aren no any dependencies in eo-runtime except those that are needed for tests'

project.dependencies.dependency.each {
if (it.scope.text() != 'test')
fail(String.format('Dependency %s.%s must be in "test" scope', it.groupId.text(), it.artifactId.text()))
}

true
15 changes: 12 additions & 3 deletions eo-runtime/src/test/groovy/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@ import java.nio.file.Path
* Entry point for running validation scripts.
* To add new validation create new script in this folder and add it
* to the list below.
* @todo #2684:30min Remove dependencies from eo-runtime. eo-runtime must stay clear out of any
* dependencies except those that are used in tests. It's needed to remove all such dependencies
* and include 'check-runtime-deps.groovy' test (which is failing for now) into 'tests' list. We
* also need to add "test" scope for all dependencies in pom.xml.
*/
Path tests = basedir.toPath().resolve("src").resolve("test").resolve("groovy");
for (it in ['check-folders-numbering.groovy', 'check-all-java-classes-compiled.groovy']) {
def res = evaluate tests.resolve(it).toFile()
Path folder = basedir.toPath().resolve("src").resolve("test").resolve("groovy");
tests = [
'check-folders-numbering.groovy',
'check-all-java-classes-compiled.groovy',
// 'check-runtime-deps.groovy'
]
for (it in tests) {
def res = evaluate folder.resolve(it).toFile()
println String.format('Verified with %s - OK. Result: %s', it, res)
}
true

0 comments on commit 0e71889

Please sign in to comment.