Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jun 10, 2024
2 parents f36094c + 10b6088 commit c5bbe04
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
14 changes: 12 additions & 2 deletions eo-maven-plugin/src/main/java/org/eolang/maven/PullMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,18 @@ public void exec() throws IOException {
)
);
names.add(name);
tojo.withSource(this.pull(name).toAbsolutePath())
.withHash(new ChNarrow(name.hash()));
try {
tojo.withSource(this.pull(name).toAbsolutePath())
.withHash(new ChNarrow(name.hash()));
} catch (final IOException exception) {
throw new IOException(
String.format(
"Failed to pull object discovered at %s",
tojo.discoveredAt()
),
exception
);
}
}
Logger.info(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*
* @since 0.30
*/
@SuppressWarnings("PMD.TooManyMethods")
@SuppressWarnings({"PMD.TooManyMethods", "PMD.GodClass"})
public final class ForeignTojo {

/**
Expand Down Expand Up @@ -137,6 +137,14 @@ public String probed() {
return this.attribute(ForeignTojos.Attribute.PROBED);
}

/**
* The discovered at location.
* @return The discovered at.
*/
public String discoveredAt() {
return this.attribute(ForeignTojos.Attribute.DISCOVERED_AT);
}

/**
* Checks if tojo was not already optimized.
*
Expand Down
36 changes: 36 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import org.eolang.maven.hash.ChText;
import org.eolang.maven.hash.CommitHash;
import org.eolang.maven.hash.CommitHashesMap;
import org.eolang.maven.log.CaptureLogs;
import org.eolang.maven.log.Logs;
import org.eolang.maven.name.ObjectName;
import org.eolang.maven.name.OnVersioned;
import org.eolang.maven.objectionary.Objectionaries;
Expand All @@ -46,6 +48,7 @@
import org.eolang.maven.util.HmBase;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
Expand Down Expand Up @@ -294,6 +297,39 @@ void doesNotPullInOfflineMode(@TempDir final Path tmp) throws IOException {
);
}

@Test
@CaptureLogs
void showsWhereNotFoundWasDiscoveredAt(@TempDir final Path tmp, final Logs out) {
Assertions.assertThrows(
Exception.class,
() -> {
new FakeMaven(tmp)
.withProgram(
"+package com.example\n",
"# This is the default 64+ symbols comment in front of named abstract object.",
"[] > main",
" org.eolang.org > @"
)
.with(
"objectionaries",
new Objectionaries.Fake(
new OyRemote(
new ChRemote("master")
)
)
)
.execute(new FakeMaven.Pull());
},
"Pull mojo should fail, but it does not"
);
Assertions.assertTrue(
out.captured().stream().anyMatch(
line -> line.contains("Failed to pull object discovered at")
),
"Log should contain info where failed to pull object was discovered at, but it does not"
);
}

/**
* Check if the given source file exists in the target directory.
* @param temp Test temporary directory.
Expand Down

0 comments on commit c5bbe04

Please sign in to comment.