Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 23, 2024
2 parents f924b17 + b477065 commit 191151f
Show file tree
Hide file tree
Showing 103 changed files with 617 additions and 357 deletions.
Expand Up @@ -50,11 +50,6 @@ final class BinarizeMojoTest {
*/
public static final Path SRC = Paths.get("src/test/resources/org/eolang/maven/binarize/");

/**
* Empty message for JUnit Assertions.
*/
private static final String EMPTY_MSG = "TO ADD ASSERTION MESSAGE";

/**
* BinarizeMojo can binarize without errors.
* @param temp Temporary directory.
Expand All @@ -71,7 +66,8 @@ void binarizesWithoutErrors(@TempDir final Path temp) throws Exception {
.withProgram(BinarizeMojoTest.SRC.resolve("twice-rust.eo"));
}
Assertions.assertDoesNotThrow(
() -> maven.execute(new FakeMaven.Binarize())
() -> maven.execute(new FakeMaven.Binarize()),
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand All @@ -85,7 +81,8 @@ void failsWithIncorrectInsert(@TempDir final Path temp) throws IOException {
}
Assertions.assertThrows(
IllegalStateException.class,
() -> maven.execute(new FakeMaven.Binarize())
() -> maven.execute(new FakeMaven.Binarize()),
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand All @@ -103,14 +100,14 @@ void savesToCache(@TempDir final Path temp) throws IOException {
.execute(new FakeMaven.Binarize())
.result();
MatcherAssert.assertThat(
BinarizeMojoTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.hasValue(
cache.resolve("Lib")
)
);
MatcherAssert.assertThat(
BinarizeMojoTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.not(
Matchers.hasValue(
Expand All @@ -121,7 +118,8 @@ void savesToCache(@TempDir final Path temp) throws IOException {
)
);
Assertions.assertDoesNotThrow(
() -> maven.execute(new FakeMaven.Binarize())
() -> maven.execute(new FakeMaven.Binarize()),
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand All @@ -144,7 +142,7 @@ void boostsSecondCompilation(@TempDir final Path temp) throws IOException {
finish = System.currentTimeMillis();
final long second = finish - start;
MatcherAssert.assertThat(
BinarizeMojoTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
second,
Matchers.lessThan(first)
);
Expand All @@ -169,12 +167,12 @@ void doesNotRecompile(@TempDir final Path temp) throws IOException {
maven.execute(new FakeMaven.Binarize());
final long second = executable.lastModified();
MatcherAssert.assertThat(
BinarizeMojoTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
first,
Matchers.not(0L)
);
MatcherAssert.assertThat(
BinarizeMojoTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
second,
Matchers.equalTo(first)
);
Expand Down
Expand Up @@ -44,13 +44,19 @@
*
* @since 0.1
*/
@SuppressWarnings("PMD.JUnit5TestShouldBePackagePrivate")
@Execution(ExecutionMode.CONCURRENT)
final class BinarizeParseTest {
public final class BinarizeParseTest {

/**
* Empty message for JUnit Assertions.
*
* @todo #2297:60m Replace all appearances of {@link BinarizeParseTest#TO_ADD_MESSAGE} field in
* eo-maven-plugin with meaningful assert messages. Don't forget to remove
* {@link BinarizeParseTest#TO_ADD_MESSAGE} field and remove public modifier from this class if
* no longer need.
*/
private static final String EMPTY_MSG = "TO ADD ASSERTION MESSAGE";
public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

@Test
void parsesSimpleEoProgram(@TempDir final Path temp) throws Exception {
Expand All @@ -67,11 +73,11 @@ void parsesSimpleEoProgram(@TempDir final Path temp) throws Exception {
function
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res, Matchers.hasKey(rust)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(res.get(rust)).asString(),
Matchers.stringContainsInOrder(
"use rand::Rng;",
Expand All @@ -84,7 +90,7 @@ void parsesSimpleEoProgram(@TempDir final Path temp) throws Exception {
)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(
res.get(
String.format(
Expand Down Expand Up @@ -112,15 +118,15 @@ void binarizesTwiceRustProgram(@TempDir final Path temp) throws Exception {
Names.PREFIX
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res, Matchers.hasKey(one)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res, Matchers.hasKey(two)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(res.get(one)).asString(),
Matchers.stringContainsInOrder(
"use eo::eo_enum::EO;",
Expand All @@ -130,7 +136,7 @@ void binarizesTwiceRustProgram(@TempDir final Path temp) throws Exception {
)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(res.get(two)).asString(),
Matchers.stringContainsInOrder(
"use eo::eo_enum::EO;",
Expand All @@ -145,7 +151,7 @@ void binarizesTwiceRustProgram(@TempDir final Path temp) throws Exception {
@ClasspathSource(value = "org/eolang/maven/binarize/add_rust/", glob = "**.yaml")
void createsDependenciesSection(final String yaml) {
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
new XaxStory(yaml),
Matchers.is(true)
);
Expand All @@ -169,19 +175,19 @@ void createsCorrectRustProject(@TempDir final Path temp) throws Exception {
dir
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res, Matchers.hasKey(cargo)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res, Matchers.hasKey(lib)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
res, Matchers.hasKey(module)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(res.get(cargo)).asString(),
Matchers.stringContainsInOrder(
"[lib]",
Expand All @@ -191,7 +197,7 @@ void createsCorrectRustProject(@TempDir final Path temp) throws Exception {
)
);
MatcherAssert.assertThat(
BinarizeParseTest.EMPTY_MSG,
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(res.get(cargo)).asString(),
Matchers.stringContainsInOrder(
"[dependencies]",
Expand Down
Expand Up @@ -54,7 +54,7 @@ final class CatalogsTest {
void readsFromTojosConcurrently(@TempDir final Path tmp) {
final Tojos tojos = Catalogs.INSTANCE.make(tmp.resolve("foreign"), "json");
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new SumOf(
new Threads<>(
CatalogsTest.CORES,
Expand Down
Expand Up @@ -54,7 +54,7 @@ void cleansSuccessfully(@TempDir final Path temp) throws IOException {
.with("targetDir", dir.toFile())
.execute(CleanMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
!file.toFile().exists() && !small.toFile().exists(),
Matchers.is(true)
);
Expand All @@ -76,7 +76,7 @@ void makesFullCompilingLifecycleSuccessfully(@TempDir final Path temp) throws IO
.execute(AssembleMojo.class)
.execute(CleanMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
temp.resolve("target").toFile().exists(),
Matchers.is(false)
);
Expand Down
Expand Up @@ -57,12 +57,12 @@ void copiesSources(@TempDir final Path temp) throws Exception {
.execute(CopyMojo.class);
final Path out = classes.resolve("EO-SOURCES/foo/main.eo");
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new HmBase(classes).exists(classes.relativize(out)),
Matchers.is(true)
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(new HmBase(classes).load(classes.relativize(out))).asString(),
Matchers.allOf(
Matchers.containsString("+rt foo:"),
Expand Down Expand Up @@ -90,7 +90,7 @@ void skipsCopyMojo(@TempDir final Path temp) throws IOException {
.execute(CopyMojo.class);
final Path out = classes.resolve("EO-SOURCES/foo/main.eo");
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new HmBase(classes).exists(classes.relativize(out)),
Matchers.is(false)
);
Expand Down
Expand Up @@ -47,12 +47,12 @@ void findsDirs(@TempDir final Path temp) throws IOException {
new HmBase(temp).save("", Paths.get("test/f.txt"));
new HmBase(temp).save("", Paths.get("a/g"));
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new DepDirs(temp),
Matchers.contains(String.format("a%sb%1$sc%1$sf", File.separator))
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new DepDirs(temp),
Matchers.iterableWithSize(1)
);
Expand Down
Expand Up @@ -89,12 +89,12 @@ void executesDiscoveryPhaseForCorrectEoPrograms(
);
final Map<String, String> first = json.removeFirst();
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
dependencies,
Matchers.equalTo(json.size())
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
String.valueOf(dependencies),
Matchers.equalTo(first.get("discovered"))
);
Expand Down
Expand Up @@ -66,7 +66,7 @@ void convertsXmirtoJavaSuccessfully(@TempDir final Path temp) throws Exception {
Paths.get("sum.xmir")
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(
new InputOf(
new JavaFiles(
Expand All @@ -86,7 +86,7 @@ void convertsXmirtoJavaWithoutJavaClasses(@TempDir final Path temp) throws Excep
Paths.get("sum.xmir")
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new JavaFiles(
temp.resolve("xml").resolve("sum.xmir"),
temp.resolve("java")
Expand Down
Expand Up @@ -46,7 +46,7 @@ final class LatexMojoTest {
@Test
void generatesTexFile(@TempDir final Path temp) throws Exception {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new FakeMaven(temp)
.withHelloWorld()
.execute(new FakeMaven.Latex())
Expand All @@ -64,7 +64,7 @@ void generatesTexFile(@TempDir final Path temp) throws Exception {
@Test
void checksLastName() {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
LatexMojo.last("foo.bar.hello"),
Matchers.equalTo("hello")
);
Expand Down
Expand Up @@ -78,7 +78,7 @@ void printsFormattedMessage(final Logs out) {
@Test
void matchesCorrectly() {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
"16:02:08 [INFO] org.eolang.maven.LogFormatTest: Wake up, Neo...\n",
Matchers.matchesPattern(LogFormatTest.FORMAT)
);
Expand Down
Expand Up @@ -52,7 +52,7 @@ void extendsForeignWithNewObjects(@TempDir final Path temp) throws IOException {
final FakeMaven maven = new FakeMaven(temp);
maven.execute(MarkMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
maven.foreignTojos()
.all()
.iterator()
Expand All @@ -71,12 +71,12 @@ void updatesVersionIfItExists(@TempDir final Path temp) throws IOException {
.withVersion("*.*.*");
maven.execute(MarkMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
foreign.all().iterator().next().version(),
Matchers.equalTo(MarkMojoTest.VERSION)
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
foreign.size(),
Matchers.equalTo(1)
);
Expand Down

4 comments on commit 191151f

@0pdd
Copy link

@0pdd 0pdd commented on 191151f Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2171-74d15acf disappeared from pom.xml), that's why I closed #2297. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on 191151f Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2297-97b6e95d discovered in eo-maven-plugin/src/test/java/org/eolang/maven/BinarizeParseTest.java) and submitted as #3130. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 191151f Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2297-059cad72 discovered in eo-parser/src/test/java/org/eolang/parser/EoIndentLexerTest.java) and submitted as #3131. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 191151f Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2297-a38e7947 discovered in eo-runtime/src/test/java/org/eolang/AtCompositeTest.java) and submitted as #3132. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.