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

#2424 move the AssembleMojo tests to the integration tests #3911

Merged
merged 28 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2488250
#2424 move assemble mojo tests to integration tests
Suban05 Feb 10, 2025
64bc41e
#2424 simple test that checks the execution of all mojos
Suban05 Feb 10, 2025
bf5d6b6
#2424 check the restart execution
Suban05 Feb 10, 2025
e3f07f6
#2424 reorder
Suban05 Feb 11, 2025
e6fdc03
#2424 test that checks the execution
Suban05 Feb 11, 2025
8abd60c
#2424 suppress warnings
Suban05 Feb 11, 2025
06bf455
#2424 remove todo
Suban05 Feb 11, 2025
c7404dc
Merge branch 'objectionary:master' into 2424
Suban05 Feb 11, 2025
432aad6
#2424 revert since
Suban05 Feb 11, 2025
7acdea0
#2424 fix trailing space
Suban05 Feb 11, 2025
09cb418
#2424 move files correctly
Suban05 Feb 11, 2025
60027b1
#2424 exclusion for codacy
Suban05 Feb 11, 2025
4dc6353
#2424 revert fake maven
Suban05 Feb 14, 2025
a389c79
#2424 rewrite tests with `Farea`
Suban05 Feb 14, 2025
286ca08
#2424 fix since
Suban05 Feb 14, 2025
85de058
Merge branch 'master' into 2424
Suban05 Feb 14, 2025
52ab9f5
#2424 fix since
Suban05 Feb 14, 2025
e62aaba
#2424 check the unpucking of the runtime
Suban05 Feb 17, 2025
feecf41
#2424 rename and move to the eo-maven-package
Suban05 Feb 18, 2025
8da3dee
#2424 fix spaces
Suban05 Feb 18, 2025
7af43dd
#2424 make assertions inside `Farea` lambdas
Suban05 Feb 18, 2025
7dac6e4
Merge branch 'objectionary:master' into 2424
Suban05 Feb 18, 2025
05ea2ac
#2424 fix codacy
Suban05 Feb 18, 2025
2ed1f32
Update pom.xml
Suban05 Feb 18, 2025
3432f8c
Update pom.xml
Suban05 Feb 18, 2025
ce2fdeb
#2424 fixes
Suban05 Feb 18, 2025
96139c9
#2424 append eo-maven-plugin to the farea
Suban05 Feb 20, 2025
c5c9698
#2424 skip tests
Suban05 Feb 20, 2025
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
1 change: 1 addition & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
exclude_paths:
- "src/test/groovy/*.groovy"
- "eo-runtime/src/test/java/integration/PhiUnphiIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/LintMojoTest.java"
18 changes: 18 additions & 0 deletions eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,24 @@ SOFTWARE.
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skipTests>${skipITs}</skipTests>
</configuration>
<version>3.5.2</version>
<executions>
<execution>
<id>assemble-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
201 changes: 201 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2025 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.maven;

