Skip to content

Commit

Permalink
add return code from test
Browse files Browse the repository at this point in the history
Signed-off-by: issacto <[email protected]>
  • Loading branch information
issacto committed Jun 27, 2023
1 parent 0b17618 commit f5259ac
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/org/openmainframeproject/cobolcheck/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static void main(String[] args) throws InterruptedException {

if (initializer.launchTestProgram())
testRunner.run(programName, initializer.isLastSourceProgram(programName));
initializer.setReturnCode(testRunner.getReturnCode());

}

initializer.exitProgram();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class CurrentStatus {

public CurrentStatus(){
exitStatus = Constants.STATUS_NORMAL;
exitStatus = Constants.STATUS_TEST_ERROR;
}

int exitStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class LauncherController {
private Launcher launcher;
private ProcessOutputWriter processOutputWriter;
private int returnCode;

public LauncherController(){
if (Config.getRunGeneratedTest()){
Expand Down Expand Up @@ -44,6 +45,11 @@ public void runTestProgram(String programName, boolean isLastRun) throws Interru
if (processOutputWriter.writeWasSuccesful){
Log.info(Messages.get("INF011", processName, processOutputWriter.getTestResultsFilePath()));
}
this.returnCode = exitCode;
Log.info(Messages.get("INF009", processName, String.valueOf(exitCode)));
}

public int getReturnCode(){
return this.returnCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private Constants() {

// File read status values
public static final int STATUS_NORMAL = 0;
public static final int STATUS_TEST_ERROR = 4;
public static final int STATUS_HALT = 8;

public static final int COMMENT_SPACE_OFFSET = 7;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ public void run(String programName, boolean isLastRun) throws InterruptedExcepti
programName = path.getFileName().toString();
controller.runTestProgram(programName, isLastRun);
}

public int getReturnCode(){
return controller.getReturnCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public void run() {
statusController.setTestFileNames(argumentController.getKeyValue(Constants.TESTS_OPTION));
}

public void setReturnCode(int returnCode){
if(returnCode==0) statusController.setExitStatusNormal();
}

public String[] getSourceProgramNames(){
return statusController.getSourceProgramNames();
}
Expand Down

0 comments on commit f5259ac

Please sign in to comment.