From db350ed5fcabfae77bdcea3d88b1184e36abc0b9 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Mon, 4 Dec 2023 16:39:01 +0300 Subject: [PATCH 01/12] #2443: VerifyMojo --- .../java/org/eolang/maven/AssembleMojo.java | 1 + .../org/eolang/maven/BinarizeParseMojo.java | 2 +- .../java/org/eolang/maven/DiscoverMojo.java | 2 +- .../java/org/eolang/maven/OptimizeMojo.java | 39 +------- .../java/org/eolang/maven/VerifyMojo.java | 84 ++++++++++++++--- .../org/eolang/maven/tojos/ForeignTojo.java | 39 ++++++++ .../org/eolang/maven/tojos/ForeignTojos.java | 5 ++ .../test/java/org/eolang/maven/FakeMaven.java | 8 ++ .../org/eolang/maven/OptimizeMojoTest.java | 79 ---------------- .../java/org/eolang/maven/VerifyMojoTest.java | 89 +++++++++++++++++-- 10 files changed, 212 insertions(+), 136 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java index 9120e938e4..6614a774da 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java @@ -204,6 +204,7 @@ public void exec() throws IOException { new Moja<>(ParseMojo.class), new Moja<>(OptimizeMojo.class), new Moja<>(ShakeMojo.class), + new Moja<>(VerifyMojo.class), new Moja<>(DiscoverMojo.class), new Moja<>(ProbeMojo.class), new Moja<>(PullMojo.class), diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeParseMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeParseMojo.java index 26f360a4ad..3a6918bf1c 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeParseMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/BinarizeParseMojo.java @@ -114,7 +114,7 @@ public final class BinarizeParseMojo extends SafeMojo { public void exec() throws IOException { new File(this.targetDir.toPath().resolve("Lib/").toString()).mkdirs(); for (final ForeignTojo tojo : this.scopedTojos().withOptimized()) { - final Path file = tojo.shaken(); + final Path file = tojo.verified(); this.getFFIs(new XMLDocument(file)) .forEach(FFINode::generateUnchecked); } diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java index e6d824ac09..8aa6c26ced 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java @@ -61,7 +61,7 @@ public void exec() throws FileNotFoundException { final Collection tojos = this.scopedTojos().notDiscovered(); final Collection discovered = new HashSet<>(); for (final ForeignTojo tojo : tojos) { - final Path src = tojo.shaken(); + final Path src = tojo.verified(); final Collection names = this.discover(src, tojo.identifier()); discovered.addAll(names); for (final String name : names) { diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java index 6f8792ee1a..79a8fccb89 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java @@ -24,7 +24,6 @@ package org.eolang.maven; import com.jcabi.log.Logger; -import com.yegor256.xsline.TrDefault; import java.io.IOException; import java.nio.file.Path; import java.util.Collection; @@ -87,31 +86,6 @@ public final class OptimizeMojo extends SafeMojo { @Parameter(property = "eo.trackOptimizationSteps", required = true, defaultValue = "false") private boolean trackOptimizationSteps; - /** - * Whether we should fail on error. - * - * @checkstyle MemberNameCheck (7 lines) - * @since 0.23.0 - */ - @SuppressWarnings("PMD.ImmutableField") - @Parameter( - property = "eo.failOnError", - defaultValue = "true") - private boolean failOnError = true; - - /** - * Whether we should fail on warn. - * - * @checkstyle MemberNameCheck (10 lines) - */ - @SuppressWarnings("PMD.ImmutableField") - @Parameter( - property = "eo.failOnWarning", - required = true, - defaultValue = "false" - ) - private boolean failOnWarning; - @Override public void exec() throws IOException { final Collection tojos = this.scopedTojos().withXmir(); @@ -148,7 +122,7 @@ public void exec() throws IOException { * @return Optimization for all tojos. */ private Optimization optimization() { - Optimization opt; + final Optimization opt; if (this.trackOptimizationSteps) { opt = new OptSpy( new ParsingTrain(), @@ -157,17 +131,6 @@ private Optimization optimization() { } else { opt = new OptTrain(new ParsingTrain()); } - if (this.failOnError) { - opt = new OptTrain(opt, "/org/eolang/parser/fail-on-errors.xsl"); - } - if (this.failOnWarning) { - opt = new OptTrain(opt, "/org/eolang/parser/fail-on-warnings.xsl"); - } - if (this.failOnError) { - opt = new OptTrain(opt, "/org/eolang/parser/fail-on-critical.xsl"); - } else { - opt = new OptTrain(opt, new TrDefault<>()); - } return opt; } } diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java index e583b207b0..ca9b5c97fe 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java @@ -23,21 +23,25 @@ */ package org.eolang.maven; +import com.jcabi.log.Logger; +import com.yegor256.xsline.TrDefault; import java.io.IOException; +import java.nio.file.Path; +import java.util.Collection; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.cactoos.iterable.Filtered; +import org.cactoos.map.MapEntry; +import org.cactoos.map.MapOf; +import org.eolang.maven.optimization.OptTrain; +import org.eolang.maven.optimization.Optimization; +import org.eolang.maven.tojos.ForeignTojo; /** * Mojo that checks errors and warnings after "assemble" phase. * * @since 0.31.0 - * @todo #1708:30min Implement VerifyMojo. VerifyMojo should check all errors - * and critical errors in xmir after {@link AssembleMojo} is finished. Also if - * {@code failOnWarning} flag is set to true - mojo should check warnings. When - * mojo is implemented - need to remove "failOnError" flag from - * {@link OptimizeMojo} and put "verify" step right after "assemble" in all - * pom.xml files */ @Mojo( name = "verify", @@ -45,6 +49,19 @@ threadSafe = true ) public final class VerifyMojo extends SafeMojo { + + /** + * Whether we should fail on error. + * + * @checkstyle MemberNameCheck (7 lines) + * @since 0.23.0 + */ + @SuppressWarnings("PMD.ImmutableField") + @Parameter( + property = "eo.failOnError", + defaultValue = "true") + private boolean failOnError = true; + /** * Whether we should fail on warning. * @@ -60,11 +77,56 @@ public final class VerifyMojo extends SafeMojo { @Override void exec() throws IOException { - throw new UnsupportedOperationException( - String.format( - "The VerifyMojo is not implemented yet, failOnWarning is %s", - this.failOnWarning + final Collection tojos = this.scopedTojos().withXmir(); + final int total = new OptimizedTojos( + new Filtered<>( + ForeignTojo::notVerified, + tojos + ), + this.optimization(), + new OptimizationTask( + new MapOf( + new MapEntry<>(OptimizationFolder.TARGET.key(), this.targetDir.toPath()), + new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache) + ), + new MapOf( + new MapEntry<>(OptimizationFolder.TARGET.key(), "3-verify"), + new MapEntry<>(OptimizationFolder.CACHE.key(), "verified") + ), + ForeignTojo::withVerified, + ForeignTojo::optimized ) - ); + ).count(); + if (total > 0) { + Logger.info( + this, + "Verified %d out of %d XMIR program(s)", total, + tojos.size() + ); + } else { + Logger.debug(this, "No XMIR programs out of %d verify", tojos.size()); + } } + + /** + * Verifying optimizations for tojos. + * + * @return Verifying optimizations + */ + private Optimization optimization() { + Optimization opt = new OptTrain(new TrDefault<>()); + if (this.failOnError) { + opt = new OptTrain(opt, "/org/eolang/parser/fail-on-errors.xsl"); + } + if (this.failOnWarning) { + opt = new OptTrain(opt, "/org/eolang/parser/fail-on-warnings.xsl"); + } + if (this.failOnError) { + opt = new OptTrain(opt, "/org/eolang/parser/fail-on-critical.xsl"); + } else { + opt = new OptTrain(opt, new TrDefault<>()); + } + return opt; + } + } diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojo.java index b84ed6bfc4..6f47fc85e0 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojo.java @@ -77,6 +77,14 @@ public Path optimized() { return Paths.get(this.delegate.get(ForeignTojos.Attribute.OPTIMIZED.key())); } + /** + * The tojo verified xmir. + * @return The verified xmir. + */ + public Path verified() { + return Paths.get(this.delegate.get(ForeignTojos.Attribute.VERIFIED.key())); + } + /** * The tojo shaken xmir. * @return The shaken xmir. @@ -170,6 +178,27 @@ public boolean notShaken() { return res; } + /** + * Checks if tojo was not already verified. + * + * @return True if optimization is required, false otherwise. + */ + public boolean notVerified() { + final Path src = this.xmir(); + boolean res = true; + if (this.delegate.exists(ForeignTojos.Attribute.VERIFIED.key())) { + final Path tgt = this.verified(); + if (tgt.toFile().lastModified() >= src.toFile().lastModified()) { + Logger.debug( + this, "Already verified %s to %s", + new Rel(src), new Rel(tgt) + ); + res = false; + } + } + return res; + } + /** * Check if the given tojo has not been parsed. * @@ -261,6 +290,16 @@ public ForeignTojo withShaken(final Path xmir) { return this; } + /** + * Set the verified xmir. + * @param xmir The verified xmir. + * @return The tojo itself. + */ + public ForeignTojo withVerified(final Path xmir) { + this.delegate.set(ForeignTojos.Attribute.VERIFIED.key(), xmir.toString()); + return this; + } + /** * Set the eo path. * @param source The eo path. diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojos.java b/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojos.java index 5353913432..77685d9a81 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojos.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/tojos/ForeignTojos.java @@ -318,6 +318,11 @@ enum Attribute { */ SHAKEN("shaken"), + /** + * Path to the verified xmir file. + */ + VERIFIED("verified"), + /** * Absolute location of SODG file. */ diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java index 6a4ccf8350..aeb9bdb09e 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java @@ -665,6 +665,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, BinarizeMojo.class ).iterator(); } @@ -683,6 +684,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, BinarizeParseMojo.class ).iterator(); } @@ -701,6 +703,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, ResolveMojo.class ).iterator(); } @@ -735,6 +738,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, ResolveMojo.class, PlaceMojo.class ).iterator(); @@ -754,6 +758,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, SodgMojo.class ).iterator(); } @@ -785,6 +790,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, DiscoverMojo.class, ProbeMojo.class ).iterator(); @@ -804,6 +810,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, DiscoverMojo.class, ProbeMojo.class, PullMojo.class @@ -824,6 +831,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, DiscoverMojo.class ).iterator(); } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java index a8c82f5c6c..aaa4cca579 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java @@ -24,13 +24,7 @@ package org.eolang.maven; import com.jcabi.matchers.XhtmlMatchers; -import com.jcabi.xml.XML; import com.jcabi.xml.XMLDocument; -import com.jcabi.xml.XSLDocument; -import com.yegor256.xsline.Shift; -import com.yegor256.xsline.StXSL; -import com.yegor256.xsline.TrDefault; -import com.yegor256.xsline.Xsline; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; @@ -246,21 +240,6 @@ void failsOnErrorFlag(@TempDir final Path temp) throws IOException { ); } - @Test - void failsOptimization(@TempDir final Path temp) { - Assertions.assertThrows( - IllegalStateException.class, - () -> new FakeMaven(temp) - .withProgram( - "+package f", - "+alias THIS-IS-WRONG org.eolang.io.stdout\n", - "[args] > main", - " (stdout \"Hello!\").print > @" - ) - .execute(new FakeMaven.Optimize()) - ); - } - @Test void stopsOnCritical(@TempDir final Path temp) throws IOException { MatcherAssert.assertThat( @@ -292,47 +271,6 @@ void stopsOnCritical(@TempDir final Path temp) throws IOException { ); } - @Test - void failsOnCritical(@TempDir final Path temp) { - Assertions.assertThrows( - IllegalStateException.class, - () -> new FakeMaven(temp) - .withProgram( - "+package f\n", - "[args] > main", - " seq > @", - " TRUE > x", - " FALSE > x" - ) - .execute(new FakeMaven.Optimize()) - ); - } - - @Test - void failsOnWarning(@TempDir final Path temp) throws Exception { - final FakeMaven maven = new FakeMaven(temp) - .withProgram( - "+architect yegor256@gmail.com", - "+tests", - "+package org.eolang.examples\n", - "[] > main", - " [] > @", - " hello > test" - ); - this.applyXsl( - "org/eolang/maven/set-warning-severity.xsl", - maven.execute(ParseMojo.class) - .result() - .get("target/1-parse/foo/x/main.xmir") - ); - Assertions.assertThrows( - IllegalStateException.class, - () -> maven.with("failOnError", false) - .with("failOnWarning", true) - .execute(OptimizeMojo.class) - ); - } - @Test void choosesTransformerFactoryOnce() { MatcherAssert.assertThat( @@ -352,21 +290,4 @@ void choosesTransformerFactoryInConcurrentEnvironment() { ); } } - - /** - * Apply XSL transformation. - * @param xsl Path to XSL within classpath - * @param xml Path to XML to be tranformed - */ - private void applyXsl(final String xsl, final Path xml) throws Exception { - final XML output = new Xsline( - new TrDefault() - .with( - new StXSL( - new XSLDocument( - new ResourceOf(xsl).stream() - ))) - ).pass(new XMLDocument(xml)); - new HmBase(xml.getParent()).save(output.toString(), xml.getParent().relativize(xml)); - } } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java index b9759ac2e2..505d1c2f84 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java @@ -23,9 +23,17 @@ */ package org.eolang.maven; +import com.jcabi.xml.XML; +import com.jcabi.xml.XMLDocument; +import com.jcabi.xml.XSLDocument; +import com.yegor256.xsline.Shift; +import com.yegor256.xsline.StXSL; +import com.yegor256.xsline.TrDefault; +import com.yegor256.xsline.Xsline; import java.nio.file.Path; +import org.cactoos.io.ResourceOf; +import org.eolang.maven.util.HmBase; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -34,10 +42,10 @@ * * @since 0.31.0 */ +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class VerifyMojoTest { @Test - @Disabled void doesNotFailWithNoErrorsAndWarnings(@TempDir final Path temp) { Assertions.assertDoesNotThrow( () -> new FakeMaven(temp) @@ -48,7 +56,6 @@ void doesNotFailWithNoErrorsAndWarnings(@TempDir final Path temp) { } @Test - @Disabled void detectsErrorsSuccessfully(@TempDir final Path temp) { Assertions.assertThrows( IllegalStateException.class, @@ -65,7 +72,6 @@ void detectsErrorsSuccessfully(@TempDir final Path temp) { } @Test - @Disabled void detectsWarningWithCorrespondingFlag(@TempDir final Path temp) { Assertions.assertThrows( IllegalStateException.class, @@ -83,7 +89,6 @@ void detectsWarningWithCorrespondingFlag(@TempDir final Path temp) { } @Test - @Disabled void doesNotDetectWarningWithoutCorrespondingFlag(@TempDir final Path temp) { Assertions.assertDoesNotThrow( () -> new FakeMaven(temp) @@ -100,7 +105,6 @@ void doesNotDetectWarningWithoutCorrespondingFlag(@TempDir final Path temp) { } @Test - @Disabled void detectsCriticalError(@TempDir final Path temp) { Assertions.assertThrows( IllegalStateException.class, @@ -115,4 +119,77 @@ void detectsCriticalError(@TempDir final Path temp) { "Program with duplicate names should have failed on critical error, but it didn't" ); } + + @Test + void failsOptimization(@TempDir final Path temp) { + Assertions.assertThrows( + IllegalStateException.class, + () -> new FakeMaven(temp) + .withProgram( + "+package f", + "+alias THIS-IS-WRONG org.eolang.io.stdout\n", + "[args] > main", + " (stdout \"Hello!\").print > @" + ) + .execute(new FakeMaven.Verify()) + ); + } + + @Test + void failsOnWarning(@TempDir final Path temp) throws Exception { + final FakeMaven maven = new FakeMaven(temp) + .withProgram( + "+architect yegor256@gmail.com", + "+tests", + "+package org.eolang.examples\n", + "[] > main", + " [] > @", + " hello > test" + ); + this.applyXsl( + "org/eolang/maven/set-warning-severity.xsl", + maven.execute(ParseMojo.class) + .result() + .get("target/1-parse/foo/x/main.xmir") + ); + Assertions.assertThrows( + IllegalStateException.class, + () -> maven.with("failOnError", false) + .with("failOnWarning", true) + .execute(VerifyMojo.class) + ); + } + + @Test + void failsOnCritical(@TempDir final Path temp) { + Assertions.assertThrows( + IllegalStateException.class, + () -> new FakeMaven(temp) + .withProgram( + "+package f\n", + "[args] > main", + " seq > @", + " TRUE > x", + " FALSE > x" + ) + .execute(new FakeMaven.Verify()) + ); + } + + /** + * Apply XSL transformation. + * @param xsl Path to XSL within classpath + * @param xml Path to XML to be tranformed + */ + private void applyXsl(final String xsl, final Path xml) throws Exception { + final XML output = new Xsline( + new TrDefault() + .with( + new StXSL( + new XSLDocument( + new ResourceOf(xsl).stream() + ))) + ).pass(new XMLDocument(xml)); + new HmBase(xml.getParent()).save(output.toString(), xml.getParent().relativize(xml)); + } } From 4f61176aff91cda4586b0466e3e03ef18b57a8b5 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Mon, 4 Dec 2023 16:48:02 +0300 Subject: [PATCH 02/12] #2443: edited "since" tag --- eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java index ca9b5c97fe..a82515228e 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java @@ -54,7 +54,7 @@ public final class VerifyMojo extends SafeMojo { * Whether we should fail on error. * * @checkstyle MemberNameCheck (7 lines) - * @since 0.23.0 + * @since 0.34.0 */ @SuppressWarnings("PMD.ImmutableField") @Parameter( From d3beed359a23c54574231d4592dedfd3a4026a11 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Mon, 4 Dec 2023 17:03:10 +0300 Subject: [PATCH 03/12] #2443: renumerated --- .../src/main/java/org/eolang/maven/PullMojo.java | 2 +- .../src/main/java/org/eolang/maven/ResolveMojo.java | 2 +- .../src/main/java/org/eolang/maven/TranspileMojo.java | 4 ++-- .../src/main/java/org/eolang/maven/VerifyMojo.java | 2 +- .../test/java/org/eolang/maven/ResolveMojoTest.java | 10 ++++++++-- .../test/java/org/eolang/maven/TranspileMojoTest.java | 4 +++- .../src/test/groovy/check-folders-numbering.groovy | 9 +++++---- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java index b224c5714c..954bbf2373 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java @@ -58,7 +58,7 @@ public final class PullMojo extends SafeMojo { /** * The directory where to process to. */ - public static final String DIR = "4-pull"; + public static final String DIR = "5-pull"; /** * The Git tag to pull objects from, in objectionary. diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java index 013c337cd3..fc68ca709e 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java @@ -65,7 +65,7 @@ public final class ResolveMojo extends SafeMojo { /** * The directory where to resolve to. */ - public static final String DIR = "5-resolve"; + public static final String DIR = "6-resolve"; /** * Skip artifact with the version 0.0.0. diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java index 294055c910..36a570560d 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java @@ -71,7 +71,7 @@ public final class TranspileMojo extends SafeMojo { /** * The directory where to transpile to. */ - public static final String DIR = "7-transpile"; + public static final String DIR = "8-transpile"; /** * Extension for compiled sources in XMIR format (XML). @@ -107,7 +107,7 @@ public final class TranspileMojo extends SafeMojo { /** * The directory where to put pre-transpile files. */ - private static final String PRE = "6-pre"; + public static final String PRE = "7-pre"; /** * Target directory. diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java index a82515228e..5ebec604e4 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java @@ -90,7 +90,7 @@ void exec() throws IOException { new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache) ), new MapOf( - new MapEntry<>(OptimizationFolder.TARGET.key(), "3-verify"), + new MapEntry<>(OptimizationFolder.TARGET.key(), "4-verify"), new MapEntry<>(OptimizationFolder.CACHE.key(), "verified") ), ForeignTojo::withVerified, diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoTest.java index 75e6553f7e..17be1e564a 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoTest.java @@ -56,7 +56,10 @@ void resolvesWithSingleDependency(@TempDir final Path temp) throws IOException { "[] > foo /int" ) ).execute(new FakeMaven.Resolve()); - final Path path = temp.resolve("target/5-resolve/org.eolang/eo-runtime/-/0.7.0"); + final Path path = temp + .resolve("target") + .resolve(ResolveMojo.DIR) + .resolve("org.eolang/eo-runtime/-/0.7.0"); MatcherAssert.assertThat(path.toFile(), FileMatchers.anExistingDirectory()); MatcherAssert.assertThat( path.resolve("eo-runtime-0.7.0.jar").toFile(), @@ -74,7 +77,10 @@ void resolvesWithoutAnyDependencies(@TempDir final Path temp) throws IOException ); maven.foreignTojos().add("sum").withDiscovered(0); maven.execute(new FakeMaven.Resolve()); - final Path path = temp.resolve("target/5-resolve/org.eolang/eo-runtime/-/"); + final Path path = temp + .resolve("target") + .resolve(ResolveMojo.DIR) + .resolve("org.eolang/eo-runtime/-/"); MatcherAssert.assertThat(path.toFile(), FileMatchers.anExistingDirectory()); MatcherAssert.assertThat( path, diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/TranspileMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/TranspileMojoTest.java index c8d355d408..7fbffb961b 100755 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/TranspileMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/TranspileMojoTest.java @@ -106,7 +106,9 @@ void recompilesIfExpired(@TempDir final Path temp) throws IOException { .execute(new FakeMaven.Transpile()) .result(); final Path java = res.get(this.compiled); - final Path xmir = res.get("target/7-transpile/foo/x/main.xmir"); + final Path xmir = res.get( + String.format("target/%s/foo/x/main.xmir", TranspileMojo.DIR) + ); MatcherAssert.assertThat(java.toFile(), FileMatchers.anExistingFile()); MatcherAssert.assertThat(xmir.toFile(), FileMatchers.anExistingFile()); MatcherAssert.assertThat(java.toFile().setLastModified(0L), Matchers.is(true)); diff --git a/eo-runtime/src/test/groovy/check-folders-numbering.groovy b/eo-runtime/src/test/groovy/check-folders-numbering.groovy index 1fda93602f..1a07f3c214 100644 --- a/eo-runtime/src/test/groovy/check-folders-numbering.groovy +++ b/eo-runtime/src/test/groovy/check-folders-numbering.groovy @@ -36,10 +36,11 @@ List allowed = [ '1-parse', '2-optimize', '3-shake', - '4-pull', - '5-resolve', - '6-pre', - '7-transpile', + '4-verify', + '5-pull', + '6-resolve', + '7-pre', + '8-transpile', ] List allowedDirs = allowed.stream() .map { target.resolve(it).toFile() } From 974903bae2bb37dfa49464af935396cd3bb58484 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Mon, 4 Dec 2023 17:04:10 +0300 Subject: [PATCH 04/12] #2443: transferred it up --- .../java/org/eolang/maven/TranspileMojo.java | 10 +- .../src/test/eo/org/eolang/line-code-tests.eo | 109 ++++++++++++++++++ plus-1 | 29 +++++ plus-2 | 29 +++++ 4 files changed, 172 insertions(+), 5 deletions(-) create mode 100644 eo-runtime/src/test/eo/org/eolang/line-code-tests.eo create mode 100644 plus-1 create mode 100644 plus-2 diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java index 36a570560d..cc1d99729b 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java @@ -68,6 +68,11 @@ @SuppressWarnings("PMD.LongVariable") public final class TranspileMojo extends SafeMojo { + /** + * The directory where to put pre-transpile files. + */ + public static final String PRE = "7-pre"; + /** * The directory where to transpile to. */ @@ -104,11 +109,6 @@ public final class TranspileMojo extends SafeMojo { */ private static final Pattern JAVA_EXT = Pattern.compile(".java", Pattern.LITERAL); - /** - * The directory where to put pre-transpile files. - */ - public static final String PRE = "7-pre"; - /** * Target directory. * @checkstyle MemberNameCheck (7 lines) diff --git a/eo-runtime/src/test/eo/org/eolang/line-code-tests.eo b/eo-runtime/src/test/eo/org/eolang/line-code-tests.eo new file mode 100644 index 0000000000..cf1606b29a --- /dev/null +++ b/eo-runtime/src/test/eo/org/eolang/line-code-tests.eo @@ -0,0 +1,109 @@ +# The MIT License (MIT) +# +# 2016-2022 Objectionary.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + ++architect yegor256@gmail.com ++home https://github.com/objectionary/eo ++tests ++package org.eolang ++version 0.0.0 + +[] > line + memory > mem + 1.plus 0 + seq > @ + mem.write + mem.plus 1 + mem.write + mem.plus 2 + mem.write + mem.plus 3 + mem.write + mem.plus 4 + mem.write + mem.plus 5 + mem.write + mem.plus 6 + mem.write + mem.plus 7 + mem.write + mem.plus 8 + mem + +[] > line-rst + memory > mem + 1.plus 0 + nop > @ + """ + use eo::Portal; + use eo::eo_enum::EO; + use eo::eo_enum::EO::{EOInt}; + use byteorder::{BigEndian, ReadBytesExt}; + + pub fn foo(env: &mut Portal) -> Option { + let mut mem = 0 as i64; + mem=mem+2; + mem=mem+2; + mem=mem+2; + mem=mem+2; + mem=mem+2; + mem=mem+2; + mem=mem+2; + mem=mem+2; + return Some(EOInt(mem)); + } + """ + * + [] + +[] > line-4 + 1.plus > sum + 2.plus + 3.plus + 4.plus + 5.plus + 6.plus + 7.plus + 8.plus + 9.plus + 10.plus + 11.plus + 12 + eq. > @ + sum + 78 + +[] > test-with-mysim + mysum > res + 1.as-int + TRUE > @ + +[] > plus-plus-plus-forms-1 + TRUE > @ + 1.plus.plus.plus.plus > complex-plus + +[] > plus-plus-plus-forms-2 + TRUE > @ + plus. > complex-plus + plus. + plus. + plus. + 1 diff --git a/plus-1 b/plus-1 new file mode 100644 index 0000000000..0fcc6fd6e0 --- /dev/null +++ b/plus-1 @@ -0,0 +1,29 @@ + + + + + + 00 00 00 00 00 00 00 01 + + + + + diff --git a/plus-2 b/plus-2 new file mode 100644 index 0000000000..83e25ca1e2 --- /dev/null +++ b/plus-2 @@ -0,0 +1,29 @@ + + + + + + 00 00 00 00 00 00 00 01 + + + + + From b11d734a57bdd391c494f524098e3552dd2959e6 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Mon, 4 Dec 2023 17:05:53 +0300 Subject: [PATCH 05/12] #2443: violations --- .../src/test/eo/org/eolang/line-code-tests.eo | 109 ------------------ plus-1 | 29 ----- plus-2 | 29 ----- 3 files changed, 167 deletions(-) delete mode 100644 eo-runtime/src/test/eo/org/eolang/line-code-tests.eo delete mode 100644 plus-1 delete mode 100644 plus-2 diff --git a/eo-runtime/src/test/eo/org/eolang/line-code-tests.eo b/eo-runtime/src/test/eo/org/eolang/line-code-tests.eo deleted file mode 100644 index cf1606b29a..0000000000 --- a/eo-runtime/src/test/eo/org/eolang/line-code-tests.eo +++ /dev/null @@ -1,109 +0,0 @@ -# The MIT License (MIT) -# -# 2016-2022 Objectionary.com -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -+architect yegor256@gmail.com -+home https://github.com/objectionary/eo -+tests -+package org.eolang -+version 0.0.0 - -[] > line - memory > mem - 1.plus 0 - seq > @ - mem.write - mem.plus 1 - mem.write - mem.plus 2 - mem.write - mem.plus 3 - mem.write - mem.plus 4 - mem.write - mem.plus 5 - mem.write - mem.plus 6 - mem.write - mem.plus 7 - mem.write - mem.plus 8 - mem - -[] > line-rst - memory > mem - 1.plus 0 - nop > @ - """ - use eo::Portal; - use eo::eo_enum::EO; - use eo::eo_enum::EO::{EOInt}; - use byteorder::{BigEndian, ReadBytesExt}; - - pub fn foo(env: &mut Portal) -> Option { - let mut mem = 0 as i64; - mem=mem+2; - mem=mem+2; - mem=mem+2; - mem=mem+2; - mem=mem+2; - mem=mem+2; - mem=mem+2; - mem=mem+2; - return Some(EOInt(mem)); - } - """ - * - [] - -[] > line-4 - 1.plus > sum - 2.plus - 3.plus - 4.plus - 5.plus - 6.plus - 7.plus - 8.plus - 9.plus - 10.plus - 11.plus - 12 - eq. > @ - sum - 78 - -[] > test-with-mysim - mysum > res - 1.as-int - TRUE > @ - -[] > plus-plus-plus-forms-1 - TRUE > @ - 1.plus.plus.plus.plus > complex-plus - -[] > plus-plus-plus-forms-2 - TRUE > @ - plus. > complex-plus - plus. - plus. - plus. - 1 diff --git a/plus-1 b/plus-1 deleted file mode 100644 index 0fcc6fd6e0..0000000000 --- a/plus-1 +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 00 00 00 00 00 00 00 01 - - - - - diff --git a/plus-2 b/plus-2 deleted file mode 100644 index 83e25ca1e2..0000000000 --- a/plus-2 +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 00 00 00 00 00 00 00 01 - - - - - From 8fd6c60d04bfa389c1fe94e4b5afdd27498a0f64 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 5 Dec 2023 00:13:18 +0300 Subject: [PATCH 06/12] #2443: VerifyMojo after AssembleMojo --- eo-maven-plugin/src/it/custom_goals/verify.groovy | 4 ++-- .../src/main/java/org/eolang/maven/AssembleMojo.java | 1 - .../src/main/java/org/eolang/maven/DiscoverMojo.java | 2 +- .../src/main/java/org/eolang/maven/PullMojo.java | 2 +- .../src/main/java/org/eolang/maven/ResolveMojo.java | 2 +- .../src/main/java/org/eolang/maven/TranspileMojo.java | 2 +- .../src/main/java/org/eolang/maven/VerifyMojo.java | 4 ++-- .../src/test/java/org/eolang/maven/FakeMaven.java | 7 +------ eo-runtime/pom.xml | 2 ++ 9 files changed, 11 insertions(+), 15 deletions(-) diff --git a/eo-maven-plugin/src/it/custom_goals/verify.groovy b/eo-maven-plugin/src/it/custom_goals/verify.groovy index be1ba9c4f8..d01cb9703a 100644 --- a/eo-maven-plugin/src/it/custom_goals/verify.groovy +++ b/eo-maven-plugin/src/it/custom_goals/verify.groovy @@ -37,8 +37,8 @@ */ [ 'target/eo/5-resolve', - 'target/eo/6-pre', - 'target/eo/7-transpile', + 'target/eo/7-pre', + 'target/eo/8-transpile', ].each { assert !new File(basedir, it).exists() } true diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java index 6614a774da..9120e938e4 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java @@ -204,7 +204,6 @@ public void exec() throws IOException { new Moja<>(ParseMojo.class), new Moja<>(OptimizeMojo.class), new Moja<>(ShakeMojo.class), - new Moja<>(VerifyMojo.class), new Moja<>(DiscoverMojo.class), new Moja<>(ProbeMojo.class), new Moja<>(PullMojo.class), diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java index 8aa6c26ced..e6d824ac09 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java @@ -61,7 +61,7 @@ public void exec() throws FileNotFoundException { final Collection tojos = this.scopedTojos().notDiscovered(); final Collection discovered = new HashSet<>(); for (final ForeignTojo tojo : tojos) { - final Path src = tojo.verified(); + final Path src = tojo.shaken(); final Collection names = this.discover(src, tojo.identifier()); discovered.addAll(names); for (final String name : names) { diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java index 954bbf2373..b224c5714c 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java @@ -58,7 +58,7 @@ public final class PullMojo extends SafeMojo { /** * The directory where to process to. */ - public static final String DIR = "5-pull"; + public static final String DIR = "4-pull"; /** * The Git tag to pull objects from, in objectionary. diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java index fc68ca709e..013c337cd3 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java @@ -65,7 +65,7 @@ public final class ResolveMojo extends SafeMojo { /** * The directory where to resolve to. */ - public static final String DIR = "6-resolve"; + public static final String DIR = "5-resolve"; /** * Skip artifact with the version 0.0.0. diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java index cc1d99729b..fe0d0b24c8 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/TranspileMojo.java @@ -185,7 +185,7 @@ public void exec() throws IOException { */ private int transpile(final ForeignTojo tojo) throws IOException { final int saved; - final Path file = tojo.shaken(); + final Path file = tojo.verified(); final XML input = new XMLDocument(file); final String name = input.xpath("/program/@name").get(0); final Place place = new Place(name); diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java index 5ebec604e4..2ee9d1e166 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java @@ -90,11 +90,11 @@ void exec() throws IOException { new MapEntry<>(OptimizationFolder.CACHE.key(), this.cache) ), new MapOf( - new MapEntry<>(OptimizationFolder.TARGET.key(), "4-verify"), + new MapEntry<>(OptimizationFolder.TARGET.key(), "6-verify"), new MapEntry<>(OptimizationFolder.CACHE.key(), "verified") ), ForeignTojo::withVerified, - ForeignTojo::optimized + ForeignTojo::shaken ) ).count(); if (total > 0) { diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java index aeb9bdb09e..e23afe2b4a 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java @@ -647,6 +647,7 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, + VerifyMojo.class, TranspileMojo.class ).iterator(); } @@ -703,7 +704,6 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, - VerifyMojo.class, ResolveMojo.class ).iterator(); } @@ -738,7 +738,6 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, - VerifyMojo.class, ResolveMojo.class, PlaceMojo.class ).iterator(); @@ -758,7 +757,6 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, - VerifyMojo.class, SodgMojo.class ).iterator(); } @@ -790,7 +788,6 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, - VerifyMojo.class, DiscoverMojo.class, ProbeMojo.class ).iterator(); @@ -810,7 +807,6 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, - VerifyMojo.class, DiscoverMojo.class, ProbeMojo.class, PullMojo.class @@ -831,7 +827,6 @@ public Iterator> iterator() { ParseMojo.class, OptimizeMojo.class, ShakeMojo.class, - VerifyMojo.class, DiscoverMojo.class ).iterator(); } diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml index d9304ff2c8..177b49386c 100644 --- a/eo-runtime/pom.xml +++ b/eo-runtime/pom.xml @@ -156,6 +156,7 @@ SOFTWARE. register assemble + verify transpile copy unplace @@ -177,6 +178,7 @@ SOFTWARE. register assemble + verify transpile binarize From 5564de608774f0234d387d14981897b8994b8d69 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 5 Dec 2023 13:02:06 +0300 Subject: [PATCH 07/12] #2443: renumerated --- eo-runtime/src/test/groovy/check-folders-numbering.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-folders-numbering.groovy b/eo-runtime/src/test/groovy/check-folders-numbering.groovy index 1a07f3c214..37a16e0525 100644 --- a/eo-runtime/src/test/groovy/check-folders-numbering.groovy +++ b/eo-runtime/src/test/groovy/check-folders-numbering.groovy @@ -36,10 +36,10 @@ List allowed = [ '1-parse', '2-optimize', '3-shake', - '4-verify', - '5-pull', - '6-resolve', - '7-pre', + '4-pull', + '5-resolve', + '6-pre', + '7-verify', '8-transpile', ] List allowedDirs = allowed.stream() From dfb3d43c89f0e95bdbfaa95299d8e85030263bef Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 5 Dec 2023 13:32:09 +0300 Subject: [PATCH 08/12] #2443: renumerated directories in groovy. Again. --- eo-runtime/src/test/groovy/check-folders-numbering.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-runtime/src/test/groovy/check-folders-numbering.groovy b/eo-runtime/src/test/groovy/check-folders-numbering.groovy index 37a16e0525..cc072abf52 100644 --- a/eo-runtime/src/test/groovy/check-folders-numbering.groovy +++ b/eo-runtime/src/test/groovy/check-folders-numbering.groovy @@ -38,8 +38,8 @@ List allowed = [ '3-shake', '4-pull', '5-resolve', - '6-pre', - '7-verify', + '6-verify', + '7-pre', '8-transpile', ] List allowedDirs = allowed.stream() From 914ff5c41cb5996e4a7cdace1b509a669014fe09 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 5 Dec 2023 16:26:14 +0300 Subject: [PATCH 09/12] #2443: failOnError flag --- .../java/org/eolang/maven/AssembleMojo.java | 3 ++ .../java/org/eolang/maven/OptimizeMojo.java | 3 +- .../java/org/eolang/maven/VerifyMojo.java | 25 ++------- .../org/eolang/maven/OptimizeMojoTest.java | 53 +++---------------- .../java/org/eolang/maven/VerifyMojoTest.java | 41 ++------------ 5 files changed, 21 insertions(+), 104 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java index 9120e938e4..5cf58874f3 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java @@ -118,6 +118,9 @@ public final class AssembleMojo extends SafeMojo { * Whether we should fail on error. * @checkstyle MemberNameCheck (7 lines) * @since 0.23.0 + * @todo #2443:90min Remove the following failOnError flag. Now we + * have already got rid from it in {@link OptimizeMojo} and {@link VerifyMojo}. + * We need to make failOnError the behaviour default. */ @SuppressWarnings("PMD.ImmutableField") @Parameter( diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java index 79a8fccb89..20f0129c7a 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/OptimizeMojo.java @@ -122,7 +122,7 @@ public void exec() throws IOException { * @return Optimization for all tojos. */ private Optimization optimization() { - final Optimization opt; + Optimization opt; if (this.trackOptimizationSteps) { opt = new OptSpy( new ParsingTrain(), @@ -131,6 +131,7 @@ private Optimization optimization() { } else { opt = new OptTrain(new ParsingTrain()); } + opt = new OptTrain(opt, "/org/eolang/parser/fail-on-critical.xsl"); return opt; } } diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java index 2ee9d1e166..d620bfde66 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java @@ -50,18 +50,6 @@ ) public final class VerifyMojo extends SafeMojo { - /** - * Whether we should fail on error. - * - * @checkstyle MemberNameCheck (7 lines) - * @since 0.34.0 - */ - @SuppressWarnings("PMD.ImmutableField") - @Parameter( - property = "eo.failOnError", - defaultValue = "true") - private boolean failOnError = true; - /** * Whether we should fail on warning. * @@ -114,18 +102,13 @@ void exec() throws IOException { * @return Verifying optimizations */ private Optimization optimization() { - Optimization opt = new OptTrain(new TrDefault<>()); - if (this.failOnError) { - opt = new OptTrain(opt, "/org/eolang/parser/fail-on-errors.xsl"); - } + Optimization opt = new OptTrain( + new OptTrain(new TrDefault<>()), + "/org/eolang/parser/fail-on-errors.xsl" + ); if (this.failOnWarning) { opt = new OptTrain(opt, "/org/eolang/parser/fail-on-warnings.xsl"); } - if (this.failOnError) { - opt = new OptTrain(opt, "/org/eolang/parser/fail-on-critical.xsl"); - } else { - opt = new OptTrain(opt, new TrDefault<>()); - } return opt; } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java index aaa4cca579..82aab5f6d7 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java @@ -23,7 +23,6 @@ */ package org.eolang.maven; -import com.jcabi.matchers.XhtmlMatchers; import com.jcabi.xml.XMLDocument; import java.io.IOException; import java.nio.file.Path; @@ -220,54 +219,18 @@ void optimizesConcurrentlyWithLotsOfPrograms(@TempDir final Path temp) throws IO } @Test - void failsOnErrorFlag(@TempDir final Path temp) throws IOException { - MatcherAssert.assertThat( - new FakeMaven(temp) + void failsOnCritical(@TempDir final Path temp) throws IOException { + Assertions.assertThrows( + IllegalStateException.class, + () -> new FakeMaven(temp) .withProgram( "+package f\n", - "+alias THIS-IS-WRONG org.eolang.io.stdout", "[args] > main", - " (stdout \"Hello!\").print > @" - ) - .with("failOnError", false) + " seq > @", + " TRUE > x", + " FALSE > x" + ).with("trackOptimizationSteps", true) .execute(new FakeMaven.Optimize()) - .result(), - Matchers.not( - Matchers.hasKey( - String.format("target/%s/foo/x/main.%s", OptimizeMojo.DIR, TranspileMojo.EXT) - ) - ) - ); - } - - @Test - void stopsOnCritical(@TempDir final Path temp) throws IOException { - MatcherAssert.assertThat( - new XMLDocument( - new FakeMaven(temp) - .withProgram( - "+package f\n", - "[args] > main", - " seq > @", - " TRUE > x", - " FALSE > x" - ) - .with("trackOptimizationSteps", true) - .with("failOnError", false) - .execute(new FakeMaven.Optimize()) - .result() - .get( - String.format( - "target/%s/foo/x/main/28-duplicate-names.xml", - OptimizeMojo.STEPS - ) - ) - ), - XhtmlMatchers.hasXPaths( - "/program/sheets[count(sheet)=2]", - "/program/errors[count(error)=1]", - "/program/errors/error[@severity='critical']" - ) ); } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java index 505d1c2f84..120e67309e 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java @@ -105,23 +105,7 @@ void doesNotDetectWarningWithoutCorrespondingFlag(@TempDir final Path temp) { } @Test - void detectsCriticalError(@TempDir final Path temp) { - Assertions.assertThrows( - IllegalStateException.class, - () -> new FakeMaven(temp) - .withProgram( - "+package f\n", - "[] > main", - " [] > name", - " [] > name" - ) - .execute(new FakeMaven.Verify()), - "Program with duplicate names should have failed on critical error, but it didn't" - ); - } - - @Test - void failsOptimization(@TempDir final Path temp) { + void failsOptimizationOnError(@TempDir final Path temp) { Assertions.assertThrows( IllegalStateException.class, () -> new FakeMaven(temp) @@ -146,7 +130,7 @@ void failsOnWarning(@TempDir final Path temp) throws Exception { " [] > @", " hello > test" ); - this.applyXsl( + VerifyMojoTest.applyXsl( "org/eolang/maven/set-warning-severity.xsl", maven.execute(ParseMojo.class) .result() @@ -154,34 +138,17 @@ void failsOnWarning(@TempDir final Path temp) throws Exception { ); Assertions.assertThrows( IllegalStateException.class, - () -> maven.with("failOnError", false) - .with("failOnWarning", true) + () -> maven.with("failOnWarning", true) .execute(VerifyMojo.class) ); } - @Test - void failsOnCritical(@TempDir final Path temp) { - Assertions.assertThrows( - IllegalStateException.class, - () -> new FakeMaven(temp) - .withProgram( - "+package f\n", - "[args] > main", - " seq > @", - " TRUE > x", - " FALSE > x" - ) - .execute(new FakeMaven.Verify()) - ); - } - /** * Apply XSL transformation. * @param xsl Path to XSL within classpath * @param xml Path to XML to be tranformed */ - private void applyXsl(final String xsl, final Path xml) throws Exception { + private static void applyXsl(final String xsl, final Path xml) throws Exception { final XML output = new Xsline( new TrDefault() .with( From e1d2fbe01d9eefe863a113d7bce1eff8837d95a2 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 5 Dec 2023 16:31:23 +0300 Subject: [PATCH 10/12] #2443: failOnError flag --- .../src/main/java/org/eolang/maven/AssembleMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java index 5cf58874f3..52f9a2b1a3 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java @@ -116,7 +116,7 @@ public final class AssembleMojo extends SafeMojo { /** * Whether we should fail on error. - * @checkstyle MemberNameCheck (7 lines) + * @checkstyle MemberNameCheck (11 lines) * @since 0.23.0 * @todo #2443:90min Remove the following failOnError flag. Now we * have already got rid from it in {@link OptimizeMojo} and {@link VerifyMojo}. From 1b5c5dc1cadce97a537d3d92a10fb22f58119463 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Wed, 6 Dec 2023 12:41:19 +0300 Subject: [PATCH 11/12] #2443: Added message for assertion --- .../src/test/java/org/eolang/maven/VerifyMojoTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java index 120e67309e..227466f1e3 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java @@ -115,7 +115,8 @@ void failsOptimizationOnError(@TempDir final Path temp) { "[args] > main", " (stdout \"Hello!\").print > @" ) - .execute(new FakeMaven.Verify()) + .execute(new FakeMaven.Verify()), + "Error in the eo code because of invalid alias" ); } @@ -139,7 +140,8 @@ void failsOnWarning(@TempDir final Path temp) throws Exception { Assertions.assertThrows( IllegalStateException.class, () -> maven.with("failOnWarning", true) - .execute(VerifyMojo.class) + .execute(VerifyMojo.class), + "Program with warning should be failed" ); } From 454d3bee2ae1c0af42762bb2fda641b2685458df Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Wed, 6 Dec 2023 12:48:00 +0300 Subject: [PATCH 12/12] #2443: Edited message for assertion --- .../src/test/java/org/eolang/maven/VerifyMojoTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java index 227466f1e3..d73c88fb06 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java @@ -116,7 +116,7 @@ void failsOptimizationOnError(@TempDir final Path temp) { " (stdout \"Hello!\").print > @" ) .execute(new FakeMaven.Verify()), - "Error in the eo code because of invalid alias" + "Error in the eo code because of invalid alias, should fail" ); } @@ -141,7 +141,7 @@ void failsOnWarning(@TempDir final Path temp) throws Exception { IllegalStateException.class, () -> maven.with("failOnWarning", true) .execute(VerifyMojo.class), - "Program with warning should be failed" + "Program with warning should fail" ); }