diff options
author | Egor Chesakov <Egor.Chesakov@microsoft.com> | 2018-10-31 09:28:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-31 09:28:09 -0700 |
commit | 4bcbb70ea3b20b959c50eb7132783ead33e2e1e9 (patch) | |
tree | d1904a623c691fc17cb2d59de40678f38163a2e8 /tests/runtest.py | |
parent | 2e10a478d9a73a4f213dd30b95afadbe3594925e (diff) | |
download | coreclr-4bcbb70ea3b20b959c50eb7132783ead33e2e1e9.tar.gz coreclr-4bcbb70ea3b20b959c50eb7132783ead33e2e1e9.tar.bz2 coreclr-4bcbb70ea3b20b959c50eb7132783ead33e2e1e9.zip |
Work around XUnit FileLoadException issues (#20644)
In order to mitigate System.IO.FileLoadException we built our own xunit.console.dll with ConcurrentDictionary used for DependencyContextAssemblyCache.managedAssemblyCache instead of Dictionary and use this instead of the one pulled from NuGet.
Diffstat (limited to 'tests/runtest.py')
-rwxr-xr-x | tests/runtest.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/runtest.py b/tests/runtest.py index a90a0eab99..d1b4683b0f 100755 --- a/tests/runtest.py +++ b/tests/runtest.py @@ -52,12 +52,20 @@ import tempfile import time import re import string +import zipfile import xml.etree.ElementTree from collections import defaultdict from sys import platform as _platform +# Version specific imports + +if sys.version_info.major < 3: + import urllib +else: + import urllib.request + ################################################################################ # Argument Parser ################################################################################ @@ -764,6 +772,52 @@ def run_tests(host_os, if test_env is not None: os.environ["__TestEnv"] = test_env + #===================================================================================================================================================== + # + # This is a workaround needed to unblock our CI (in particular, Linux/arm and Linux/arm64 jobs) from the following failures appearing almost in every + # pull request (but hard to reproduce locally) + # + # System.IO.FileLoadException: Could not load file or assembly 'Exceptions.Finalization.XUnitWrapper, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. + # An operation is not legal in the current state. (Exception from HRESULT: 0x80131509 (COR_E_INVALIDOPERATION)) + # + # COR_E_INVALIDOPERATION comes from System.InvalidOperationException that is thrown during AssemblyLoadContext.ResolveUsingResolvingEvent + # when multiple threads attempt to modify an instance of Dictionary (managedAssemblyCache) during Xunit.DependencyContextAssemblyCache.LoadManagedDll call. + # + # In order to mitigate the failure we built our own xunit.console.dll with ConcurrentDictionary used for managedAssemblyCache and use this instead of + # the one pulled from NuGet. The exact code that got built can be found at the following fork of Xunit + # * https://github.com/echesakovMSFT/xunit/tree/UseConcurrentDictionaryInDependencyContextAssemblyCache + # + # The assembly was built using Microsoft Visual Studio v15.9.0-pre.4.0 Developer Command Prompt using the following commands + # 1) git clone https://github.com/echesakovMSFT/xunit.git --branch UseConcurrentDictionaryInDependencyContextAssemblyCache --single-branch + # 2) cd xunit + # 3) git submodule update --init + # 4) powershell .\build.ps1 + # + # Then file "xunit\src\xunit.console\bin\Release\netcoreapp2.0\xunit.console.dll" was archived and uploaded to the clrjit blob storage. + # + # Ideally, this code should be removed when we find a more robust way of running Xunit tests. + # + # References: + # * https://github.com/dotnet/coreclr/issues/20392 + # * https://github.com/dotnet/coreclr/issues/20594 + # * https://github.com/xunit/xunit/issues/1842 + # * https://github.com/xunit/xunit/pull/1846 + # + #===================================================================================================================================================== + + print("Download and overwrite xunit.console.dll in Core_Root") + + urlretrieve = urllib.urlretrieve if sys.version_info.major < 3 else urllib.request.urlretrieve + zipfilename = os.path.join(tempfile.gettempdir(), "xunit.console.dll.zip") + url = r"https://clrjit.blob.core.windows.net/xunit-console/xunit.console.dll.zip" + urlretrieve(url, zipfilename) + + with zipfile.ZipFile(zipfilename,"r") as ziparch: + ziparch.extractall(core_root) + + os.remove(zipfilename) + assert not os.path.isfile(zipfilename) + # Call msbuild. return call_msbuild(coreclr_repo_location, dotnetcli_location, |