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

some tests enabled #2711

Merged
merged 17 commits into from
Dec 22, 2023
19 changes: 11 additions & 8 deletions eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,20 @@ SOFTWARE.
</dependencies>
<build>
<plugins>
<!--
@todo #2555:30min Enable integration tests. Integration tests were disabled because of
new recursive implementation of tuple. Need to upload new version of eo-runtime to
Objectionary and enable integration tests by just removing "maven-invoker-plugin" from
this pom.xml. Don't forget to remove the puzzle.
-->
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<skipInstallation>true</skipInstallation>
<skipInvocation>true</skipInvocation>
<pomExcludes>
<!--
@todo #2660:30min Enable the following integration tests when it's possible.
Now they don't work because many .eo files are absent in the
objectionary/home repository. Once they are released, the tests
should work as is, without any modifications.
-->
<exclude>custom_goals/pom.xml</exclude>
<exclude>fibonacci/pom.xml</exclude>
<exclude>rewritten_sources/pom.xml</exclude>
</pomExcludes>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 2 additions & 0 deletions eo-maven-plugin/src/it/duplicate_classes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ SOFTWARE.
<goals>
<goal>register</goal>
<goal>assemble</goal>
<goal>verify</goal>
<goal>transpile</goal>
<goal>copy</goal>
<goal>unplace</goal>
Expand All @@ -86,6 +87,7 @@ SOFTWARE.
<goals>
<goal>register</goal>
<goal>assemble</goal>
<goal>verify</goal>
<goal>transpile</goal>
<goal>binarize</goal>
</goals>
Expand Down
4 changes: 4 additions & 0 deletions eo-maven-plugin/src/it/simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This is the simplest possible example of a program written in EO.
Don't make it more complex than it is right now.
The purpose of this integration test is to keep it running no matter
how much we change the eo-maven-plugin or the eo-runtime modules.
1 change: 1 addition & 0 deletions eo-maven-plugin/src/it/simple/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = clean compile
75 changes: 75 additions & 0 deletions eo-maven-plugin/src/it/simple/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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 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.66.0</version>
</parent>
<groupId>org.eolang</groupId>
<artifactId>examples</artifactId>
<version>@project.version@</version>
<packaging>jar</packaging>
<name>Simplest possible EO program</name>
<build>
<plugins>
<plugin>
<groupId>org.eolang</groupId>
<artifactId>eo-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>register</goal>
<goal>assemble</goal>
<goal>verify</goal>
<goal>transpile</goal>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256 you forgot verify here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxonfjvipon yes, this is true, but the problem is in the SnippetTestCase -- they fail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxonfjvipon also, the absence of verify here should not be the problem -- the code that is not verified still can be traspiled, right? The verify step is optional. If the user is sure that all XMIR files are valid, he may skip the verify step. Am I wrong?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256 transpile mojo expects xmir files in 4-verified directory, which is absent if verify step was skipped. Actually it's a bug because files are not changed after verification so there's no point to rewrite them one more time

</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.eolang.Main</mainClass>
<arguments>
<argument>org.eolang.examples.app</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 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.io.stdout

[args] > app
stdout > @
"Hello, world!\n"
27 changes: 27 additions & 0 deletions eo-maven-plugin/src/it/simple/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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 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.
*/

new File(basedir, 'build.log').text.contains('BUILD SUCCESS')

