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

#3941 move LintMojo tests that use Farea to integration tests #3945

Merged
merged 5 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
# package name contains capital letter and such names are conventional.
---
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"
- "eo-maven-plugin/src/test/java/org/eolang/maven/LintMojoIT.java"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
package org.eolang.maven;

import com.jcabi.manifests.Manifests;
import com.jcabi.manifests.Manifests;
import com.yegor256.MayBeSlow;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
Expand Down
99 changes: 99 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/LintMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* 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.Execution;
import com.yegor256.farea.Farea;
import java.io.IOException;
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 LintMojo}.
*
* @since 0.52
*/
@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"})
@ExtendWith({WeAreOnline.class, MktmpResolver.class, MayBeSlow.class, RandomProgramResolver.class})
final class LintMojoIT {

@Test
void lintsAgainAfterModification(@Mktmp final Path temp, @RandomProgram final String program)
throws Exception {
final String source = "src/main/eo/foo.eo";
final String xmir = String.format("target/eo/%s/foo.xmir", LintMojo.DIR);
new Farea(temp).together(
f -> {
f.clean();
f.files().file(source).write(program.getBytes());
LintMojoIT.appendItself(f)
.configuration()
.set("failOnWarning", "false");
f.exec("process-classes");
final long before = f.files()
.file(xmir)
.path()
.toFile()
.lastModified();
f.files().file(source).write(program.getBytes());
f.exec("process-classes");
MatcherAssert.assertThat(
"the .xmir file is re-generated",
f.files().file(xmir).path().toFile().lastModified(),
Matchers.not(Matchers.equalTo(before))
);
}
);
}

@Test
void printsLintsUrlWithVersion(@Mktmp final Path temp, @RandomProgram final String program)
throws IOException {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/foo.eo").write(program.getBytes());
LintMojoIT.appendItself(f)
.configuration()
.set("failOnWarning", "false");
f.exec("process-classes");
MatcherAssert.assertThat(
"Lints URL was not printed, but it should",
f.log().content(),
Matchers.matchesPattern(
String.join(
" ",
"(?s).*\\[INFO] Read more about lints:",
"https://www\\.objectionary\\.com/lints/\\d+\\.\\d+\\.\\d+.*"
)
)
);
}
);
}

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", "parse", "shake", "lint");
}
}
59 changes: 0 additions & 59 deletions eo-maven-plugin/src/test/java/org/eolang/maven/LintMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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 All @@ -31,64 +30,6 @@
@ExtendWith(MktmpResolver.class)
@ExtendWith(RandomProgramResolver.class)
final class LintMojoTest {

@Test
void lintsAgainAfterModification(@Mktmp final Path temp, @RandomProgram final String program)
throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/foo.eo").write(program.getBytes());
f.build()
.plugins()
.appendItself()
.execution()
.goals("register", "parse", "shake", "lint")
.configuration()
.set("failOnWarning", "false");
f.exec("process-classes");
final long before = f.files().file(
"target/eo/6-lint/foo.xmir"
).path().toFile().lastModified();
f.files().file("src/main/eo/foo.eo").write(program.getBytes());
f.exec("process-classes");
MatcherAssert.assertThat(
"the .xmir file is re-generated",
f.files().file(
"target/eo/6-lint/foo.xmir"
).path().toFile().lastModified(),
Matchers.not(Matchers.equalTo(before))
);
}
);
}

@Test
void printsLintsUrlWithVersion(@Mktmp final Path temp, @RandomProgram final String program)
throws IOException {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("src/main/eo/foo.eo").write(program.getBytes());
f.build()
.plugins()
.appendItself()
.execution()
.goals("register", "parse", "shake", "lint")
.configuration()
.set("failOnWarning", "false");
f.exec("process-classes");
MatcherAssert.assertThat(
"Lints URL was not printed, but it should",
f.log().content(),
Matchers.matchesPattern(
"(?s).*\\[INFO] Read more about lints: https://www\\.objectionary\\.com/lints/\\d+\\.\\d+\\.\\d+.*"
)
);
}
);
}

@Test
void doesNotFailWithNoErrorsAndWarnings(@Mktmp final Path temp) {
Assertions.assertDoesNotThrow(
Expand Down
Loading