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 #2674 Adapt unit tests to run on Linux #2690

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5d6b91c
WI #2684 Fix some unit test errors
fm-117 Dec 5, 2024
32fc3fe
WI #2684 Use unified line comparison method
fm-117 Dec 5, 2024
5452201
WI #2684 Fix documentation tests
fm-117 Dec 6, 2024
b475b3e
WI #2684 Fix file name case - part1
fm-117 Dec 12, 2024
1095e70
WI #2684 Fix file name case - part2
fm-117 Dec 12, 2024
58d55e3
WI #2684 Normalize line ending translation when generating dot files
fm-117 Dec 12, 2024
38d8efc
WI #2684 Fix test paths
fm-117 Dec 12, 2024
8972f9f
WI #2684 Avoid generating newlines in CFG/DFA notification
fm-117 Dec 13, 2024
a1f6d2a
WI #2684 Fix refactoring processor test when reading test data file
fm-117 Dec 13, 2024
4c29961
WI #2684 Duplicate LSR tests for AdjustFillers depending on platform
fm-117 Dec 13, 2024
b83f7e4
WI #2684 Remove newlines from hover tooltips
fm-117 Dec 17, 2024
ae56bec
WI #2684 Disable file watchers for LSR tests
fm-117 Dec 23, 2024
26ce14d
WI #2684 Fix local directory library file enumeration
fm-117 Dec 23, 2024
5b037b9
WI #2684 Fix inserted node position in Codegen
fm-117 Dec 24, 2024
237a5ff
WI #2684 Fix case in LSR test folder name
fm-117 Dec 24, 2024
e11829b
WI #2684 Force file order when testing multiple files at once
fm-117 Dec 30, 2024
ba14890
WI #2684 Add matrix strategy to build on multiple OSes
fm-117 Dec 30, 2024
36bfc5e
WI #2684 Fix slashes in workflow file
fm-117 Dec 30, 2024
7a430d3
Merge branch 'develop' into 2684-ignore-carriage-return-character-whe…
fm-117 Dec 30, 2024
cc693b9
WI #2684 Fix code after merge
fm-117 Dec 30, 2024
2256544
WI #2684 Simplify Antlr4 references
fm-117 Dec 31, 2024
08e72ac
WI #2674 Introduce NodePositions record class to improve readability …
fm-117 Jan 3, 2025
4b33340
Merge branch 'develop' into 2684-ignore-carriage-return-character-whe…
fm-117 Jan 6, 2025
df4ef58
WI #2684 Code review
fm-117 Jan 6, 2025
5748497
WI #2684 Use \n line break in Linux-specific tests
fm-117 Jan 6, 2025
a6c3239
WI #2684 Improve comments for CFG DOT file generator
fm-117 Jan 6, 2025
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
13 changes: 8 additions & 5 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ on:

jobs:
build:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]

runs-on: windows-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
Expand All @@ -22,10 +25,10 @@ jobs:
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore .\TypeCobol.sln
run: dotnet restore ./TypeCobol.sln
- name: Build CSCup
run: dotnet build .\CSCup\CSCup.csproj --no-restore --configuration ${{ inputs.build-configuration }}
run: dotnet build ./CSCup/CSCup.csproj --no-restore --configuration ${{ inputs.build-configuration }}
- name: Build solution
run: dotnet build .\TypeCobol.sln --no-restore --configuration ${{ inputs.build-configuration }}
run: dotnet build ./TypeCobol.sln --no-restore --configuration ${{ inputs.build-configuration }}
- name: Test
run: dotnet test .\TypeCobol.sln --no-build --verbosity normal --configuration ${{ inputs.build-configuration }}
run: dotnet test ./TypeCobol.sln --no-build --verbosity normal --configuration ${{ inputs.build-configuration }}
4 changes: 2 additions & 2 deletions CLI/test/CLITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ internal static void ReadConsoleWarnings(string testFolderName, ReturnCode expec
string standardOutput = Test(workingDirectory, arguments, expectedReturnCode).Trim();
string warnings = string.Empty;

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

warnings = warnings.Trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* YPRTD20
* YCONVEA
* ).


