Skip to content

Commit

Permalink
#3941 parse, print tests that use Farea to integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Suban05 committed Feb 25, 2025
1 parent b7e9601 commit a1b6ba4
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
# package name contains capital letter and such names are conventional.
---
exclude_paths:
- "eo-maven-plugin/src/test/java/org/eolang/maven/LintMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoIT.java"
58 changes: 58 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
* SPDX-License-Identifier: MIT
*/
package org.eolang.maven;

import com.jcabi.manifests.Manifests;
import com.yegor256.MayBeSlow;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
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 {@link ParseMojo}.
*
* @since 0.52
*/
@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"})
@ExtendWith({WeAreOnline.class, MktmpResolver.class, MayBeSlow.class})
final class ParseMojoIT {
@Test
void parsesSimpleFile(@Mktmp 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()
.append(
"org.eolang",
"eo-maven-plugin",
System.getProperty(
"eo.version",
Manifests.read("EO-Version")
)
)
.execution()
.goals("register", "parse");
f.exec("compile", String.format("-Deo.cache=%s", temp.resolve("cache")));
MatcherAssert.assertThat(
"the XMIR file is generated",
f.files().file(
String.format("target/eo/%s/foo.xmir", ParseMojo.DIR)
).exists(),
Matchers.is(true)
);
}
);
}
}
24 changes: 0 additions & 24 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -36,29 +35,6 @@
@ExtendWith(MktmpResolver.class)
final class ParseMojoTest {

@Test
void parsesSimpleFile(@Mktmp 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(
"the XMIR file is generated",
f.files().file("target/eo/1-parse/foo.xmir").exists(),
Matchers.is(true)
);
}
);
}

@Test
void parsesSuccessfully(@Mktmp final Path temp) throws Exception {
final FakeMaven maven = new FakeMaven(temp);
Expand Down
69 changes: 69 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
* SPDX-License-Identifier: MIT
*/
package org.eolang.maven;

import com.jcabi.manifests.Manifests;
import com.yegor256.MayBeSlow;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
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 {@link PrintMojo}.
*
* @since 0.52
*/
@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"})
@ExtendWith({WeAreOnline.class, MktmpResolver.class, MayBeSlow.class})
final class PrintMojoIT {
@Test
void printsSimpleObject(@Mktmp final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/foo.eo").write(
String.join(
" ",
"# This unit test is supposed to check",
"the functionality of the corresponding object.\n[] > foo\n"
).getBytes()
);
f.build()
.plugins()
.append(
"org.eolang",
"eo-maven-plugin",
System.getProperty(
"eo.version",
Manifests.read("EO-Version")
)
)
.execution()
.goals("register", "parse");
f.exec("compile");
f.files()
.file("src/main/xmir/foo.xmir")
.save(
f.files()
.file(
String.format("target/eo/%s/foo.xmir", ParseMojo.DIR)
).path()
);
f.exec("eo:print");
MatcherAssert.assertThat(
"the .phi file is generated",
f.files().file("target/generated-sources/eo/foo.eo").exists(),
Matchers.is(true)
);
}
);
}
}
27 changes: 0 additions & 27 deletions eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.farea.Farea;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -34,32 +33,6 @@
*/
@ExtendWith(MktmpResolver.class)
final class PrintMojoTest {
@Test
void printsSimpleObject(@Mktmp final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/foo.eo").write(
"# This unit test is supposed to check the functionality of the corresponding object.\n[] > foo\n".getBytes()
);
f.build()
.plugins()
.appendItself()
.execution()
.goals("register", "parse");
f.exec("compile");
f.files()
.file("src/main/xmir/foo.xmir")
.save(f.files().file("target/eo/1-parse/foo.xmir").path());
f.exec("eo:print");
MatcherAssert.assertThat(
"the .phi file is generated",
f.files().file("target/generated-sources/eo/foo.eo").exists(),
Matchers.is(true)
);
}
);
}

@Test
void printsSuccessfully(@Mktmp final Path temp) throws Exception {
Expand Down

0 comments on commit a1b6ba4

Please sign in to comment.