Merge pull request #850 from PowerShell/andschwa/fix-xunit

Re-enable xUnit tests on Linux
This commit is contained in:
Andy Schwartzmeyer committed 2016-04-18 19:27:55 -07:00
commit a655b439bc
6 files changed
+23 -7

No files matched your search

@@ -522,7 +522,15 @@ namespace System.Management.Automation
if (!IsInitialized)
{
var psAsmLoadContext = new PowerShellAssemblyLoadContext(basePaths);
AssemblyLoadContext.InitializeDefaultContext(psAsmLoadContext);
try
{
AssemblyLoadContext.InitializeDefaultContext(psAsmLoadContext);
}
catch (System.InvalidOperationException)
{
// We may not be able to set the default context. If we're under the
// xUnit test harness, it has already been set.
}
IsInitialized = true;
}
}
@@ -394,7 +394,9 @@ namespace System.Management.Automation
_psLoadContext = AssemblyLoadContext.Default as PowerShellAssemblyLoadContext;
if (_psLoadContext == null)
{
throw new InvalidOperationException(ParserStrings.InvalidAssemblyLoadContextInUse);
// The default load context may not be ours. This can happen during,
// for instance, xUnit testing.
_psLoadContext = new PowerShellAssemblyLoadContext(String.Empty);
}
}
return _psLoadContext;