Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge DEV to MAIN #347

Merged
merged 45 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
731e72b
Dummy change
Dec 15, 2023
4f99701
Update ProcessOutputWriter.java
SMoRG75 Apr 4, 2024
1ad4623
Correct message
SMoRG75 Apr 4, 2024
dc0d49c
bump versions
SMoRG75 Apr 4, 2024
81795cd
more bumping
SMoRG75 Apr 4, 2024
d867dd6
0.2.9 builds
SMoRG75 Apr 4, 2024
c431d60
minor detail
SMoRG75 Apr 4, 2024
26e4116
Update cobol-check-0.2.9.zip
SMoRG75 Apr 4, 2024
14f5165
Update cobol-check-0.2.9.jar
SMoRG75 Apr 4, 2024
5feb40e
Update CobolGenerator.java
SMoRG75 Apr 4, 2024
ab55727
less periods
SMoRG75 Apr 5, 2024
4789318
Merge branch 'main' of https://github.com/openmainframeproject/cobol-…
Apr 22, 2024
1657fe2
Merge pull request #342 from openmainframeproject/make-it-more-thread…
SMoRG75 Apr 29, 2024
4c2d646
Initial commit on branch
May 13, 2024
af195cf
Merge remote-tracking branch 'origin/Developer' into DDH-12295-Fixing…
May 13, 2024
102d5c3
New version created
May 13, 2024
c3e0e9b
Update VerifyAction.yml
SMoRG75 May 13, 2024
e6200df
Lock added to thread when fetching output
May 13, 2024
3ada173
Cleanup
May 14, 2024
3539af1
Another build
May 14, 2024
ede79db
Just signoff:
Dec 15, 2023
efd308d
Testing
Dec 15, 2023
ed57349
Now unit test can run with or without input file.
Dec 19, 2023
5530c0c
Dummy change/Sign off
Dec 29, 2023
def427c
Initial commit on branch
May 13, 2024
169d43f
Update ProcessOutputWriter.java
SMoRG75 Apr 4, 2024
5033fdc
Correct message
SMoRG75 Apr 4, 2024
34c0a4b
bump versions
SMoRG75 Apr 4, 2024
14e6f4a
more bumping
SMoRG75 Apr 4, 2024
52a2b86
Update CobolGenerator.java
SMoRG75 Apr 4, 2024
a9233a9
less periods
SMoRG75 Apr 5, 2024
f0f3b03
New version created
May 13, 2024
d522535
Lock added to thread when fetching output
May 13, 2024
1c4b84d
Cleanup
May 14, 2024
8bbbd09
Another build
May 14, 2024
85ca1dc
Fixing copy book expand issue on z/OS
May 22, 2024
5b33b0b
Fixing compile issues with new npm version.
May 24, 2024
fe5d5dc
Merge branch 'DDH-12295-Fixing-dobbelt-output-from-COBOL-check-' of h…
SMoRG75 May 27, 2024
2433a9c
Bughunting
May 28, 2024
172f153
Fixing . and END-EXEC issue on z/OS
Jun 10, 2024
d396f7f
Merge pull request #345 from openmainframeproject/DDH-12295-Fixing-do…
SMoRG75 Jun 10, 2024
d1280d2
Update tsconfig.json
SMoRG75 Jun 10, 2024
26d6c27
Update tsconfig.json
SMoRG75 Jun 10, 2024
b379ee3
Update tsconfig.json
SMoRG75 Jun 10, 2024
45d168f
Update tsconfig.json
SMoRG75 Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/VerifyAction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
java-version: [8, 11]
java-version: [11]

steps:
- uses: actions/checkout@v3
- name: set up JDK 8
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
Expand All @@ -27,4 +27,4 @@ jobs:
- name: Tests
run: ./gradlew clean test
- name: Approval Tests
run: ./gradlew clean approvalTest
run: ./gradlew clean approvalTest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ output/testResults.txt
approval-test-actual.txt
default.conf
null
ParserErrorLog.txt
ParserErrorLog.txt
/zapp.json
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Mock SQL tables
- Mock batch file I/O

## \[0.2.10\] 2024-05-13
### Not released
- Fixing bug in showing unit test result twice.

## \[0.2.9\] 2024-04-23
### Not released
- Better thread handling of the files processInput and processError


## \[0.2.8\] 2023-10-17
### Implemented
- Proper handling of END-EXEC without trailing period in WORKING-STORAGE
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ As of March 2022 we could use help with:

## Downloads

Version 0.2.8 pre-release is available!
Version 0.2.10 pre-release is available!

