tcunit / TcUnit-Runner

Program that makes it possible to automate runs of TcUnit unit tests
Other
34 stars 17 forks source link

TcUnit-Runner fail to find TwinCAT project given a more complex solution structure #49

Closed ahuca closed 9 months ago

ahuca commented 10 months ago

TcUnit-Runner does not support more complex solution structure When a solution has more than one child item under it, the function FindTwinCATProjectFile may fail to find a TwinCAT project file if a non-TwinCAT-project item is listed at the top in the solution file.

To Reproduce Consider the following solution structure,

├── Example.sln
│   ├── Solution Items
│   │   ├── Example.libcat.xml
│   ├── Example (XAE Solution)

Given this, the content of the Example.sln could be, for example,

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.33403.129
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{986D592B-6B07-4D9C-9910-4D3A5BBDD0A3}"
    ProjectSection(SolutionItems) = preProject
        Example.libcat.xml = Example.libcat.xml
    EndProjectSection
EndProject
Project("{B1E792BE-AA5F-4E3C-8C82-674BF9C0715B}") = "Examle", "Example\Example.tsproj", "{D6956552-7530-4208-832D-7CACFFFF6BE4}"
EndProject

In this scenario, FindTwinCATProjectFile will stop parsing at the first Project entry and mistakenly assume that it is an entry of a TwinCAT project. It then returns an empty string and TcUnit-Runner error out with this message,

Did not find TwinCAT project file in solution. Is this a TwinCAT project?

Expected behaviour The program should parse the solution file differently to get the right TwinCAT project. It should iterate through all Project entries in the solution file and return the first TwinCAT project entry it finds, or an empty string if it doesn't find any at all. Within the solution file, the EndProject, used after each Project, should help with parsing by limiting the scope of each Project entry.

Software versions TcUnit-Runner v0.9.3.0.

Run environment Not applicable.

Additional context Not applicable.