Skip to content

Commit

Permalink
Add a workaround for xunit tests (#2787)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev authored Jan 28, 2022
1 parent cd3d57f commit 60c629e
Show file tree
Hide file tree
Showing 10 changed files with 490 additions and 125 deletions.
17 changes: 16 additions & 1 deletion .github/templates/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,27 @@ jobs:
if: matrix.targetFramework == 'net6.0'
with:
dotnet-version: '6.0.x'
include-prerelease: true
- #@ template.replace(dotnetPublishAndRunTests("Tests/Realm.Tests", "${{ matrix.targetFramework }}", "Realm.Tests --result=TestResults.xml --labels=After"))
- #@ publishTestsResults("TestResults.xml", ".NET (${{ matrix.os }}, ${{ matrix.targetFramework }})")
_: #@ template.replace(testJob("Xamarin.macOS", "macos-latest", xamarinMacTestSteps()))
_: #@ template.replace(testJob("Xamarin.iOS", "macos-latest", xamariniOSTestSteps()))
_: #@ template.replace(testJob("Xamarin.Android", "macos-latest", xamarinAndroidTestSteps()))
run-tests-xunit:
runs-on: windows-latest
name: Test xUnit Compatibility
timeout-minutes: #@ testTimeout
needs:
- build-packages
if: #@ ignoreSkippedJobsCondition + " && github.event_name != 'pull_request'"
steps:
- #@ template.replace(checkoutCode())
- #@ template.replace(fetchPackageArtifacts())
- uses: #@ actionSetupDotnet
with:
dotnet-version: '6.0.x'
- #@ template.replace(dotnetPublish("Tests/Tests.XUnit", "net6.0", { "RestoreConfigFile": "Tests/Test.NuGet.Config", "UseRealmNupkgsWithVersion": "${{ needs.build-packages.outputs.package_version }}" }))
- name: Run Tests
run: dotnet test ${{ steps.dotnet-publish.outputs.executable-path }}/Tests.XUnit.dll --logger GitHubActions
run-tests-weaver:
runs-on: windows-latest
name: Test Weaver
Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ jobs:
if: matrix.targetFramework == 'net6.0'
with:
dotnet-version: 6.0.x
include-prerelease: true
- name: Publish Tests/Realm.Tests
run: dotnet publish Tests/Realm.Tests -c Release -f ${{ matrix.targetFramework }} -r ${{ (runner.os == 'macOS' && 'osx-x64') || (runner.os == 'Windows' && 'win-x64') || (runner.os == 'Linux' && 'linux-x64') || '???' }} -p:AdditionalFrameworks=${{ matrix.targetFramework }} -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} --no-self-contained
- name: Output executable path
Expand Down Expand Up @@ -1285,6 +1284,43 @@ jobs:
apiKey: ${{ (contains(github.head_ref, 'release') && secrets.ATLAS_QA_PUBLIC_API_KEY) || secrets.ATLAS_PUBLIC_API_KEY }}
privateApiKey: ${{ (contains(github.head_ref, 'release') && secrets.ATLAS_QA_PRIVATE_API_KEY) || secrets.ATLAS_PRIVATE_API_KEY }}
differentiator: Xamarin.Android
run-tests-xunit:
runs-on: windows-latest
name: Test xUnit Compatibility
timeout-minutes: 45
needs:
- build-packages
if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.event_name != 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Register csc problem matcher
run: echo "::add-matcher::.github/problem-matchers/csc.json"
- name: Register msvc problem matcher
run: echo "::add-matcher::.github/problem-matchers/msvc.json"
- name: Fetch Realm
uses: actions/download-artifact@v2
with:
name: Realm.${{ needs.build-packages.outputs.package_version }}
path: ${{ github.workspace }}/Realm/packages/
- name: Fetch Realm.Fody
uses: actions/download-artifact@v2
with:
name: Realm.Fody.${{ needs.build-packages.outputs.package_version }}
path: ${{ github.workspace }}/Realm/packages/
- uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Publish Tests/Tests.XUnit
run: dotnet publish Tests/Tests.XUnit -c Release -f net6.0 -r ${{ (runner.os == 'macOS' && 'osx-x64') || (runner.os == 'Windows' && 'win-x64') || (runner.os == 'Linux' && 'linux-x64') || '???' }} -p:RestoreConfigFile=Tests/Test.NuGet.Config -p:UseRealmNupkgsWithVersion=${{ needs.build-packages.outputs.package_version }} --no-self-contained
- name: Output executable path
id: dotnet-publish
run: echo '::set-output name=executable-path::./Tests/Tests.XUnit/bin/Release/net6.0/${{ (runner.os == 'macOS' && 'osx-x64') || (runner.os == 'Windows' && 'win-x64') || (runner.os == 'Linux' && 'linux-x64') || '???' }}'
- name: Run Tests
run: dotnet test ${{ steps.dotnet-publish.outputs.executable-path }}/Tests.XUnit.dll --logger GitHubActions
run-tests-weaver:
runs-on: windows-latest
name: Test Weaver
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* None

### Fixed
* None
* Fixed an issue with xUnit tests that would cause `System.Runtime.InteropServices.SEHException` to be thrown whenever Realm was accessed in a non-async test. (Issue [#1865](https://github.com/realm/realm-dotnet/issues/1865))

### Compatibility
* Realm Studio: 11.0.0 or later.

### Internal
* Using Core x.y.z.
* Using Core 11.8.0

## 10.9.0 (2022-01-21)

Expand Down
Loading

0 comments on commit 60c629e

Please sign in to comment.