forked from objectionary/eo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
objectionary#3941 move LintMojo tests that use
Farea
to integration…
… tests
- Loading branch information
Showing
3 changed files
with
104 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
eo-maven-plugin/src/test/java/org/eolang/maven/LintMojoIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* 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 { | ||
|
||
/** | ||
* The path to the EO file. | ||
*/ | ||
private static final String EO = "src/main/eo/foo.eo"; | ||
|
||
@Test | ||
void lintsAgainAfterModification(@Mktmp final Path temp, @RandomProgram final String program) | ||
throws Exception { | ||
final String xmir = String.format("target/eo/%s/foo.xmir", LintMojo.DIR); | ||
new Farea(temp).together( | ||
f -> { | ||
f.clean(); | ||
f.files().file(LintMojoIT.EO).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(LintMojoIT.EO).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(LintMojoIT.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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters