Skip to content

Commit

Permalink
feat(objectionary#1417): remove CompilationResult
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Nov 18, 2022
1 parent b1b0597 commit 28a1c02
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 121 deletions.
19 changes: 14 additions & 5 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,21 @@ final class ParseMojoTest {

@Test
void testSimpleParsing(@TempDir final Path temp) throws Exception {
final FakeMaven maven = new FakeMaven(temp);
maven.program("+package f\n\n[args] > main\n (stdout \"Hello!\").print\n")
.execute(ParseMojo.class);
MatcherAssert.assertThat(
new FakeMaven(temp)
.program("+package f\n\n[args] > main\n (stdout \"Hello!\").print\n")
.execute(ParseMojo.class)
.result()
.xmirCompiled(),
new Home(maven.targetPath()).exists(
Paths.get(
String.format("%s/foo/x/main.%s", ParseMojo.DIR, TranspileMojo.EXT)
)
),
Matchers.is(true)
);
MatcherAssert.assertThat(
new TjSmart(
Catalogs.INSTANCE.make(maven.foreignPath())
).getById("foo.x.main").exists("xmir"),
Matchers.is(true)
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public final class FakeMaven {
*/
private static final String FOREIGN_FORMAT = "csv";


/**
* Default eo-foreign.csv file path.
*/
Expand Down Expand Up @@ -109,42 +110,29 @@ public <T extends AbstractMojo> FakeMaven execute(final Class<T> mojo) {
}

/**
* Builds and returns compilation results after all manipulations.
*
* @return Compilation result.
*/
public CompilationResult result() {
return new CompilationResult(
FakeMaven.PROGRAM_ID,
new Home(this.targetPath()),
this.foreignPath()
);
}

/**
* Creates eo-foreign.* file. In the future it is going to be a method for `MavenWorkspace`
* interface.
* Path to compilation target directory.
* @return Path to target dir.
*/
private void withEoForeign() {
Catalogs.INSTANCE.make(this.foreignPath())
.add(FakeMaven.PROGRAM_ID)
.set(AssembleMojo.ATTR_SCOPE, "compile")
.set(AssembleMojo.ATTR_EO, this.workspace.absolute(this.prog));
public Path targetPath() {
return this.workspace.absolute(Paths.get("target"));
}

/**
* Path to 'eo-foreign.csv' or 'eo-foreign.json' file after all changes.
* @return Path to eo-foreign.* file.
*/
private Path foreignPath() {
public Path foreignPath() {
return this.workspace.absolute(FakeMaven.FOREIGN_PATH);
}

/**
* Path to compilation target directory.
* @return Path to target dir.
* Creates eo-foreign.* file. In the future it is going to be a method for `MavenWorkspace`
* interface.
*/
private Path targetPath() {
return this.workspace.absolute(Paths.get("target"));
private void withEoForeign() {
Catalogs.INSTANCE.make(this.foreignPath())
.add(FakeMaven.PROGRAM_ID)
.set(AssembleMojo.ATTR_SCOPE, "compile")
.set(AssembleMojo.ATTR_EO, this.workspace.absolute(this.prog));
}
}

0 comments on commit 28a1c02

Please sign in to comment.