import com.jcabi.manifests.Manifests;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Execution;
import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Integration tests for mojas.
*
* @since 0.52
*/
@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"})
@ExtendWith(WeAreOnline.class)
@ExtendWith(MktmpResolver.class)
final class AssembleMojoIT {

@Test
void assemblesTogether(@Mktmp final Path temp) throws IOException {
final String stdout = "target/eo/%s/org/eolang/io/stdout.%s";
final String parsed = String.format(stdout, ParseMojo.DIR, AssembleMojo.XMIR);
final String optimized = String.format(stdout, ShakeMojo.DIR, AssembleMojo.XMIR);
final String pulled = String.format(stdout, PullMojo.DIR, AssembleMojo.EO);
new Farea(temp).together(
f -> {
f.clean();
f.dependencies()
.append("org.eolang", "eo-runtime", "0.51.6");
f.files()
.file("src/main/eo/one/main.eo")
.write(AssembleMojoIT.helloWorld().getBytes(StandardCharsets.UTF_8));
AssembleMojoIT.appendItself(f);
f.exec("package");
MatcherAssert.assertThat(
String.join(
" ",
"AssembleMojo should have placed runtime",
"library, but didn't"
),
f.files().file(
String.format(
"target/eo/%s/org.eolang/eo-runtime/-/0.51.6/org/eolang/Phi.class",
ResolveMojo.DIR
)
).exists(),
Matchers.is(true)
);
MatcherAssert.assertThat(
String.format(
"AssembleMojo should have parsed stdout object %s, but didn't",
parsed
),
f.files().file(parsed).exists(),
Matchers.is(true)
);
MatcherAssert.assertThat(
String.format(
"AssembleMojo should have optimized stdout object %s, but didn't",
optimized
),
f.files().file(optimized).exists(),
Matchers.is(true)
);
MatcherAssert.assertThat(
String.format(
"AssembleMojo should have pulled stdout object %s, but didn't",
pulled
),
f.files().file(pulled).exists(),
Matchers.is(true)
);
}
);
}

@Test
void assemblesNotFailWithFailOnError(@Mktmp final Path temp) throws IOException {
final String prog = String.join(
"\n",
"+alias stdout org.eolang.io.stdout",
"+home https://github.com/objectionary/eo",
"+package test",
"+version 0.0.0",
"",
"[x] < wrong>",
" (stdout \"Hello!\" x).print"
);
new Farea(temp).together(
f -> {
f.clean();
f.files()
.file("src/main/eo/one/main.eo")
.write(prog.getBytes(StandardCharsets.UTF_8));
AssembleMojoIT.appendItself(f);
f.exec("test");
MatcherAssert.assertThat(
"Even if the eo program invalid we still have to parse it, but we didn't",
temp.resolve(String.format("target/eo/%s", ParseMojo.DIR)).toAbsolutePath(),
new ContainsFiles(String.format("**/main.%s", AssembleMojo.XMIR))
);
MatcherAssert.assertThat(
"Even if the eo program invalid we still have to optimize it, but we didn't",
temp.resolve(String.format("target/eo/%s", ShakeMojo.DIR)).toAbsolutePath(),
new ContainsFiles(String.format("**/main.%s", AssembleMojo.XMIR))
);
}
);
}

@Test
void configuresChildParameters(@Mktmp final Path temp) throws IOException {
new Farea(temp).together(
f -> {
f.clean();
f.files()
.file("src/main/eo/one/main.eo")
.write(AssembleMojoIT.helloWorld().getBytes(StandardCharsets.UTF_8));
AssembleMojoIT.appendItself(f)
.configuration()
.set("trackTransformationSteps", Boolean.TRUE.toString());
f.exec("test");
MatcherAssert.assertThat(
String.join(
"\n",
"AssembleMojo should have configured parameters",
"within the Mojos that it uses, but it didn't"
),
f.files().file(
String.format(
"target/eo/%s/one/main.%s",
ShakeMojo.DIR,
AssembleMojo.XMIR
)
).exists(),
Matchers.is(true)
);
}
);
}

private static String helloWorld() {
return String.join(
"\n",
"+alias stdout org.eolang.io.stdout",
"+home https://www.eolang.org",
"+package foo.x",
"+version 0.0.0",
"",
"# No comments.",
"[x] > main",
" (stdout \"Hello!\" x).print > @"
);
}

private static Execution appendItself(final Farea farea) throws IOException {
return farea.build()
.plugins()
.append(
"org.eolang",
"eo-maven-plugin",
System.getProperty(
"eo.version",
Manifests.read("EO-Version")
)
)
.execution("tests")
.goals("register", "assemble");
}
}
136 changes: 0 additions & 136 deletions eo-maven-plugin/src/test/java/org/eolang/maven/AssembleMojoTest.java

This file was deleted.

Loading