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

WI #1282 An empty dependency folder should not stop the generation #1322

Merged
merged 1 commit into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 35 additions & 1 deletion CLI/test/CLITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,23 @@ public void TestDependencies() {
CLITestHelper.ReadConsole("dependencies_4", ReturnCode.DependenciesError); //No dependencies found
CLITestHelper.Test("dependencies_5", ReturnCode.Success);
CLITestHelper.Test("dependencies_6", ReturnCode.Success);
CLITestHelper.Test("dependency_with_copy_loading", ReturnCode.Success);
CLITestHelper.Test("dependency_with_copy_loading", ReturnCode.Success);
#if EUROINFO_RULES
CLITestHelper.Test("ei_dependencies_1", ReturnCode.ParsingDiagnostics);
#endif
}

[TestMethod]
public void TestEmptyDependency()
{
var testFolderName = "empty_dependency_folder";
Directory.CreateDirectory("ressources" + Path.DirectorySeparatorChar + testFolderName + Path.DirectorySeparatorChar + "emptyFolder");

CLITestHelper.ReadConsoleWarnings(testFolderName, ReturnCode.Success);
}



/// <summary>
/// Test that even with a execToStep>Preprocessor, then the parsing will halt on preprocessor phase because copy are missing
/// </summary>
Expand Down Expand Up @@ -218,6 +229,29 @@ internal static void ReadConsole(string testFolderName, ReturnCode expectedRetur
Environment.NewLine, standardOutput, expectedoutput, Environment.NewLine, standardOutput.Length, expectedoutput.Length));
}

internal static void ReadConsoleWarnings(string testFolderName, ReturnCode expectedReturnCode)
{
var workingDirectory = "ressources" + Path.DirectorySeparatorChar + testFolderName;
string arguments = File.ReadAllText(workingDirectory + Path.DirectorySeparatorChar + "CLIArguments.txt");
string standardOutput = Test(workingDirectory, arguments, expectedReturnCode).Trim();
string warnings = string.Empty;

foreach (string line in standardOutput.Split(new string[] { "\r\n" }, StringSplitOptions.None))
{
if (line.StartsWith("Line"))
warnings += line + "\r\n";
}

warnings = warnings.Trim();
string expectedoutput = File.ReadAllText(workingDirectory + Path.DirectorySeparatorChar + "ExpectedConsole.txt").Trim();
if (!string.Equals(warnings, expectedoutput, StringComparison.CurrentCultureIgnoreCase))
throw new Exception(string.Format("console outputs not equals.{0}" +
"Console: {4}{0}{1}{0}" +
"Expected: {5}{0}{2}{0}" +
"{3}",
Environment.NewLine, warnings, expectedoutput, Environment.NewLine, warnings.Length, expectedoutput.Length));
}

/// <summary>
/// Use the folder ressources\[testFolderName]
/// Run command TypeCobol.CLI with the content of CLIArguments.txt as arguments
Expand Down
2 changes: 1 addition & 1 deletion CLI/test/ressources/arguments_errors_1/ExpectedConsole.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Code: 1022 TypeCobol.CLI.exe: Error diagnostics path is unreachable.
Code: 1024 TypeCobol.CLI.exe: Missing copy path given is unreachable.
Code: 1027 TypeCobol.CLI.exe: Intrinsic files given are unreachable.
Code: 1028 TypeCobol.CLI.exe: Copies files given are unreachable.
Code: 1029 TypeCobol.CLI.exe: Dependencies files given are unreachable.
Code: 1029 TypeCobol.CLI.exe: Dependencies files given are unreachable: input\MissingDependencies1
Code: 1030 TypeCobol.CLI.exe: Maximum diagnostics have to be an integer.
Code: 1031 TypeCobol.CLI.exe: Unexpected parameter given for Output format option. Accepted parameters are Cobol85/0(default), PublicSignature/1.
Code: 1032 TypeCobol.CLI.exe: Expanding copy path given is unreachable.
Expand Down
2 changes: 1 addition & 1 deletion CLI/test/ressources/dependencies_4/ExpectedConsole.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Code: 1029 TypeCobol.CLI.exe: Dependencies files given are unreachable.
Code: 1029 TypeCobol.CLI.exe: Dependencies files given are unreachable: input\DoesntExists.rdz.tcbl
Try TypeCobol.CLI.exe --help for usage information.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1 -i input\PGM3.rdz.tcbl -o output\PGM3.rdz.tcbl -d output\error.txt --dependencies emptyFolder\ -s ..\skeletons.xml -e rdz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Line 1[1,1] <35, Warning, Semantics> - Error while parsing dependency file: emptyFolder\, no dependencies found
13 changes: 13 additions & 0 deletions CLI/test/ressources/empty_dependency_folder/input/PGM3.rdz.tcbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
 IDENTIFICATION DIVISION.
