uno icon indicating copy to clipboard operation
uno copied to clipboard

test: Added ability to run generators and get diagnostics

Open HavenDV opened this issue 3 years ago • 10 comments

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:

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):

HavenDV avatar Apr 11 '22 18:04 HavenDV

gitpod-io[bot] avatar Apr 11 '22 18:04 gitpod-io[bot]

/azp run

jeromelaban avatar Apr 13 '22 00:04 jeromelaban

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Apr 13 '22 00:04 azure-pipelines[bot]

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

HavenDV avatar Apr 29 '22 08:04 HavenDV

#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.

Youssef1313 avatar Apr 29 '22 08:04 Youssef1313

@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.

Youssef1313 avatar Apr 29 '22 08:04 Youssef1313

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.

jeromelaban avatar May 02 '22 12:05 jeromelaban

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?)

jeromelaban avatar May 05 '22 01:05 jeromelaban

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

HavenDV avatar May 05 '22 03:05 HavenDV

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.

jeromelaban avatar May 05 '22 12:05 jeromelaban