DATA DIVISION.
Working-STORAGE SECTION.
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 @@ -5,7 +5,7 @@ Code: 124 TypeCobol.CLI: Missing copy path given is unreachable.
Code: 126 TypeCobol.CLI: The format 'BadFormat' is not supported. The input encoding 'BadInputEncoding' could not be found.
Code: 127 TypeCobol.CLI: Intrinsic files given are unreachable.
Code: 128 TypeCobol.CLI: Copies files given are unreachable.
Code: 129 TypeCobol.CLI: Dependencies files given are unreachable: input\MissingDependencies1
Code: 129 TypeCobol.CLI: Dependencies files given are unreachable: input/MissingDependencies1
Code: 130 TypeCobol.CLI: Maximum diagnostics have to be an integer.
Code: 131 TypeCobol.CLI: Unexpected parameter given for Output format option. Accepted parameters are Cobol85/0(default), PublicSignature/1.
Code: 132 TypeCobol.CLI: 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: 129 TypeCobol.CLI: Dependencies files given are unreachable: input\DoesntExists.rdz.tcbl
Code: 129 TypeCobol.CLI: Dependencies files given are unreachable: input/DoesntExists.rdz.tcbl
Try TypeCobol.CLI --help for usage information.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Documentations":[{"__type":"DocumentationForProgram:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"My program \r\ndescription ","Name":"DocGen","Namespace":"DocGen","Needs":["some needs","description"],"ReplacedBy":"MyFonction2 ","Restriction":"Do not Use BOOL var ","See":"Thank you for your attention ","ToDos":["Add BOOL support","implement a call counter"]},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"inline typedef ","Name":"myType","Namespace":"DocGen","Restriction":"Do not Use BOOL var ","Visibility":1,"DocDataType":{"MaxOccurence":1,"Picture":"X(01)"}},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Description":"Vect2D ","Name":"Vect2D","Namespace":"DocGen","Visibility":1,"Childrens":[{"Childrens":[{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"X"},{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"Y"}],"DocDataType":{"MaxOccurence":1},"Name":"Coord2d"}],"DocDataType":{"MaxOccurence":1}},{"__type":"DocumentationForFunction:#TypeCobol.Compiler.Nodes","Deprecated":"It is deprecated ","Description":"MyProc info \r\n","Name":"MyProc","Namespace":"DocGen","Needs":["long need"],"ToDos":["todo1","todo 2"],"Visibility":1,"Parameters":[{"DocDataType":{"MaxOccurence":1,"TypeName":"DATE"},"Info":"just a date","Name":"myDate","PassingType":0},{"DocDataType":{"MaxOccurence":1,"Picture":"S9(1)V9(12)"},"Info":"bla < 2","Name":"bla","PassingType":0},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Name":"myBool","PassingType":2},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Info":"toto","Name":"toto","PassingType":1},{"DocDataType":{"MaxOccurence":1,"Picture":"PPP999PPP"},"Name":"bli","PassingType":1}]}],"TypeCobolVersion":"[[ParserVersion]]"}
{"Documentations":[{"__type":"DocumentationForProgram:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"My program description","Name":"DocGen","Namespace":"DocGen","Needs":["some needs","description"],"ReplacedBy":"MyFonction2","Restriction":"Do not Use BOOL var","See":"Thank you for your attention","ToDos":["Add BOOL support","implement a call counter"]},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Deprecated":"","Description":"inline typedef","Name":"myType","Namespace":"DocGen","Restriction":"Do not Use BOOL var","Visibility":1,"DocDataType":{"MaxOccurence":1,"Picture":"X(01)"}},{"__type":"DocumentationForType:#TypeCobol.Compiler.Nodes","Description":"Vect2D","Name":"Vect2D","Namespace":"DocGen","Visibility":1,"Childrens":[{"Childrens":[{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"X"},{"DocDataType":{"MaxOccurence":1,"Picture":"9(4)"},"Name":"Y"}],"DocDataType":{"MaxOccurence":1},"Name":"Coord2d"}],"DocDataType":{"MaxOccurence":1}},{"__type":"DocumentationForFunction:#TypeCobol.Compiler.Nodes","Deprecated":"It is deprecated","Description":"MyProc info","Name":"MyProc","Namespace":"DocGen","Needs":["long need"],"ToDos":["todo1","todo 2"],"Visibility":1,"Parameters":[{"DocDataType":{"MaxOccurence":1,"TypeName":"DATE"},"Info":"just a date","Name":"myDate","PassingType":0},{"DocDataType":{"MaxOccurence":1,"Picture":"S9(1)V9(12)"},"Info":"bla < 2","Name":"bla","PassingType":0},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Name":"myBool","PassingType":2},{"DocDataType":{"MaxOccurence":1,"TypeName":"BOOL"},"Info":"toto","Name":"toto","PassingType":1},{"DocDataType":{"MaxOccurence":1,"Picture":"PPP999PPP"},"Name":"bli","PassingType":1}]}],"TypeCobolVersion":"[[ParserVersion]]"}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. STACKED.
DATA DIVISION.

WORKING-STORAGE SECTION.
01 TC-STACKED-FctList-Loaded PIC X(02) VALUE space.
88 TC-STACKED-FctList-IsLoaded VALUE 'OK'.
Expand All @@ -113,7 +113,7 @@
05 TC-STACKED-b4a83777-Idt PIC X(08) VALUE 'b4a83777'.
05 TC-STACKED-b4a83777 PROCEDURE-POINTER.


LINKAGE SECTION.
01 PntTab-Pnt POINTER.
01 TC-A1 PIC X.
Expand Down Expand Up @@ -161,7 +161,7 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. STACKED2.
DATA DIVISION.

WORKING-STORAGE SECTION.
01 TC-STACKED2-FctList-Loaded PIC X(02) VALUE space.
88 TC-STACKED2-FctList-IsLoaded VALUE 'OK'.
Expand All @@ -174,7 +174,7 @@
05 TC-STACKED2-f22bfcb0-Idt PIC X(08) VALUE 'f22bfcb0'.
05 TC-STACKED2-f22bfcb0 PROCEDURE-POINTER.


LINKAGE SECTION.
01 PntTab-Pnt POINTER.
01 TC-A1 PIC X.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. PGM2.
DATA DIVISION.

WORKING-STORAGE SECTION.
01 TC-PGM2-FctList-Loaded PIC X(02) VALUE space.
88 TC-PGM2-FctList-IsLoaded VALUE 'OK'.
Expand All @@ -15,7 +15,7 @@
05 TC-PGM2-a4ee502d-Idt PIC X(08) VALUE 'a4ee502d'.
05 TC-PGM2-a4ee502d PROCEDURE-POINTER.


LINKAGE SECTION.
01 PntTab-Pnt POINTER.
01 TC-A1 PIC X.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*REMARKS. COPY=(
* TESTCPY
* ).

data division.
working-storage section.
*01 MyType typedef strict public.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* XMYCOPY
* YMYCOPY1
* ).


ENVIRONMENT DIVISION.
DATA DIVISION.
Expand Down
19 changes: 8 additions & 11 deletions Codegen/src/Actions/Qualifier.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using TypeCobol.Codegen.Nodes;
using TypeCobol.Codegen.Nodes;
using TypeCobol.Compiler.CodeElements;
using TypeCobol.Compiler.CodeModel;
using TypeCobol.Compiler.Nodes;
Expand Down Expand Up @@ -112,7 +109,7 @@ public override bool Visit(StorageArea storageArea)
{
if (this.CurrentNode.IsFlagSet(Node.Flag.NodeContainsIndex) || this.CurrentNode.IsFlagSet(Node.Flag.NodeContainsBoolean))
{
Tuple<int, int, int, List<int>, List<int>> sourcePositions = this.Generator.FromToPositions(this.CurrentNode);
NodePositions sourcePositions = this.Generator.FromToPositions(this.CurrentNode);
foreach (TypeCobol.Compiler.CodeElements.StorageArea storage_area in this.CurrentNode.QualifiedStorageAreas.Keys)
{
if (this.CurrentNode.IsFlagSet(Node.Flag.NodeContainsIndex))
Expand All @@ -130,7 +127,7 @@ public override bool Visit(StorageArea storageArea)
return true;
}

private void QualifiedStorageAreaSelecterForBoolean(StorageArea storage_area, Tuple<int, int, int, List<int>, List<int>> sourcePositions)
private void QualifiedStorageAreaSelecterForBoolean(StorageArea storage_area, NodePositions sourcePositions)
{
if (UsedStorageArea != null && UsedStorageArea.Contains(storage_area))
return;
Expand All @@ -147,7 +144,7 @@ private void QualifiedStorageAreaSelecterForBoolean(StorageArea storage_area, Tu
UsedStorageArea.Add(storage_area);
}

private void QualifiedStorageAreaSelecterForIndexes(StorageArea storageArea, Tuple<int, int, int, List<int>, List<int>> sourcePositions)
private void QualifiedStorageAreaSelecterForIndexes(StorageArea storageArea, NodePositions sourcePositions)
{
if (storageArea.SymbolReference != null && !storageArea.SymbolReference.IsQualifiedReference)
{
Expand Down Expand Up @@ -257,7 +254,7 @@ public override bool Visit(IndexDefinition indexDefinition)
{
if (index.Name.Equals(indexDefinition.Name))
{
Tuple<int, int, int, List<int>, List<int>> sourcePositions = this.Generator.FromToPositions(indexDefinition.Parent);
NodePositions sourcePositions = this.Generator.FromToPositions(indexDefinition.Parent);
string qualified_name = indexDefinition.QualifiedName.ToString();
GenerateToken item = null;
string hashName = GeneratorHelper.ComputeIndexHashName(qualified_name, indexDefinition.Parent);
Expand Down Expand Up @@ -558,7 +555,7 @@ internal void Perform(Node sourceNode)

//Now this Node Is Visited
sourceNode.SetFlag(Node.Flag.HasBeenTypeCobolQualifierVisited, true);
Tuple<int, int, int, List<int>, List<int>> sourcePositions = this.Generator.FromToPositions(sourceNode);
NodePositions sourcePositions = this.Generator.FromToPositions(sourceNode);
IList<TypeCobol.Compiler.Scanner.Token> nodeTokens = sourceNode.CodeElement.ConsumedTokens;
List<Tuple<int, int>> boundaries = ItemsListIndexBoundary(nodeTokens);
int b = 0;
Expand Down Expand Up @@ -724,7 +721,7 @@ internal class GenerateToken : GenericNode<CodeElement>, GeneratedAndReplace
/// <param name="codelement">The Code element of this Node</param>
/// <param name="code">The replace code</param>
/// <param name="sourcePositions">The Positions of the Source Node</param>
public GenerateToken(CodeElement codelement, string code, Tuple<int, int, int, List<int>, List<int>> sourcePositions)
public GenerateToken(CodeElement codelement, string code, NodePositions sourcePositions)
: base(codelement)
{
ReplaceCode = code;
Expand All @@ -734,7 +731,7 @@ public GenerateToken(CodeElement codelement, string code, Tuple<int, int, int, L
/// <summary>
/// Source Node Positions
/// </summary>
public Tuple<int, int, int, List<int>, List<int>> SourceNodePositions
public NodePositions SourceNodePositions
{
get;
private set;
Expand Down
9 changes: 2 additions & 7 deletions Codegen/src/Codegen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Antlr4.Runtime" Version="4.6.6" />
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="TypeCobol.TemplateTask" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" PrivateAssets="all" />
<PackageReference Include="TypeCobol.TemplateTask" Version="1.3.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 12 additions & 12 deletions Codegen/src/Generator.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Diagnostics;
using TypeCobol.Codegen.Actions;
using TypeCobol.Codegen.Nodes;
using TypeCobol.Compiler;
Expand All @@ -17,6 +13,15 @@

namespace TypeCobol.Codegen
{
/// <summary>
/// Capture positions for actual or generated nodes.
/// </summary>
/// <param name="From">Start position of the node.</param>
/// <param name="To">End position of the node.</param>
/// <param name="Span">End offset of the node, this is the end column of the node on its last line.</param>
/// <param name="LineNumbers">List of line numbers the node spans across.</param>
public record NodePositions(int From, int To, int Span, List<int> LineNumbers);

/// <summary>
/// The Second Code Generator which can Handle correctly all preprocessor directives
/// during the Code Generation Phase.
Expand Down Expand Up @@ -149,7 +154,7 @@ public Generator(TypeCobol.Compiler.CompilationDocument document, StringBuilder
/// The method also calculate the ending span offset from the beginning of the last line.
/// It also get the list of Line numbers occupated by this node, and the offset of each line.
/// </summary>
public Tuple<int, int, int, List<int>, List<int>> FromToPositions(Node node)
public NodePositions FromToPositions(Node node)
{
if (node.CodeElement == null || node.CodeElement.ConsumedTokens == null || node is ParameterEntry)
return null;
Expand All @@ -161,7 +166,6 @@ public Tuple<int, int, int, List<int>, List<int>> FromToPositions(Node node)
int i = 0;
int span = 0;
List<int> lineNumbers = new List<int>();
List<int> lineOffsets = new List<int>();
SourceDocument.SourceLine srcFirstLine = null;
do
{
Expand All @@ -180,15 +184,12 @@ public Tuple<int, int, int, List<int>, List<int>> FromToPositions(Node node)
while (++lastLine < curLineIndex)
{
lineNumbers.Add(lastLine);
SourceDocument.SourceLine srcLine = TargetDocument[lastLine - 1];
if (srcFirstLine != null) lineOffsets.Add(srcLine.From - srcFirstLine.From);
}
}
SourceDocument.SourceLine curLine = TargetDocument[curLineIndex - 1];
if (srcFirstLine == null)
srcFirstLine = curLine;
lineNumbers.Add(curLineIndex);
lineOffsets.Add(curLine.From - srcFirstLine.From);
span = 0;
while ((i < node.CodeElement.ConsumedTokens.Count) && ((curLineIndex == node.CodeElement.ConsumedTokens[i].Line)
|| (node.CodeElement.ConsumedTokens[i] is TypeCobol.Compiler.Preprocessor.ImportedToken)))
Expand All @@ -209,8 +210,7 @@ public Tuple<int, int, int, List<int>, List<int>> FromToPositions(Node node)
}
} while (i < node.CodeElement.ConsumedTokens.Count);
lineNumbers.TrimExcess();
lineOffsets.TrimExcess();
return new Tuple<int, int, int, List<int>, List<int>>(from, to, span, lineNumbers, lineOffsets);
return new NodePositions(from, to, span, lineNumbers);
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Codegen/src/Generators/DefaultGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ protected SourceText LinearGeneration<A>(LinearNodeSourceCodeMapper mapper, Line
//Pad a splitted segment
if (mapper.Nodes[node_index].Positions != null)
{
int span = mapper.Nodes[node_index].Positions.Item3;
int span = mapper.Nodes[node_index].Positions.Span;
string pad = new string(' ', span);
curSourceText.Insert(pad, to.Pos, to.Pos);
}
Expand Down
Loading
Loading