Skip to content

Commit b76a6bd

Browse files
committed
Fix ParseCommandTest by mocking an additional method in resultfactory
1 parent a81eafc commit b76a6bd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

org.metaborg.spoofax.shell.core/src/main/java/org/metaborg/spoofax/shell/commands/ParseCommand.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.util.stream.Collectors;
55

6+
import org.apache.commons.vfs2.FileObject;
67
import org.metaborg.core.MetaborgException;
78
import org.metaborg.core.language.ILanguageImpl;
89
import org.metaborg.core.messages.IMessage;
@@ -77,15 +78,17 @@ public ParseResult parse(InputResult unit) throws MetaborgException {
7778
@Override
7879
public void execute(String... args) throws MetaborgException {
7980
try {
81+
String source = args[0];
82+
FileObject file = write(args[0]);
8083
ShellFacet shellFacet = lang.facet(ShellFacet.class);
84+
8185
InputResult input = resultFactory
82-
.createInputResult(lang, write(args[0]), args[0],
86+
.createInputResult(lang, file, source,
8387
new JSGLRParserConfiguration(shellFacet.getShellStartSymbol()));
8488
try {
8589
resultHook.accept(parse(input));
8690
} catch (MetaborgException e) {
87-
resultHook.accept(parse(resultFactory.createInputResult(lang, input.unit().source(),
88-
input.unit().text())));
91+
resultHook.accept(parse(resultFactory.createInputResult(lang, file, source)));
8992
}
9093
} catch (IOException e) {
9194
throw new MetaborgException("Cannot write to temporary source file.");

org.metaborg.spoofax.shell.core/src/test/java/org/metaborg/spoofax/shell/commands/ParseCommandTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public void setup() throws FileSystemException, ParseException {
6262

6363
when(project.location()).thenReturn(sourceFile);
6464

65+
when(resultFactory.createInputResult(any(), any(), any())).thenReturn(inputResult);
6566
when(resultFactory.createInputResult(any(), any(), any(), any())).thenReturn(inputResult);
6667
when(resultFactory.createParseResult(any())).thenReturn(parseResult);
6768

0 commit comments

Comments
 (0)