uno
uno copied to clipboard
test: Added ability to run generators and get diagnostics
Added ability to run generators and get diagnostics to Uno.UI.SourceGenerators.
GitHub Issue (If applicable): closes #6646
PR Type
What kind of change does this PR introduce?
Project automation
What is the current behavior?
Testing error cases for a generator is now difficult. In addition, the debugging of the generator is now bypassed via the MSBuild property.
What is the new behavior?
It will be possible to test both the absence of diagnostics and the presence of specific erroneous diagnostics. In addition, it will be easy to debug generators for specific cases.
PR Checklist
Please check if your PR fulfills the following requirements:
- [ ] Docs have been added/updated which fit documentation template (for bug fixes / features)
- [x] Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
- [ ] Validated PR
Screenshots Compare Test Runresults. - [x] Contains NO breaking changes
- [x] Associated with an issue (GitHub or internal) and uses the automatic close keywords.
- [x] Commits must be following the Conventional Commits specification.
Other information
At the moment, contain tests for the code that is in the PR. https://github.com/unoplatform/uno/pull/8507 https://github.com/unoplatform/uno/pull/8448
Internal Issue (If applicable):
/azp run
Azure Pipelines successfully started running 1 pipeline(s).
I want to note that this PR depends on this - https://github.com/unoplatform/uno/pull/8448 because the tests check for the absence of diagnostics for these changes The strange thing is that the CI builds are correctly completed in this case. These changes are either already included or the CI build does not take into account tests for net6.0
#8448 isn't yet merged. So it's definitely not included in this PR. If the tests are supposed to fail, then they might not be run in CI.
@HavenDV See https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/vstest?view=azure-devops#does-the-vstest-task-support-running-tests-that-target-multiple-target-frameworks-at-a-time
https://github.com/unoplatform/uno/blob/c383dd8a0d3fcd6316873a9d0d740c86292df172/build/ci/.azure-devops-unit-tests.yml#L53-L66
I'm not entirely sure the above is related, but maybe.
The tests are indeed not running.
I've made a small change to the project file, just in case there's a file name conflict, let's see what that does.
It looks like there are additional compilation errors:
src\SourceGenerators\Uno.UI.SourceGenerators.Tests\Given_SymbolExtension.cs(32,20): Error CS1061: 'INamedTypeSymbol' does not contain a definition for 'GetAllMembersWithName' and no accessible extension method 'GetAllMembersWithName' accepting a first argument of type 'INamedTypeSymbol' could be found (are you missing a using directive or an assembly reference?)
It looks like there are additional compilation errors:
I checked the latest changes and noticed that locally the build fails at the moment the dependencies are restored:
1>error NETSDK1005: Assets file 'C:\Users\haven\source\repos\HavenDV\uno\src\SourceGenerators\Uno.UI.SourceGenerators.Tests\obj\project.assets.json' doesn't have a target for 'net461'. Ensure that restore has run and that you have included 'net461' in the TargetFrameworks for your project.
1>error NETSDK1005: Assets file 'C:\Users\haven\source\repos\HavenDV\uno\src\SourceGenerators\Uno.UI.SourceGenerators.Tests\obj\project.assets.json' doesn't have a target for 'net6.0'. Ensure that restore has run and that you have included 'net6.0' in the TargetFrameworks for your project.
After removing these changes, then everything is fine
<AssemblyName>Uno.UI.SourceGenerators.Tests.$(TargetFramework)</AssemblyName>
Related issues: https://github.com/NuGet/Home/issues/6461 https://github.com/NuGet/Home/issues/5222
It still does not look like it's running the tests:
##[warning]DiscoveryMessage : [MSTest][Discovery][D:\a\1\s\src\SourceGenerators\Uno.UI.SourceGenerators.Tests\bin\Release\net6.0\Uno.UI.SourceGenerators.Tests.Net6.dll] Failed to discover tests from assembly D:\a\1\s\src\SourceGenerators\Uno.UI.SourceGenerators.Tests\bin\Release\net6.0\Uno.UI.SourceGenerators.Tests.Net6.dll. Reason:Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Could not find or load a type. (Exception from HRESULT: 0x80131522)
Let's see if using .NET 6 as the last installer changes anything.