Skip to content

Commit a386f8b

Browse files
committed
Complete preAnalyseError test
1 parent 3bf8747 commit a386f8b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/test/java/GoblintAnalysisTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,16 @@ void preAnalyseError() {
241241
doReturn(true).when(goblintServer).isAlive();
242242
when(goblintConfWatcher.refreshGoblintConfig()).thenReturn(true);
243243

244-
// Mock that the command to execute is not empty
245-
// Make mistake to catch exception - correct - {"cmake", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-B", "build"}
246-
String[] preAnalyzeCommand = new String[]{"cmake", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-B", "build"};
244+
// Mock that Goblint returns some messages
245+
when(goblintService.messages()).thenReturn(CompletableFuture.completedFuture(new ArrayList<>()));
246+
247+
// Mock that the command to execute is not empty and is something that is not a valid command
248+
String processName = "asdf";
249+
String[] preAnalyzeCommand = new String[]{processName};
247250
when(gobPieConfiguration.getPreAnalyzeCommand()).thenReturn(preAnalyzeCommand);
248251

249252
// Mock that the analyses of Goblint have started and completed
250-
when(goblintService.analyze(new AnalyzeParams(false))).thenReturn(CompletableFuture.completedFuture(null));
251-
//.throw
253+
when(goblintService.analyze(new AnalyzeParams(false))).thenReturn(CompletableFuture.completedFuture(new GoblintAnalysisResult()));
252254

253255
// Mock that the incremental analysis is turned off (TODO: not sure why this is checked in reanalyze?)
254256
when(gobPieConfiguration.useIncrementalAnalysis()).thenReturn(true);
@@ -261,7 +263,8 @@ void preAnalyseError() {
261263
// Verify that preAnalysis was indeed called once
262264
verify(goblintServer).preAnalyse();
263265
verify(magpieServer).forwardMessageToClient(new MessageParams(MessageType.Info, "GobPie started analyzing the code."));
264-
//verify(magpieServer).forwardMessageToClient(new MessageParams(MessageType.Warning, "Running preanalysis command failed."));
266+
verify(magpieServer).forwardMessageToClient(new MessageParams(MessageType.Warning, "Running preanalysis command failed."));
267+
verify(magpieServer).forwardMessageToClient(new MessageParams(MessageType.Info, "GobPie finished analyzing the code."));
265268
}
266269

267270
}

0 commit comments

Comments
 (0)