Skip to content

Commit

Permalink
bug(#3698): it
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Dec 19, 2024
1 parent 1f81597 commit 0d47108
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eo-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Here `fibonacci` is the name of the desired integration test, `-DskipTests` is u

## How to disable Integration Tests

It is sometime necessary to temporary disable the integration tests (for example for introducing
It is sometime necessary to temporarily disable the integration tests (for example for introducing
braking changes into plugin or EO runtime). This can be achieved by disabling `maven-invoker-plugin`
execution within `eo-maven-plugin/pom.xml`:

Expand Down
9 changes: 9 additions & 0 deletions eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ SOFTWARE.
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration combine.self="override">
<!--
All integration tests are enabled.
-->
<pomExcludes/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions eo-maven-plugin/src/it/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- markdownlint-disable-next-line line-length -->
<img alt="logo" src="https://www.yegor256.com/images/books/elegant-objects/cactus.svg" height="100px" />

[![Maven Central](https://img.shields.io/maven-central/v/org.eolang/eo-maven-plugin.svg)](https://maven-badges.herokuapp.com/maven-central/org.eolang/eo-maven-plugin)

This directory contains integration tests for eolang-maven-plugin,
but you can use them as examples of EO-to-Java transformations.
18 changes: 18 additions & 0 deletions eo-maven-plugin/src/it/fibonacci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<img alt="logo" src="https://www.objectionary.com/cactus.svg" height="100px" />

This is a simple example a program written entirely in EO.
You can use the files from this directory as a template.
The only change you will have to do is setting
the right versions the `pom.xml`. Use the latest version
visible in this badge:

[![Maven Central](https://img.shields.io/maven-central/v/org.eolang/eo-maven-plugin.svg)](https://maven-badges.herokuapp.com/maven-central/org.eolang/eo-maven-plugin)

Just copy these files to your local directory, change the
version in `pom.xml` and run `mvn test` (it is assumed that
you have [Maven 3.3+](https://maven.apache.org/) installed).

If everything works fine, you will see the `SUCCESS` message
in the console. The files generated during parsing, optimization,
and compilation are available in `target/eo` directory. This directory
will be created by Maven automatically.
24 changes: 24 additions & 0 deletions eo-maven-plugin/src/it/fibonacci/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The MIT License (MIT)
#
# Copyright (c) 2016-2024 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (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.

invoker.mavenOpts = -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
invoker.goals = clean test
103 changes: 103 additions & 0 deletions eo-maven-plugin/src/it/fibonacci/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License (MIT)
Copyright (c) 2016-2024 Objectionary.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jcabi</groupId>
<artifactId>parent</artifactId>
<version>0.68.0</version>
</parent>
<groupId>org.eolang</groupId>
<artifactId>examples</artifactId>
<version>@project.version@</version>
<packaging>jar</packaging>
<name>Fibonacci Numbers Calculator</name>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration combine.self="override"/>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<failIfNoTests>false</failIfNoTests>
</configuration>
</plugin>
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>register</goal>
<goal>assemble</goal>
<goal>transpile</goal>
<goal>sodg</goal>
</goals>
</execution>
</executions>
<configuration>
<unrollExitError>true</unrollExitError>
<sodgIncludes>
<o>org.eolang.error</o>
</sodgIncludes>
<foreign>${project.build.directory}/eo/foreign.csv</foreign>
<foreignFormat>csv</foreignFormat>
<placed>${project.build.directory}/eo/placed.json</placed>
<placedFormat>json</placedFormat>
<trackOptimizationSteps>true</trackOptimizationSteps>
<generateSodgXmlFiles>true</generateSodgXmlFiles>
<generateGraphFiles>true</generateGraphFiles>
<generateXemblyFiles>true</generateXemblyFiles>
<generateDotFiles>true</generateDotFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.eolang.Main</mainClass>
<arguments>
<argument>org.eolang.examples.app</argument>
<argument>6</argument>
<argument>8</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# The MIT License (MIT)
#
# Copyright (c) 2016-2024 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (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.

+package org.eolang.examples
+alias org.eolang.examples.fibonacci
+alias org.eolang.io.stdout
+alias org.eolang.txt.sprintf
+alias org.eolang.txt.sscanf
+architect yegor256@gmail.com

# Application.
[args] > app
number > n
at. > nn!
QQ.txt.sscanf
"%d"
args.at 0
0
at. > e!
QQ.txt.sscanf
"%d"
args.at 1
0
fibonacci n > f!
and. > @
stdout
sprintf
"%dth Fibonacci number is %d\n"
* n f
e.eq f

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# The MIT License (MIT)
#
# Copyright (c) 2016-2024 Objectionary.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (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.

+architect yegor256@gmail.com
+package org.eolang.examples

# This is the main abstract object that
# represents n-th Fibonacci number
[n] > fibonacci
if. > @
lt.
n
2
n
plus.
^.fibonacci
n.minus 1
^.fibonacci
n.minus 2
72 changes: 72 additions & 0 deletions eo-maven-plugin/src/it/fibonacci/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016-2024 Objectionary.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (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.
*/

/**
* Check the internet connection.
*
* @return Is the internet connection available
*/
private static boolean online() {
boolean online = true
try {
final URL url = new URL('http://www.google.com')
final URLConnection conn = url.openConnection()
conn.connect()
conn.inputStream.close()
} catch (final IOException ignored) {
online = false
}
return online
}

[
'target/eo/foreign.csv',
'target/generated-sources/EOorg/EOeolang/EOexamples/EOapp.java',
'target/eo/1-parse/org/eolang/examples/app.xmir',
'target/eo/2-optimization-steps/org/eolang/examples/app/00-not-empty-atoms.xml',
'target/eo/2-optimize/org/eolang/examples/app.xmir',
'target/eo/6-pre/org/eolang/examples/app/01-classes.xml',
'target/eo/7-transpile/org/eolang/examples/app.xmir',
'target/eo/sodg/org/eolang/error.sodg',
'target/eo/sodg/org/eolang/error.sodg.xe',
'target/eo/sodg/org/eolang/error.sodg.graph.xml',
'target/eo/sodg/org/eolang/error.sodg.dot',
].each { path -> assert new File(basedir, path).exists() }

[
'target/classes/EOorg/EOeolang/EOexamples/EOapp.class',
'target/eo/placed.json',
'target/eo/4-pull/org/eolang/tuple.eo',
].each { path -> assert new File(basedir, path).exists() || !online() }

String log = new File(basedir, 'build.log').text

[
'org.eolang:eo-runtime:',
' unpacked to ',
'6th Fibonacci number is 8',
'BUILD SUCCESS',
].each { expectedLog -> assert log.contains(expectedLog) || !online() }

true
Loading

0 comments on commit 0d47108

Please sign in to comment.