Skip to content

Commit

Permalink
objectionary#3941 shake, sodg 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 a1b6ba4 commit 29907c9
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# package name contains capital letter and such names are conventional.
---
exclude_paths:
- "eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/PrintMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoIT.java"
62 changes: 62 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
* SPDX-License-Identifier: MIT
*/
package org.eolang.maven;

import com.jcabi.manifests.Manifests;
import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XMLDocument;
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.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

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

@Test
void shakesSimpleObject(@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", "shake");
f.exec("compile");
}
);
MatcherAssert.assertThat(
"the .xmir file contains lint defects",
new XMLDocument(temp.resolve(String.format("target/eo/%s/foo.xmir", ShakeMojo.DIR))),
XhtmlMatchers.hasXPaths("/program[not(errors)]")
);
}
}
25 changes: 0 additions & 25 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
*/
package org.eolang.maven;

import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XMLDocument;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -46,29 +44,6 @@
@ExtendWith(MktmpResolver.class)
final class ShakeMojoTest {

@Test
void shakesSimpleObject(@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", "shake");
f.exec("compile");
}
);
MatcherAssert.assertThat(
"the .xmir file contains lint defects",
new XMLDocument(temp.resolve("target/eo/2-shake/foo.xmir")),
XhtmlMatchers.hasXPaths("/program[not(errors)]")
);
}

@ParameterizedTest
@ClasspathSource(value = "org/eolang/maven/shake-packs/", glob = "**.yaml")
void checksShakePacks(final String yaml) {
Expand Down
66 changes: 66 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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 java.nio.file.Paths;
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 SodgMojo}.
*
* @since 0.52
*/
@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"})
@ExtendWith({WeAreOnline.class, MktmpResolver.class, MayBeSlow.class})
final class SodgMojoIT {
@Test
void convertsSimpleObjectToGraph(@Mktmp final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("XMIR.xsd").save(
Paths.get(System.getProperty("user.dir")).resolve(
"../eo-parser/src/main/resources/XMIR.xsd"
)
);
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", "shake", "sodg");
f.exec("compile");
MatcherAssert.assertThat(
"the .sodg file is generated",
f.files().file("target/eo/sodg/foo.sodg").exists(),
Matchers.is(true)
);
}
);
}
}
32 changes: 0 additions & 32 deletions eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
import com.jcabi.log.Logger;
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -30,7 +27,6 @@
import org.eolang.xax.XtoryMatcher;
import org.hamcrest.Description;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeMatcher;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
Expand All @@ -55,34 +51,6 @@
@ExtendWith(MktmpResolver.class)
final class SodgMojoTest {

@Test
void convertsSimpleObjectToGraph(@Mktmp final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("XMIR.xsd").save(
Paths.get(System.getProperty("user.dir")).resolve(
"../eo-parser/src/main/resources/XMIR.xsd"
)
);
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", "shake", "sodg");
f.exec("compile");
MatcherAssert.assertThat(
"the .sodg file is generated",
f.files().file("target/eo/sodg/foo.sodg").exists(),
Matchers.is(true)
);
}
);
}

@Test
@Disabled
void convertsToGraph() throws Exception {
Expand Down

0 comments on commit 29907c9

Please sign in to comment.