Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#2684): Added groovy test to check dependencies #2701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @todo #1326:30min Enable only necessary tests. Several checks
# are not available for the project. For example a lot of
# package name contains capital letter and such names are conventional.
exclude_paths:
exclude_paths:
- "eo-runtime/src/test/groovy/check-runtime-deps.groovy"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
skip: true
out:
- ".*Hello, дорогой!.*"
args: ["simple.main"]
Expand Down
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
Loading