[//]: # (- Find the download on the project home page on the [Neo Pragma site](https://neopragma.com/projects/cobol-check/).)
- Find distributions here: [Cobol Check Ditributions](https://github.com/openmainframeproject/cobol-check/tree/Developer/build/distributions).
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id 'jacoco'
}

def productVersion = '0.2.8'
def productVersion = '0.2.10'
def productName = 'cobol-check'
group = 'org.openmainframeproject'
description = 'Unit testing framework for Cobol'
Expand Down
Binary file added build/distributions/cobol-check-0.2.10.zip
Binary file not shown.
Binary file added build/distributions/cobol-check-0.2.9.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import org.openmainframeproject.cobolcheck.services.Constants;
import org.openmainframeproject.cobolcheck.services.cobolLogic.*;
import org.openmainframeproject.cobolcheck.services.log.Log;
import org.openmainframeproject.cobolcheck.services.platform.Platform;
import org.openmainframeproject.cobolcheck.services.platform.PlatformLookup;
import org.openmainframeproject.cobolcheck.services.RunInfo;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -140,7 +143,7 @@ public boolean shouldCurrentLineBeStubbed() throws IOException {
if (reader.getState().isFlagSetFor(Constants.PROCEDURE_DIVISION)) {
if (Interpreter.shouldLineBeStubbed(reader.getCurrentLine(), reader.getState())) {
if (!insideSectionOrParagraphMockBody && Interpreter.endsInPeriod(reader.getCurrentLine()))
reader.putNextLine(" .");
reader.putNextLine(" .");
reader.putNextLine(" CONTINUE");
return true;
}
Expand All @@ -154,9 +157,11 @@ public boolean shouldCurrentLineBeStubbed() throws IOException {
public boolean shouldCurrentStatementBeStubbed() {
for (CobolLine line : reader.getCurrentStatement()) {
if (Interpreter.shouldLineBeStubbed(line, reader.getState())) {
if (!insideSectionOrParagraphMockBody && Interpreter.endsInPeriod(reader.getCurrentLine()))
reader.putNextLine(" .");
reader.putNextLine(" CONTINUE");
if (reader.getState().isFlagSetFor(Constants.PROCEDURE_DIVISION)){
if (!insideSectionOrParagraphMockBody && !Interpreter.endsInPeriod(reader.getCurrentLine()))
reader.putNextLine(" .");
reader.putNextLine(" CONTINUE");
}
return true;
}
}
Expand Down Expand Up @@ -445,17 +450,26 @@ private void updateLineRepository(CobolLine line) throws IOException {
lineRepository.addFileSectionStatement(line.getUnNumberedString());
}
}

if (reader.isFlagSet(Constants.WORKING_STORAGE_SECTION) &&
line.containsToken(Constants.EXEC_SQL_TOKEN) &&
(line.containsToken(Constants.INCLUDE)
|| reader.peekNextMeaningfulLine().containsToken(Constants.INCLUDE))) {
extractedCopyBook = lineRepository.addExpandedCopyDB2Statements(reader.readStatementAsOneLine());
for (int i = 0; i < extractedCopyBook.size(); i++) {
CobolLine cobolLine = new CobolLine(extractedCopyBook.get(i), tokenExtractor);
List<CobolLine> currentStatement = new ArrayList<>();
currentStatement.add(cobolLine);
this.currentDataStructure = updateCurrentDataStructure(currentStatement, currentDataStructure);
updateNumericFields(cobolLine);
Platform platform = PlatformLookup.get();
switch(platform){
case ZOS:
if (line.containsToken("SQLCA") || line.containsToken("SQLDA"))
return;
default:
extractedCopyBook = lineRepository.addExpandedCopyDB2Statements(reader.readStatementAsOneLine());
for (int i = 0; i < extractedCopyBook.size(); i++) {
CobolLine cobolLine = new CobolLine(extractedCopyBook.get(i), tokenExtractor);
List<CobolLine> currentStatement = new ArrayList<>();
currentStatement.add(cobolLine);
this.currentDataStructure = updateCurrentDataStructure(currentStatement, currentDataStructure);
updateNumericFields(cobolLine);
}
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ public Formatter(DataTransferObjectStyle dataTransferObjectStyle){
*/
public void parseText(String text, String testSuitePackage){
String[] lines = text.split(Constants.NEWLINE);

for (String line : lines){
if (line.trim().isEmpty() || line.startsWith("==="))
continue;


//Getting Test Suite name
if (line.trim().equalsIgnoreCase(testSuiteKeyword))
expectTestSuiteName = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ int launchProgram(ProcessLauncher launcher, String programPath,
int launchProgram(ProcessLauncher launcher, String programPath) throws InterruptedException {
if (launcher == null) return -1;
Process process = launcher.run(programPath);

int exitCode = 1;
exitCode = process.waitFor();
return exitCode;
return exitCode;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void runTestProgram(String programName, boolean isLastRun) throws Interru
int exitCode = launcher.launchProgram(pLauncher, PathHelper.getTestSourceOutPath(), (proc) ->
processOutputWriter.writeProcessOutputToTestResultsFile(proc, Config.getTestResultFormat(),
Config.getTestResultFormatStyle(), programName, true, isLastRun));

if (processOutputWriter.writeWasSuccesful){
Log.info(Messages.get("INF011", processName, processOutputWriter.getTestResultsFilePath()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,76 @@ public void writeProcessOutputToTestResultsFile(Process proc, TestOutputFormat f
}

private void getProcessOut(Process proc) {
BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
processInput = "";
processError = "";

try{
String s = null;
while ((s = stdInput.readLine()) != null){
if (s != null)
processInput += s + Constants.NEWLINE;
StringBuilder processErrorBuilder = new StringBuilder();
final Object lock = new Object(); // For synchronizing access if necessary

Thread inputThread = new Thread(() -> {
Reader reader = new InputStreamReader(proc.getInputStream());
int maxBytesToReadFromCobolCheck = 25000;
char tempReadBuffer[] = new char[maxBytesToReadFromCobolCheck];
int writeOffset = 0;
int numberOfCharsRead = 0;
char cobolCheckOutput[] = null;
try {
synchronized (lock) {
numberOfCharsRead = reader.read(tempReadBuffer, writeOffset, maxBytesToReadFromCobolCheck);
if(numberOfCharsRead > 0) {
if(numberOfCharsRead == maxBytesToReadFromCobolCheck) {
int largeMaxBytesToReadFromCobolCheck = 100000;
char largeTempReadBuffer[] = new char[maxBytesToReadFromCobolCheck + largeMaxBytesToReadFromCobolCheck];
System.arraycopy(tempReadBuffer, 0, largeTempReadBuffer, 0, tempReadBuffer.length);
int largeNumberOfCharsRead = reader.read(largeTempReadBuffer, tempReadBuffer.length, largeMaxBytesToReadFromCobolCheck);
numberOfCharsRead += largeNumberOfCharsRead;
cobolCheckOutput = new char[numberOfCharsRead];
System.arraycopy(largeTempReadBuffer, 0, cobolCheckOutput, 0, numberOfCharsRead);
}
else {
cobolCheckOutput = new char[numberOfCharsRead];
System.arraycopy(tempReadBuffer, 0, cobolCheckOutput, 0, numberOfCharsRead);
}
}
reader.close();
}
} catch (IOException e) {
Log.warn(Messages.get("WRN007"));
}

while ((s = stdError.readLine()) != null){
if (s != null)
processError += s + Constants.NEWLINE;
processInput = "";
for (int i = 0; i < numberOfCharsRead; i++) {
processInput += cobolCheckOutput[i];
}
});

Thread errorThread = new Thread(() -> {
try (BufferedReader stdError = new BufferedReader(new InputStreamReader(proc.getErrorStream()))) {
String s;
while ((s = stdError.readLine()) != null) {
synchronized (lock) {
processErrorBuilder.append(s).append(Constants.NEWLINE);
}
}
} catch (IOException e) {
Log.warn(Messages.get("WRN007"));
}
//Remove extra NEWLINE:
processInput = StringHelper.removeLastIndex(processInput);
processError = StringHelper.removeLastIndex(processError);
});

stdInput.close();
stdError.close();
}
catch (IOException ex)
{
Log.warn(Messages.get("WRN007"));
inputThread.start();
errorThread.start();

// Wait for both threads to finish
try {
inputThread.join();
errorThread.join();
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // Restore interrupted status
Log.warn(Messages.get("WRN009"));
}

// Convert StringBuilder to String, removing the last NEWLINE if necessary
processInput = StringHelper.removeLastIndex(processInput.toString());
processError = StringHelper.removeLastIndex(processErrorBuilder.toString());
}


private void writeOutPutToConsole() {
System.out.println(processInput);
System.out.println(processError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ static List<String> generateSectionLines(String identifier, List<String> comment
lines.add(String.format(SECTION_HEADER_FORMAT, identifier));
if (commentLines != null)
lines.addAll(commentLines);
if (bodyLines != null)
if (bodyLines != null) {
lines.addAll(bodyLines);
lines.add(ENDING_PERIOD);
// Check if the last line in bodyLines ends with a period
if (!bodyLines.get(bodyLines.size() - 1).endsWith(".")) {
lines.add(ENDING_PERIOD);
}
} else {
// If bodyLines is null, add ENDING_PERIOD
lines.add(ENDING_PERIOD);
}
return lines;
}

Expand All @@ -32,9 +39,16 @@ static List<String> generateParagraphLines(String identifier, List<String> comme
lines.add(String.format(PARAGRAPH_HEADER_FORMAT, identifier));
if (commentLines != null)
lines.addAll(commentLines);
if (bodyLines != null)
if (bodyLines != null) {
lines.addAll(bodyLines);
lines.add(ENDING_PERIOD);
// Check if the last line in bodyLines ends with a period
if (!bodyLines.get(bodyLines.size() - 1).endsWith(".")) {
lines.add(ENDING_PERIOD);
}
} else {
// If bodyLines is null, add ENDING_PERIOD
lines.add(ENDING_PERIOD);
}
return lines;
}

Expand Down Expand Up @@ -75,17 +89,28 @@ static void addStartAndEndTags(List<String> lines){
lines.add(getInjectEndTagComment());
}

static List<String> generateWhenOtherLines(String identifier, String type, List<String> commentLines, List<String> bodyLines){
static List<String> generateWhenOtherLines(String identifier, String type, List<String> commentLines, List<String> bodyLines) {
List<String> lines = new ArrayList<>();
if(type.equals(Constants.SECTION_TOKEN))
if (type.equals(Constants.SECTION_TOKEN))
lines.add(String.format(WHEN_OTHER_SECTION_HEADER_FORMAT, identifier));
else lines.add(String.format(PARAGRAPH_HEADER_FORMAT, identifier));
else
lines.add(String.format(PARAGRAPH_HEADER_FORMAT, identifier));

if (commentLines != null)
lines.addAll(commentLines);
if (bodyLines != null)

if (bodyLines != null) {
lines.addAll(bodyLines);
lines.add(ENDING_PERIOD);
// Check if the last line in bodyLines ends with a period
if (!bodyLines.get(bodyLines.size() - 1).endsWith(".")) {
lines.add(ENDING_PERIOD);
}
} else {
// If bodyLines is null, add ENDING_PERIOD
lines.add(ENDING_PERIOD);
}
return lines;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.openmainframeproject.cobolcheck.features.interpreter.Area;
import org.openmainframeproject.cobolcheck.features.interpreter.State;
import org.openmainframeproject.cobolcheck.services.Constants;
import org.openmainframeproject.cobolcheck.services.platform.Platform;
import org.openmainframeproject.cobolcheck.services.platform.PlatformLookup;

import java.util.*;

Expand Down Expand Up @@ -271,13 +273,23 @@ public static boolean shouldLineBeParsed(CobolLine line, State state) {
public static boolean shouldLineBeStubbed(CobolLine line, State state) {
if (state.isFlagSetFor(Constants.PROCEDURE_DIVISION)) {
if (checkForBatchFileIOStatement(line) || line.containsToken(Constants.CALL_TOKEN) ||
line.containsToken(Constants.EXEC_SQL_TOKEN) || line.containsToken(Constants.EXEC_CICS_TOKEN)) {
line.containsToken(Constants.EXEC_SQL_TOKEN) || line.containsToken(Constants.EXEC_CICS_TOKEN) || line.containsToken(Constants.END_EXEC_TOKEN)) {
return true;
}
}
if (state.isFlagSetFor(Constants.WORKING_STORAGE_SECTION)) {
if (line.containsToken(Constants.EXEC_SQL_TOKEN) || line.containsToken(Constants.INCLUDE) || line.containsToken(Constants.END_EXEC_TOKEN))
return true;
if (line.containsToken(Constants.EXEC_SQL_TOKEN) || line.containsToken(Constants.INCLUDE) || line.containsToken(Constants.END_EXEC_TOKEN)) {
Platform platform = PlatformLookup.get();
switch(platform){
case ZOS:
if(line.containsToken(Constants.INCLUDE))
return false;
else
return true;
default:
return true;
}
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ WRN005 = WRN005: Test results input file not found: %1$s. Define in config as te
WRN006 = WRN006: IOException writing test results to file: %1$s in ProcessOutputWriter.writeProcessOutputToFile(...)
WRN007 = WRN007: IOException reading test results from current process
WRN008 = WRN008: Access denied: Could not change permissions for %1$s
WRN009 = WRN009: InterruptedException during reading processInput and processError

INF001 = INF001: Attempting to load config from %1$s.
INF002 = INF002: Loaded config successfully from %1$s.
Expand Down
Loading
Loading