Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 1, 2024
1 parent 6635c93 commit 4e5f490
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions src/test/java/org/eolang/hone/OptimizeMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
package org.eolang.hone;

import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -111,9 +109,23 @@ void worksAfterOptimization() {
}
""".getBytes()
);
Assertions.assertTrue(
OptimizeMojoTest.optimizeAndTest(f, image),
"must optimize without mistakes"
f.dependencies()
.append("org.junit.jupiter", "junit-jupiter-engine", "5.10.2");
f.dependencies()
.append("org.junit.jupiter", "junit-jupiter-params", "5.10.2");
f.build()
.plugins()
.appendItself()
.execution("default")
.phase("process-classes")
.goals("build", "optimize", "rmi")
.configuration()
.set("image", image);
f.exec("test");
MatcherAssert.assertThat(
"the build must be successful",
f.log(),
new LogMatcher()
);
MatcherAssert.assertThat(
"optimized .xmir must be present",
Expand Down Expand Up @@ -231,9 +243,23 @@ void worksAfterOptimization() {
}
""".getBytes()
);
Assertions.assertTrue(
OptimizeMojoTest.optimizeAndTest(f, image),
"must optimize without mistakes"
f.dependencies()
.append("org.junit.jupiter", "junit-jupiter-engine", "5.10.2");
f.dependencies()
.append("org.junit.jupiter", "junit-jupiter-params", "5.10.2");
f.build()
.plugins()
.appendItself()
.execution("default")
.phase("process-classes")
.goals("build", "optimize", "rmi")
.configuration()
.set("image", image);
f.exec("test");
MatcherAssert.assertThat(
"the build must be successful",
f.log(),
new LogMatcher()
);
}
);
Expand Down Expand Up @@ -278,34 +304,4 @@ void optimizesJustOneLargeJnaClass(@Mktmp final Path dir,
}
);
}

/**
* Run optimization.
* @param farea The farea
* @param image The image name
* @return TRUE if success
* @throws IOException If fails
*/
private static boolean optimizeAndTest(final Farea farea,
final String image) throws IOException {
farea.dependencies()
.append("org.junit.jupiter", "junit-jupiter-engine", "5.10.2");
farea.dependencies()
.append("org.junit.jupiter", "junit-jupiter-params", "5.10.2");
farea.build()
.plugins()
.appendItself()
.execution("default")
.phase("process-classes")
.goals("build", "optimize", "rmi")
.configuration()
.set("image", image);
farea.exec("test");
MatcherAssert.assertThat(
"the build must be successful",
farea.log(),
new LogMatcher()
);
return true;
}
}

0 comments on commit 4e5f490

Please sign in to comment.