Skip to content

Commit

Permalink
Unify test execution steps
Browse files Browse the repository at this point in the history
Turns out xunit _can_ run tests on Mono, you just have to install
an additional package to work around a vstest bug.

See microsoft/vstest#2469
  • Loading branch information
mhutch committed Oct 4, 2022
1 parent 132448a commit 1dbe2d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,14 @@ jobs:
- name: Test
run: dotnet test --no-build -c ${{ matrix.config }}

- name: Test (Windows)
if: startsWith (matrix.os, 'windows')
run: dotnet test -c ${{ matrix.config }} --no-build
# run: dotnet test -c ${{ matrix.config }} --no-build --blame-hang-timeout 5m --diag TestResults-${{ matrix.config }}-${{ matrix.os }}/Log/test_log.txt --logger trx --results-directory TestResults-${{ matrix.config }}-${{ matrix.os }}

# - name: Test diagnostics
# if: failure() && startsWith (matrix.os, 'windows')
# uses: actions/upload-artifact@v2
# with:
# name: test-results-${{ matrix.config }}-${{ matrix.os }}
# path: TestResults-${{ matrix.config }}-${{ matrix.os }}

# dotnet test doesn't support mono so we have to use the xunit console runner
- name: Set up NuGet
if: startsWith (matrix.os, 'windows') == false
uses: nuget/setup-nuget@v1

- name: Test (Linux/Mac)
if: startsWith (matrix.os, 'windows') == false
run: |
nuget install xunit.runner.console -Version 2.4.2 -OutputDirectory testrunner
mono ./testrunner/xunit.runner.console.2.4.2/tools/net472/xunit.console.exe ./Mono.TextTemplating.Tests/bin/${{ matrix.config }}/net472/Mono.TextTemplating.Tests.dll -parallel none -noshadow
dotnet test -c ${{ matrix.config }} --no-build -f netcoreapp2.1
dotnet test -c ${{ matrix.config }} --no-build -f netcoreapp3.1
dotnet test -c ${{ matrix.config }} --no-build -f net5.0
- uses: actions/upload-artifact@v3
if: matrix.config == 'Release' && startsWith(matrix.os, 'windows')
with:
Expand Down
13 changes: 10 additions & 3 deletions Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@
<DefineConstants Condition="'$(TargetFramework)'=='net472'">$(DefineConstants);FEATURE_APPDOMAINS</DefineConstants>
<DefaultItemExcludes>$(DefaultItemExcludes);TestCases\**</DefaultItemExcludes>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Mono.TextTemplating\Mono.TextTemplating.csproj" />
<ProjectReference Include="..\Mono.TextTemplating.Roslyn\Mono.TextTemplating.Roslyn.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<!-- fix conflicts in indirect references -->
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<!-- newer versions drop netcoreapp2.1 -->
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<!-- seems to be required for tests to run on Mono -->
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.3.2" Condition="'$(TargetFramework)'=='net472' And $([MSBuild]::IsOSUnixLike())" />
</ItemGroup>

<ItemGroup>
<None Include="TestCases\**\*.*" CopyToOutputDirectory="PreserveNewest" />
<!-- disable parallel test execution on github actions, it hangs the runner there -->
Expand Down

0 comments on commit 1dbe2d9

Please sign in to comment.