PROGRAM-ID. PGM3.

DATA DIVISION.
Working-STORAGE SECTION.

01 somedate TYPE Date.
01 msg PIC X(80).

PROCEDURE DIVISION.
GOBACK.

END PROGRAM PGM3.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
 *TypeCobol_Version:0.1(alpha)
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM3.

DATA DIVISION.
Working-STORAGE SECTION.

*01 somedate TYPE Date.
01 somedate.
02 YYYY PIC 9(4).
02 MM PIC 9(2).
02 DD PIC 9(2).

01 msg PIC X(80).

PROCEDURE DIVISION.
GOBACK.

END PROGRAM PGM3.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ReturnCode=Success_
No error in "input\PGM3.rdz.tcbl".
20 changes: 17 additions & 3 deletions TypeCobol/Tools/Options-Config/TypeCobolConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public bool IsErrorXML
{ ReturnCode.EncodingError, "Unexpected parameter given for encoding option. Accepted parameters are \"rdz\"(default), \"zos\", \"utf8\"." },
{ ReturnCode.IntrinsicError, "Intrinsic files given are unreachable." },
{ ReturnCode.CopiesError, "Copies files given are unreachable." },
{ ReturnCode.DependenciesError, "Dependencies files given are unreachable." },
{ ReturnCode.DependenciesError, "Dependencies files given are unreachable: " },
{ ReturnCode.MaxDiagnosticsError, "Maximum diagnostics have to be an integer." },
{ ReturnCode.OutputFormatError, "Unexpected parameter given for Output format option. Accepted parameters are Cobol85/0(default), PublicSignature/1." },
{ ReturnCode.ExpandingCopyError, "Expanding copy path given is unreachable." },
Expand Down Expand Up @@ -256,8 +256,22 @@ public static Dictionary<ReturnCode, string> InitializeCobolOptions(TypeCobolCon
//CopiesError
VerifFiles(config.CopyFolders, ReturnCode.CopiesError, ref errorStack, true);

//DependenciesError
VerifFiles(config.Dependencies, ReturnCode.DependenciesError, ref errorStack);
////DependencyFolderMissing
if (config.ExecToStep == ExecutionStep.Generate && !errorStack.ContainsKey(ReturnCode.ExecToStepError))
{
foreach (string dependency in config.Dependencies)
{
string directory = Path.GetDirectoryName(dependency);
string file = Path.GetFileName(dependency);

if (file?.Contains("*") == true)
file = string.Empty;

if ((!Directory.Exists(directory) || !file.IsNullOrEmpty() && !File.Exists(dependency)) && !errorStack.ContainsKey(ReturnCode.DependenciesError))
errorStack.Add(ReturnCode.DependenciesError, TypeCobolConfiguration.ErrorMessages[ReturnCode.DependenciesError] + directory + Path.DirectorySeparatorChar + file);

}
}

// MaxDiagnosticsError
if (!config.RawMaximumDiagnostics.IsNullOrEmpty())
Expand Down