true
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@
*
* <p>This test will/may fail if you change something in {@code to-java.xsl}
* or some other place where Java sources are generated. This happens
* because this test relies on {@code eo-runtime.jar}, which it finds in your local
* Maven repository. This file is supposed to be generated by a previous run
* of Maven, but will not exist at the first run. Thus, when changes are made,
* it is recommended to disable this test. Then, when new {@code eo-runtime.jar} is
* because this test relies on {@code eo-runtime.jar}, which it finds in Maven
* Central. Thus, when changes are made, it is recommended to disable this test.
* Then, when new {@code eo-runtime.jar} is
* released to Maven Central, you enable this test again.</p>
*
* @since 0.1
*
* @todo #2660:30min Most of the snippets are disabled now, in
* the "src/test/resources/snippets/*.yaml" because they don't work.
* Hopefully, they will work once a new eo-runtime.jar is released.
* Just wait until it's released and try to enable the tests.
* @todo #2660:30min One snippet is disabled now, in
* the "src/test/resources/snippets/*.yaml" because it doesn't work.
* I don't understand what's wrong with it (parenting.yaml). Let's
* try to find out and enable it (by removing the "skip" attribute from
* the YAML file).
*/
@ExtendWith(OnlineCondition.class)
@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass")
Expand All @@ -84,6 +84,7 @@ final class SnippetTestCase {
void runsAllSnippets(final String yml) throws IOException {
final Yaml yaml = new Yaml();
final Map<String, Object> map = yaml.load(yml);
final String file = map.get("file").toString();
Assumptions.assumeFalse(map.containsKey("skip"));
new Farea(this.temp).together(
f -> {
Expand All @@ -98,14 +99,16 @@ void runsAllSnippets(final String yml) throws IOException {
.set("project.build.sourceEncoding", "UTF-8")
.set("project.reporting.outputEncoding", "UTF-8");
f.files()
.file("src/main/eo/main.eo")
.file(String.format("src/main/eo/%s", file))
.write(String.format("%s\n", map.get("eo")))
.show();
f.build()
.plugins()
.appendItself()
.phase("generate-sources")
.goals("register", "assemble", "verify", "transpile");
.goals("register", "assemble", "verify", "transpile")
.configuration()
.set("failOnWarnings", "true");
f.build()
.plugins()
.append("org.codehaus.mojo", "exec-maven-plugin", "3.1.1")
Expand All @@ -114,7 +117,7 @@ void runsAllSnippets(final String yml) throws IOException {
.configuration()
.set("mainClass", "org.eolang.Main")
.set("arguments", map.get("args"));
f.exec("test");
f.exec("clean", "test");
MatcherAssert.assertThat(
String.format("'%s' printed something wrong", yml),
f.log(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
skip: true
out:
- ".*works!.*"
args: ["foo.main"]
file: org/eolang/snippets/all.eo
args: ["org.eolang.snippets.all"]
eo: |
+package foo
+package org.eolang.snippets

[args] > main
[args] > all
seq > a
*
42
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
skip: true
file: org/eolang/snippets/fibo.eo
out:
- ".*true.*"
args: [ "main" ]
- ".*8 is the 6th number.*"
args: [ "org.eolang.snippets.fibo" ]
eo: |
[args] > main
+package org.eolang.snippets
+alias org.eolang.io.stdout

[args] > fibo
[n] > f
if. > @
n.lt 2
n
plus.
f (n.minus 1)
f (n.minus 2)
eq. > @
8
f 6
stdout > @
QQ.txt.sprintf
"%d is the %dth number\n"
8
f 6

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
skip: true
out:
- ".*greater.*"
args: [ "main" ]
file: org/eolang/snippets/ifthenelse.eo
args: [ "org.eolang.snippets.ifthenelse" ]
eo: |
+package org.eolang.snippets
+alias org.eolang.io.stdout

[args] > main
[args] > ifthenelse
[n] > f
if. > @
n.lt 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
file: org/eolang/snippets/parenting.eo
skip: true
out:
- ".*123.*"
args: [ "main", "123" ]
args: [ "org.eolang.snippets.parenting", "123" ]
eo: |
+package org.eolang.snippets
+alias org.eolang.io.stdout

[args] > main
[args] > parenting
"The code snippet that checks parent's args" > description
[] > take
^.args.at 0 > @
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
skip: true
out:
- ".*Hello, дорогой!.*"
args: ["simple.main"]
- ".*Hello, Jeff!.*"
file: org/eolang/snippets/simple.eo
args: ["org.eolang.snippets.simple"]
eo: |
+package simple
+package org.eolang.snippets
+alias org.eolang.io.stdout

[args] > main
[args] > simple
seq > @
*
stdout
"Hello, "
stdout
"дорогой"
"Jeff"
stdout
"!"
Loading