Skip to content

Commit

Permalink
#3468 extra test via Farea
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 7, 2024
1 parent a4e4ec2 commit 29ba50f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 3 deletions.
6 changes: 6 additions & 0 deletions eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ SOFTWARE.
<artifactId>xml-apis</artifactId>
<!-- version from parent POM -->
</dependency>
<dependency>
<groupId>com.yegor256</groupId>
<artifactId>farea</artifactId>
<!-- We need to have the "version" here explicitly, otherwise tests won't work: -->
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ public void exec() {
).intValue();
if (0 == total) {
if (this.scopedTojos().withSources().isEmpty()) {
Logger.info(this, "No new .eo sources need to be parsed to XMIRs");
Logger.info(
this,
"No .eo sources registered, nothing to be parsed to XMIRs (maybe you forgot to execute the \"register\" goal?)"
);
} else {
Logger.info(this, "No new .eo sources parsed to XMIRs");
}
Expand Down
30 changes: 30 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.eolang.maven;

import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
import com.yegor256.farea.RequisiteMatcher;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -56,6 +58,34 @@
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
final class ParseMojoTest {

@Test
void parsesSimpleFile(@TempDir final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/foo.eo").write(
"# Simple object.\n[] > foo\n".getBytes()
);
f.build()
.plugins()
.appendItself()
.execution()
.goals("register", "parse");
f.exec("compile", String.format("-Deo.cache=%s", temp.resolve("cache")));
MatcherAssert.assertThat(
"build has no problems",
f.log(),
RequisiteMatcher.SUCCESS
);
MatcherAssert.assertThat(
"the XMIR file is generated",
f.files().file("target/eo/1-parse/foo.xmir").exists(),
Matchers.is(true)
);
}
);
}

@Test
void parsesSuccessfully(@TempDir final Path temp) throws Exception {
final FakeMaven maven = new FakeMaven(temp);
Expand Down
32 changes: 32 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/PhiMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
package org.eolang.maven;

import com.yegor256.farea.Farea;
import com.yegor256.farea.RequisiteMatcher;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -43,13 +45,43 @@
* Test cases for {@link PhiMojo}.
* @since 0.34.0
*/
@SuppressWarnings("PMD.TooManyMethods")
final class PhiMojoTest {
/**
* Comment.
*/
private static final String COMMENT =
"# This is the default 64+ symbols comment in front of named abstract object.";

@Test
void convertsSimpleObjectToPhi(@TempDir final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/foo.eo").write(
String.format("%s\n[] > foo\n", PhiMojoTest.COMMENT).getBytes()
);
f.build()
.plugins()
.appendItself()
.execution()
.goals("register", "parse", "optimize", "xmir-to-phi");
f.exec("compile");
MatcherAssert.assertThat(
"build has no problems",
f.log(),
RequisiteMatcher.SUCCESS
);
MatcherAssert.assertThat(
"the .phi file is generated",
f.files().file("target/eo/phi/foo.phi").exists(),
Matchers.is(true)
);
f.files().show();
}
);
}

@Test
void createsFiles(@TempDir final Path temp) throws Exception {
MatcherAssert.assertThat(
Expand Down
3 changes: 1 addition & 2 deletions eo-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ SOFTWARE.
<dependency>
<groupId>com.yegor256</groupId>
<artifactId>farea</artifactId>
<version>0.6.0</version>
<scope>test</scope>
<!-- version from parent POM -->
</dependency>
<dependency>
<groupId>org.eolang</groupId>
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ SOFTWARE.
<scope>test</scope>
<version>0.0.5</version>
</dependency>
<dependency>
<groupId>com.yegor256</groupId>
<artifactId>farea</artifactId>
<version>0.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
Expand Down

0 comments on commit 29ba50f

Please sign in to comment.