我们使用 Github Actions 来构建和测试我们的 ActiveX 控件。我们几周前就开始了,并取得了很大进展。我们使用矩阵构建和测试 x86 和 x64。从一周前开始,两次构建仍然成功,x64 单元测试成功,但 x86 单元测试失败。
有时5分钟后。50分钟后的某个时间。我们得到这样的错误:
The active test run was aborted. Reason: Test host process crashed : Fatal error. Internal CLR error. (0x80131506)
Test Run Aborted with error System.AggregateException: One or more errors occurred.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
Test Run Aborted with error System.AggregateException: One or more errors occurred. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
Total tests: Unknown
--- End of inner exception stack trace ---
Passed: 31
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
Skipped: 1
at System.IO.Stream.ReadByte()
at System.IO.BinaryReader.ReadByte()
at System.IO.BinaryReader.Read7BitEncodedInt()
at System.IO.BinaryReader.ReadString()
at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.LengthPrefixCommunicationChannel.NotifyDataAvailable()
at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TcpClientExtensions.MessageLoopAsync(TcpClient client, ICommunicationChannel channel, Action`1 errorHandler, CancellationToken cancellationToken)
主动测试随机不同,让我相信问题不在于测试。
x86 和 x64 的单元测试相同,我们没有具体的测试。
两个版本都很好,运行大约 8-10 分钟。此外,生产的工件看起来不错。
Actions 结果可以在我们的公共仓库https://github.com/MapWindow/MapWinGIS/actions查看
这是我们的测试部分的动作脚本:
# Build test solution
- name: setup-msbuild
uses: microsoft/setup-msbuild@v1.1
with:
msbuild-architecture: x64
- name: Build test solution ${{matrix.platform}}
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m:2 /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.platform}} -restore /v:m ${{env.UNITTESTS_SOLUTION_FILE_PATH}}
# Run unit tests
- name: Setup VSTest.console.exe
uses: darenm/Setup-VSTest@v1
- name: Unit Testing x86
if: ${{matrix.platform == 'Win32' }}
run: vstest.console.exe /Parallel /Blame /Diag:logs\log.txt /Platform:x86 -e:PROJ_LIB="${{ github.workspace }}\src\bin\Release\Win32\proj7\share\" .\unittest-net6\UnitTests\bin\x86\${{env.BUILD_CONFIGURATION}}\net6.0-windows8.0\unittest-net6.dll
- name: Unit Testing x64
if: ${{matrix.platform == 'x64' }}
run: vstest.console.exe /Parallel /Blame /Diag:logs\log.txt /Platform:x64 -e:PROJ_LIB="${{ github.workspace }}\src\bin\Release\x64\proj7\share\" .\unittest-net6\UnitTests\bin\x64\${{env.BUILD_CONFIGURATION}}\net6.0-windows8.0\unittest-net6.dll
编辑:
删除vstest.console.exe/Parallel
的参数确实导致 1 次成功运行。但是,下一次运行再次失败并出现相同的错误。我使用. windows-2022镜像使用VS2022windows-2022
dotnet-version: '6.x'