From 6fe441b675cd367bef7af7cd6caf0d85dfb2a681 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 12 Nov 2018 18:16:02 +0500 Subject: [PATCH 1/9] Move xUnit tests in new folder Remove unneeded dotnet restore Add --no-restore Add extraParams for MacOS Fix TestRunspaceWithPowerShellAndInitialSessionState Fix race condition to access powershell.config.json Reduce an impact of the inter process race condition Fix race condition to access powershell.config.json (#8249) --- build.psm1 | 26 ++++------- test/README.md | 3 +- test/csharp/README.md | 20 --------- test/xUnit/Asserts/PriorityAttribute.cs | 12 +++++ test/xUnit/Asserts/PriorityOrderer.cs | 45 +++++++++++++++++++ test/xUnit/README.md | 29 ++++++++++++ test/{ => xUnit}/csharp/test_Binders.cs | 0 .../{ => xUnit}/csharp/test_CorePsPlatform.cs | 0 .../csharp/test_ExtensionMethods.cs | 0 .../csharp/test_FileSystemProvider.cs | 0 test/{ => xUnit}/csharp/test_MshSnapinInfo.cs | 0 .../csharp/test_PSConfiguration.cs | 21 ++++----- test/{ => xUnit}/csharp/test_PSVersionInfo.cs | 0 test/{ => xUnit}/csharp/test_Runspace.cs | 6 ++- .../csharp/test_SecuritySupport.cs | 0 test/{ => xUnit}/csharp/test_SessionState.cs | 0 test/{ => xUnit}/csharp/test_Utils.cs | 0 .../xUnit.tests.csproj} | 2 +- tools/appveyor.psm1 | 11 +---- tools/travis.ps1 | 5 +-- 20 files changed, 115 insertions(+), 65 deletions(-) delete mode 100644 test/csharp/README.md create mode 100644 test/xUnit/Asserts/PriorityAttribute.cs create mode 100644 test/xUnit/Asserts/PriorityOrderer.cs create mode 100644 test/xUnit/README.md rename test/{ => xUnit}/csharp/test_Binders.cs (100%) rename test/{ => xUnit}/csharp/test_CorePsPlatform.cs (100%) rename test/{ => xUnit}/csharp/test_ExtensionMethods.cs (100%) rename test/{ => xUnit}/csharp/test_FileSystemProvider.cs (100%) rename test/{ => xUnit}/csharp/test_MshSnapinInfo.cs (100%) rename test/{ => xUnit}/csharp/test_PSConfiguration.cs (99%) rename test/{ => xUnit}/csharp/test_PSVersionInfo.cs (100%) rename test/{ => xUnit}/csharp/test_Runspace.cs (98%) rename test/{ => xUnit}/csharp/test_SecuritySupport.cs (100%) rename test/{ => xUnit}/csharp/test_SessionState.cs (100%) rename test/{ => xUnit}/csharp/test_Utils.cs (100%) rename test/{csharp/csharp.tests.csproj => xUnit/xUnit.tests.csproj} (95%) diff --git a/build.psm1 b/build.psm1 index 866cc51de4a..f1c01fc5d09 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1371,7 +1371,6 @@ function Test-PSPesterResults function Start-PSxUnit { [CmdletBinding()]param( - [string] $SequentialTestResultsFile = "SequentialXUnitResults.xml", [string] $ParallelTestResultsFile = "ParallelXUnitResults.xml" ) @@ -1384,10 +1383,9 @@ function Start-PSxUnit { } try { - Push-Location $PSScriptRoot/test/csharp + Push-Location $PSScriptRoot/test/xUnit # Path manipulation to obtain test project output directory - dotnet restore if(-not $Environment.IsWindows) { @@ -1419,30 +1417,22 @@ function Start-PSxUnit { } } - # Run sequential tests first, and then run the tests that can execute in parallel - if (Test-Path $SequentialTestResultsFile) { - Remove-Item $SequentialTestResultsFile -Force -ErrorAction SilentlyContinue - } - dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Sequential -p:ParallelizeTestCollections=false --test-adapter-path:. "--logger:xunit;LogFilePath=$SequentialTestResultsFile" - Publish-TestResults -Path $SequentialTestResultsFile -Type 'XUnit' -Title 'Xunit Sequential' + dotnet build --configuration $Options.configuration - $extraParams = @() + if (Test-Path $ParallelTestResultsFile) { + Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue + } # we are having intermittent issues on macOS with these tests failing. # VSTS has suggested forcing them to be sequential if($env:TF_BUILD -and $IsMacOS) { Write-Log 'Forcing parallel xunit tests to run sequentially.' - $extraParams += @( - '-parallel' - 'none' - ) + dotnet test -p:ParallelizeTestCollections=false --configuration $Options.configuration --no-restore --no-build --test-adapter-path:. "--logger:xunit;LogFilePath=$ParallelTestResultsFile" + } else { + dotnet test --configuration $Options.configuration --no-restore --no-build --test-adapter-path:. "--logger:xunit;LogFilePath=$ParallelTestResultsFile" } - if (Test-Path $ParallelTestResultsFile) { - Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue - } - dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Parallel --no-build --test-adapter-path:. "--logger:xunit;LogFilePath=$ParallelTestResultsFile" Publish-TestResults -Path $ParallelTestResultsFile -Type 'XUnit' -Title 'Xunit Parallel' } finally { diff --git a/test/README.md b/test/README.md index 08e07d7a54b..d511995cbe0 100644 --- a/test/README.md +++ b/test/README.md @@ -4,8 +4,7 @@ Testing The tests are organized by testing language. Thus Pester tests, which are written in the PowerShell language, are in [./powershell](./powershell) and xUnit tests, written in C#, are in -[./csharp](./csharp). The sanity tests for the Full .NET build of -PowerShell are in [./fullclr](./fullclr), and the third-party +[./xUnit](./xUnit). The third-party [shebang][] test is in [./shebang](./shebang). [shebang]: https://en.wikipedia.org/wiki/Shebang_(Unix) diff --git a/test/csharp/README.md b/test/csharp/README.md deleted file mode 100644 index 18979b0552a..00000000000 --- a/test/csharp/README.md +++ /dev/null @@ -1,20 +0,0 @@ -xUnit Tests -=========== - -These tests are completely Linux specific. - -Every test class *must* belong to -`[Collection("AssemblyLoadContext")]`. This ensures that PowerShell's -AssemblyLoadContext is initialized before any other code is executed. -When this is not the case, late initialization fails with -`System.InvalidOperationException : Binding model is already locked -for the AppDomain and cannot be reset.` - -Having every class in the same collection is as close to an xUnit -global init hook as can be done. - -Running xUnit Tests -------------------- - -Go to the top level of the PowerShell repository and run: -`Start-PSxUnit` inside a self-hosted copy of PowerShell. diff --git a/test/xUnit/Asserts/PriorityAttribute.cs b/test/xUnit/Asserts/PriorityAttribute.cs new file mode 100644 index 00000000000..741dd12391d --- /dev/null +++ b/test/xUnit/Asserts/PriorityAttribute.cs @@ -0,0 +1,12 @@ +using System; + +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +public class TestPriorityAttribute : Attribute +{ + public TestPriorityAttribute(int priority) + { + Priority = priority; + } + + public int Priority { get; private set; } +} diff --git a/test/xUnit/Asserts/PriorityOrderer.cs b/test/xUnit/Asserts/PriorityOrderer.cs new file mode 100644 index 00000000000..b0675b55f1d --- /dev/null +++ b/test/xUnit/Asserts/PriorityOrderer.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace TestOrder.TestCaseOrdering +{ + public class PriorityOrderer : ITestCaseOrderer + { + public IEnumerable OrderTestCases(IEnumerable testCases) where TTestCase : ITestCase + { + var sortedMethods = new SortedDictionary>(); + + foreach (TTestCase testCase in testCases) + { + int priority = 0; + + foreach (IAttributeInfo attr in testCase.TestMethod.Method.GetCustomAttributes((typeof(TestPriorityAttribute).AssemblyQualifiedName))) + priority = attr.GetNamedArgument("Priority"); + + GetOrCreate(sortedMethods, priority).Add(testCase); + } + + foreach (var list in sortedMethods.Keys.Select(priority => sortedMethods[priority])) + { + list.Sort((x, y) => StringComparer.OrdinalIgnoreCase.Compare(x.TestMethod.Method.Name, y.TestMethod.Method.Name)); + foreach (TTestCase testCase in list) + yield return testCase; + } + } + + static TValue GetOrCreate(IDictionary dictionary, TKey key) where TValue : new() + { + TValue result; + + if (dictionary.TryGetValue(key, out result)) return result; + + result = new TValue(); + dictionary[key] = result; + + return result; + } + } +} diff --git a/test/xUnit/README.md b/test/xUnit/README.md new file mode 100644 index 00000000000..1debb2abb42 --- /dev/null +++ b/test/xUnit/README.md @@ -0,0 +1,29 @@ +# xUnit Tests + +The folder contains xUnit tests for PowerShell Core project. + +## Running xUnit Tests + +Go to the top level of the PowerShell repository and run full set of tests: +`Start-PSxUnit` inside a self-hosted copy of PowerShell. + +Go to the test project folder and run `dotnet test -c Release`. + +Use [`filter`](xunit-filter) parameter to run only needed tests: +```powershell +dotnet test -c Release --filter "FullyQualifiedName~UnitTest1 # Runs tests which have UnitTest1 in FullyQualifiedName +dotnet test --filter Name~TestMethod1 # Runs tests whose name contains TestMethod1 +``` + +## Creating xUnit Tests + +Keep the folder structure that is for Pester [../../test/powershell](../../test/powershell) and C# files [../../src](../../src). + +Use namespace names started with `PSTests`. +```c# +namespace PSTests.YourNameSpace +{ +} +``` + +[xunit-filter]: https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests \ No newline at end of file diff --git a/test/csharp/test_Binders.cs b/test/xUnit/csharp/test_Binders.cs similarity index 100% rename from test/csharp/test_Binders.cs rename to test/xUnit/csharp/test_Binders.cs diff --git a/test/csharp/test_CorePsPlatform.cs b/test/xUnit/csharp/test_CorePsPlatform.cs similarity index 100% rename from test/csharp/test_CorePsPlatform.cs rename to test/xUnit/csharp/test_CorePsPlatform.cs diff --git a/test/csharp/test_ExtensionMethods.cs b/test/xUnit/csharp/test_ExtensionMethods.cs similarity index 100% rename from test/csharp/test_ExtensionMethods.cs rename to test/xUnit/csharp/test_ExtensionMethods.cs diff --git a/test/csharp/test_FileSystemProvider.cs b/test/xUnit/csharp/test_FileSystemProvider.cs similarity index 100% rename from test/csharp/test_FileSystemProvider.cs rename to test/xUnit/csharp/test_FileSystemProvider.cs diff --git a/test/csharp/test_MshSnapinInfo.cs b/test/xUnit/csharp/test_MshSnapinInfo.cs similarity index 100% rename from test/csharp/test_MshSnapinInfo.cs rename to test/xUnit/csharp/test_MshSnapinInfo.cs diff --git a/test/csharp/test_PSConfiguration.cs b/test/xUnit/csharp/test_PSConfiguration.cs similarity index 99% rename from test/csharp/test_PSConfiguration.cs rename to test/xUnit/csharp/test_PSConfiguration.cs index e474ff699a0..2480225879b 100644 --- a/test/csharp/test_PSConfiguration.cs +++ b/test/xUnit/csharp/test_PSConfiguration.cs @@ -12,6 +12,7 @@ namespace PSTests.Sequential { + [TestCaseOrderer("TestOrder.TestCaseOrdering.PriorityOrderer", "powershell-tests")] public class PowerShellPolicyFixture : IDisposable { private const string configFileName = "powershell.config.json"; @@ -344,7 +345,7 @@ public PowerShellPolicyTests(PowerShellPolicyFixture fixture) this.fixture = fixture; } - [Fact] + [Fact, TestPriority(1)] public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotEmpty() { fixture.SetupConfigFile1(); @@ -358,7 +359,7 @@ public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotEmpty() fixture.CompareTwoPolicies(userPolicies, fixture.CurrentUserPolicies); } - [Fact] + [Fact, TestPriority(2)] public void PowerShellConfig_GetPowerShellPolicies_EmptyUserConfig() { fixture.SetupConfigFile2(); @@ -371,7 +372,7 @@ public void PowerShellConfig_GetPowerShellPolicies_EmptyUserConfig() fixture.CompareTwoPolicies(sysPolicies, fixture.SystemWidePolicies); } - [Fact] + [Fact, TestPriority(3)] public void PowerShellConfig_GetPowerShellPolicies_EmptySystemConfig() { fixture.SetupConfigFile3(); @@ -384,7 +385,7 @@ public void PowerShellConfig_GetPowerShellPolicies_EmptySystemConfig() fixture.CompareTwoPolicies(userPolicies, fixture.CurrentUserPolicies); } - [Fact] + [Fact, TestPriority(4)] public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesEmpty() { fixture.SetupConfigFile4(); @@ -395,7 +396,7 @@ public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesEmpty() Assert.Null(userPolicies); } - [Fact] + [Fact, TestPriority(5)] public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotExist() { fixture.CleanupConfigFiles(); @@ -406,7 +407,7 @@ public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotExist() Assert.Null(userPolicies); } - [Fact] + [Fact, TestPriority(6)] public void Utils_GetPolicySetting_BothConfigFilesNotEmpty() { fixture.SetupConfigFile1(); @@ -504,7 +505,7 @@ public void Utils_GetPolicySetting_BothConfigFilesNotEmpty() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, fixture.SystemWidePolicies.ConsoleSessionConfiguration); } - [Fact] + [Fact, TestPriority(7)] public void Utils_GetPolicySetting_EmptyUserConfig() { fixture.SetupConfigFile2(); @@ -602,7 +603,7 @@ public void Utils_GetPolicySetting_EmptyUserConfig() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, fixture.SystemWidePolicies.ConsoleSessionConfiguration); } - [Fact] + [Fact, TestPriority(8)] public void Utils_GetPolicySetting_EmptySystemConfig() { fixture.SetupConfigFile3(); @@ -701,7 +702,7 @@ public void Utils_GetPolicySetting_EmptySystemConfig() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, null); } - [Fact] + [Fact, TestPriority(9)] public void Utils_GetPolicySetting_BothConfigFilesEmpty() { fixture.SetupConfigFile4(); @@ -800,7 +801,7 @@ public void Utils_GetPolicySetting_BothConfigFilesEmpty() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, null); } - [Fact] + [Fact, TestPriority(10)] public void Utils_GetPolicySetting_BothConfigFilesNotExist() { fixture.CleanupConfigFiles(); diff --git a/test/csharp/test_PSVersionInfo.cs b/test/xUnit/csharp/test_PSVersionInfo.cs similarity index 100% rename from test/csharp/test_PSVersionInfo.cs rename to test/xUnit/csharp/test_PSVersionInfo.cs diff --git a/test/csharp/test_Runspace.cs b/test/xUnit/csharp/test_Runspace.cs similarity index 98% rename from test/csharp/test_Runspace.cs rename to test/xUnit/csharp/test_Runspace.cs index c9f06112407..5b72618026e 100644 --- a/test/csharp/test_Runspace.cs +++ b/test/xUnit/csharp/test_Runspace.cs @@ -66,7 +66,7 @@ public void TestRunspaceWithPowerShell() [Fact] public void TestRunspaceWithPowerShellAndInitialSessionState() { - InitialSessionState iss = InitialSessionState.CreateDefault2(); + InitialSessionState iss = InitialSessionState.CreateDefault(); // NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output // in addition to just the PSObjects @@ -90,9 +90,11 @@ public void TestRunspaceWithPowerShellAndInitialSessionState() ++objCount; Assert.NotNull(result); } + Assert.Equal(count, objCount); - powerShell.Dispose(); } + + runspace.Close(); } } } diff --git a/test/csharp/test_SecuritySupport.cs b/test/xUnit/csharp/test_SecuritySupport.cs similarity index 100% rename from test/csharp/test_SecuritySupport.cs rename to test/xUnit/csharp/test_SecuritySupport.cs diff --git a/test/csharp/test_SessionState.cs b/test/xUnit/csharp/test_SessionState.cs similarity index 100% rename from test/csharp/test_SessionState.cs rename to test/xUnit/csharp/test_SessionState.cs diff --git a/test/csharp/test_Utils.cs b/test/xUnit/csharp/test_Utils.cs similarity index 100% rename from test/csharp/test_Utils.cs rename to test/xUnit/csharp/test_Utils.cs diff --git a/test/csharp/csharp.tests.csproj b/test/xUnit/xUnit.tests.csproj similarity index 95% rename from test/csharp/csharp.tests.csproj rename to test/xUnit/xUnit.tests.csproj index af62b5447e6..72f52593915 100644 --- a/test/csharp/csharp.tests.csproj +++ b/test/xUnit/xUnit.tests.csproj @@ -5,6 +5,7 @@ PowerShell xUnit Tests powershell-tests + true win7-x86;win7-x64;osx-x64;linux-x64 @@ -26,5 +27,4 @@ - diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 9f16dc0c76c..227f1847fb5 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -369,7 +369,6 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Run CoreCLR tests' $testResultsNonAdminFile = "$pwd\TestsResultsNonAdmin.xml" $testResultsAdminFile = "$pwd\TestsResultsAdmin.xml" - $SequentialXUnitTestResultsFile = "$pwd\SequentialXUnitTestResults.xml" $ParallelXUnitTestResultsFile = "$pwd\ParallelXUnitTestResults.xml" if(!(Test-Path "$env:CoreOutput\pwsh.exe")) { @@ -443,19 +442,13 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Upload CoreCLR Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsAdminFile - Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile + Start-PSxUnit -ParallelTestResultsFile $ParallelXUnitTestResultsFile Write-Host -ForegroundColor Green 'Uploading PSxUnit test results' - Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFile Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFile # Fail the build, if tests failed Test-PSPesterResults -TestResultsFile $testResultsAdminFile - @( - $SequentialXUnitTestResultsFile, - $ParallelXUnitTestResultsFile - ) | ForEach-Object { - Test-XUnitTestResults -TestResultsFile $_ - } + Test-XUnitTestResults -TestResultsFile $ParallelXUnitTestResultsFile # Run tests with specified experimental features enabled foreach ($entry in $ExperimentalFeatureTests.GetEnumerator()) { diff --git a/tools/travis.ps1 b/tools/travis.ps1 index a9823e2a6cd..33498d89ec7 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -330,12 +330,11 @@ elseif($Stage -eq 'Build') } try { - $SequentialXUnitTestResultsFile = "$pwd/SequentialXUnitTestResults.xml" $ParallelXUnitTestResultsFile = "$pwd/ParallelXUnitTestResults.xml" - Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile + Start-PSxUnit -ParallelTestResultsFile $ParallelXUnitTestResultsFile # If there are failures, Test-XUnitTestResults throws - $SequentialXUnitTestResultsFile, $ParallelXUnitTestResultsFile | ForEach-Object { Test-XUnitTestResults -TestResultsFile $_ } + Test-XUnitTestResults -TestResultsFile $ParallelXUnitTestResultsFile } catch { $result = "FAIL" From 664131d5c326551b06a6b0af0134d0c1dad6ab8d Mon Sep 17 00:00:00 2001 From: Ilya Date: Sat, 1 Dec 2018 01:01:00 +0500 Subject: [PATCH 2/9] Add copyright --- test/xUnit/Asserts/PriorityOrderer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/xUnit/Asserts/PriorityOrderer.cs b/test/xUnit/Asserts/PriorityOrderer.cs index b0675b55f1d..72eff865a93 100644 --- a/test/xUnit/Asserts/PriorityOrderer.cs +++ b/test/xUnit/Asserts/PriorityOrderer.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + using System; using System.Collections.Generic; using System.Linq; From d881c3af1f2fb8bf3ba2cc09918ffb836696d9bd Mon Sep 17 00:00:00 2001 From: Ilya Date: Sat, 1 Dec 2018 01:02:35 +0500 Subject: [PATCH 3/9] Add copyright 2 --- test/xUnit/Asserts/PriorityAttribute.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/xUnit/Asserts/PriorityAttribute.cs b/test/xUnit/Asserts/PriorityAttribute.cs index 741dd12391d..626ac5ac233 100644 --- a/test/xUnit/Asserts/PriorityAttribute.cs +++ b/test/xUnit/Asserts/PriorityAttribute.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + using System; [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] From 2f5182f94f311b6a5aa976c1afb7df1aab7b3d8a Mon Sep 17 00:00:00 2001 From: Ilya Date: Sat, 1 Dec 2018 14:04:53 +0500 Subject: [PATCH 4/9] Revert to CreateDefault2() --- test/xUnit/csharp/test_Runspace.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/xUnit/csharp/test_Runspace.cs b/test/xUnit/csharp/test_Runspace.cs index 5b72618026e..7d1d0d64abe 100644 --- a/test/xUnit/csharp/test_Runspace.cs +++ b/test/xUnit/csharp/test_Runspace.cs @@ -66,7 +66,8 @@ public void TestRunspaceWithPowerShell() [Fact] public void TestRunspaceWithPowerShellAndInitialSessionState() { - InitialSessionState iss = InitialSessionState.CreateDefault(); + // CreateDefault2 is intentional. + InitialSessionState iss = InitialSessionState.CreateDefault2(); // NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output // in addition to just the PSObjects From c4a86e532f31c25cf63d3b6aa9f540037831adce Mon Sep 17 00:00:00 2001 From: iSazonov Date: Mon, 12 Nov 2018 18:16:02 +0500 Subject: [PATCH 5/9] Move xUnit tests in new folder Remove unneeded dotnet restore Add --no-restore Add extraParams for MacOS Fix TestRunspaceWithPowerShellAndInitialSessionState Fix race condition to access powershell.config.json Reduce an impact of the inter process race condition Fix race condition to access powershell.config.json (#8249) --- build.psm1 | 26 ++++------- test/README.md | 3 +- test/csharp/README.md | 20 --------- test/xUnit/Asserts/PriorityAttribute.cs | 12 +++++ test/xUnit/Asserts/PriorityOrderer.cs | 45 +++++++++++++++++++ test/xUnit/README.md | 29 ++++++++++++ test/{ => xUnit}/csharp/test_Binders.cs | 0 .../{ => xUnit}/csharp/test_CorePsPlatform.cs | 0 .../csharp/test_ExtensionMethods.cs | 0 .../csharp/test_FileSystemProvider.cs | 0 test/{ => xUnit}/csharp/test_MshSnapinInfo.cs | 0 .../csharp/test_PSConfiguration.cs | 21 ++++----- test/{ => xUnit}/csharp/test_PSVersionInfo.cs | 0 test/{ => xUnit}/csharp/test_Runspace.cs | 6 ++- .../csharp/test_SecuritySupport.cs | 0 test/{ => xUnit}/csharp/test_SessionState.cs | 0 test/{ => xUnit}/csharp/test_Utils.cs | 0 .../xUnit.tests.csproj} | 2 +- tools/appveyor.psm1 | 11 +---- tools/travis.ps1 | 5 +-- 20 files changed, 115 insertions(+), 65 deletions(-) delete mode 100644 test/csharp/README.md create mode 100644 test/xUnit/Asserts/PriorityAttribute.cs create mode 100644 test/xUnit/Asserts/PriorityOrderer.cs create mode 100644 test/xUnit/README.md rename test/{ => xUnit}/csharp/test_Binders.cs (100%) rename test/{ => xUnit}/csharp/test_CorePsPlatform.cs (100%) rename test/{ => xUnit}/csharp/test_ExtensionMethods.cs (100%) rename test/{ => xUnit}/csharp/test_FileSystemProvider.cs (100%) rename test/{ => xUnit}/csharp/test_MshSnapinInfo.cs (100%) rename test/{ => xUnit}/csharp/test_PSConfiguration.cs (99%) rename test/{ => xUnit}/csharp/test_PSVersionInfo.cs (100%) rename test/{ => xUnit}/csharp/test_Runspace.cs (98%) rename test/{ => xUnit}/csharp/test_SecuritySupport.cs (100%) rename test/{ => xUnit}/csharp/test_SessionState.cs (100%) rename test/{ => xUnit}/csharp/test_Utils.cs (100%) rename test/{csharp/csharp.tests.csproj => xUnit/xUnit.tests.csproj} (95%) diff --git a/build.psm1 b/build.psm1 index 490505cc089..7e379777423 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1369,7 +1369,6 @@ function Test-PSPesterResults function Start-PSxUnit { [CmdletBinding()]param( - [string] $SequentialTestResultsFile = "SequentialXUnitResults.xml", [string] $ParallelTestResultsFile = "ParallelXUnitResults.xml" ) @@ -1382,10 +1381,9 @@ function Start-PSxUnit { } try { - Push-Location $PSScriptRoot/test/csharp + Push-Location $PSScriptRoot/test/xUnit # Path manipulation to obtain test project output directory - dotnet restore if(-not $Environment.IsWindows) { @@ -1417,30 +1415,22 @@ function Start-PSxUnit { } } - # Run sequential tests first, and then run the tests that can execute in parallel - if (Test-Path $SequentialTestResultsFile) { - Remove-Item $SequentialTestResultsFile -Force -ErrorAction SilentlyContinue - } - dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Sequential -p:ParallelizeTestCollections=false --test-adapter-path:. "--logger:xunit;LogFilePath=$SequentialTestResultsFile" - Publish-TestResults -Path $SequentialTestResultsFile -Type 'XUnit' -Title 'Xunit Sequential' + dotnet build --configuration $Options.configuration - $extraParams = @() + if (Test-Path $ParallelTestResultsFile) { + Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue + } # we are having intermittent issues on macOS with these tests failing. # VSTS has suggested forcing them to be sequential if($env:TF_BUILD -and $IsMacOS) { Write-Log 'Forcing parallel xunit tests to run sequentially.' - $extraParams += @( - '-parallel' - 'none' - ) + dotnet test -p:ParallelizeTestCollections=false --configuration $Options.configuration --no-restore --no-build --test-adapter-path:. "--logger:xunit;LogFilePath=$ParallelTestResultsFile" + } else { + dotnet test --configuration $Options.configuration --no-restore --no-build --test-adapter-path:. "--logger:xunit;LogFilePath=$ParallelTestResultsFile" } - if (Test-Path $ParallelTestResultsFile) { - Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue - } - dotnet test --configuration $Options.configuration --filter FullyQualifiedName~PSTests.Parallel --no-build --test-adapter-path:. "--logger:xunit;LogFilePath=$ParallelTestResultsFile" Publish-TestResults -Path $ParallelTestResultsFile -Type 'XUnit' -Title 'Xunit Parallel' } finally { diff --git a/test/README.md b/test/README.md index 08e07d7a54b..d511995cbe0 100644 --- a/test/README.md +++ b/test/README.md @@ -4,8 +4,7 @@ Testing The tests are organized by testing language. Thus Pester tests, which are written in the PowerShell language, are in [./powershell](./powershell) and xUnit tests, written in C#, are in -[./csharp](./csharp). The sanity tests for the Full .NET build of -PowerShell are in [./fullclr](./fullclr), and the third-party +[./xUnit](./xUnit). The third-party [shebang][] test is in [./shebang](./shebang). [shebang]: https://en.wikipedia.org/wiki/Shebang_(Unix) diff --git a/test/csharp/README.md b/test/csharp/README.md deleted file mode 100644 index 18979b0552a..00000000000 --- a/test/csharp/README.md +++ /dev/null @@ -1,20 +0,0 @@ -xUnit Tests -=========== - -These tests are completely Linux specific. - -Every test class *must* belong to -`[Collection("AssemblyLoadContext")]`. This ensures that PowerShell's -AssemblyLoadContext is initialized before any other code is executed. -When this is not the case, late initialization fails with -`System.InvalidOperationException : Binding model is already locked -for the AppDomain and cannot be reset.` - -Having every class in the same collection is as close to an xUnit -global init hook as can be done. - -Running xUnit Tests -------------------- - -Go to the top level of the PowerShell repository and run: -`Start-PSxUnit` inside a self-hosted copy of PowerShell. diff --git a/test/xUnit/Asserts/PriorityAttribute.cs b/test/xUnit/Asserts/PriorityAttribute.cs new file mode 100644 index 00000000000..741dd12391d --- /dev/null +++ b/test/xUnit/Asserts/PriorityAttribute.cs @@ -0,0 +1,12 @@ +using System; + +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +public class TestPriorityAttribute : Attribute +{ + public TestPriorityAttribute(int priority) + { + Priority = priority; + } + + public int Priority { get; private set; } +} diff --git a/test/xUnit/Asserts/PriorityOrderer.cs b/test/xUnit/Asserts/PriorityOrderer.cs new file mode 100644 index 00000000000..b0675b55f1d --- /dev/null +++ b/test/xUnit/Asserts/PriorityOrderer.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace TestOrder.TestCaseOrdering +{ + public class PriorityOrderer : ITestCaseOrderer + { + public IEnumerable OrderTestCases(IEnumerable testCases) where TTestCase : ITestCase + { + var sortedMethods = new SortedDictionary>(); + + foreach (TTestCase testCase in testCases) + { + int priority = 0; + + foreach (IAttributeInfo attr in testCase.TestMethod.Method.GetCustomAttributes((typeof(TestPriorityAttribute).AssemblyQualifiedName))) + priority = attr.GetNamedArgument("Priority"); + + GetOrCreate(sortedMethods, priority).Add(testCase); + } + + foreach (var list in sortedMethods.Keys.Select(priority => sortedMethods[priority])) + { + list.Sort((x, y) => StringComparer.OrdinalIgnoreCase.Compare(x.TestMethod.Method.Name, y.TestMethod.Method.Name)); + foreach (TTestCase testCase in list) + yield return testCase; + } + } + + static TValue GetOrCreate(IDictionary dictionary, TKey key) where TValue : new() + { + TValue result; + + if (dictionary.TryGetValue(key, out result)) return result; + + result = new TValue(); + dictionary[key] = result; + + return result; + } + } +} diff --git a/test/xUnit/README.md b/test/xUnit/README.md new file mode 100644 index 00000000000..1debb2abb42 --- /dev/null +++ b/test/xUnit/README.md @@ -0,0 +1,29 @@ +# xUnit Tests + +The folder contains xUnit tests for PowerShell Core project. + +## Running xUnit Tests + +Go to the top level of the PowerShell repository and run full set of tests: +`Start-PSxUnit` inside a self-hosted copy of PowerShell. + +Go to the test project folder and run `dotnet test -c Release`. + +Use [`filter`](xunit-filter) parameter to run only needed tests: +```powershell +dotnet test -c Release --filter "FullyQualifiedName~UnitTest1 # Runs tests which have UnitTest1 in FullyQualifiedName +dotnet test --filter Name~TestMethod1 # Runs tests whose name contains TestMethod1 +``` + +## Creating xUnit Tests + +Keep the folder structure that is for Pester [../../test/powershell](../../test/powershell) and C# files [../../src](../../src). + +Use namespace names started with `PSTests`. +```c# +namespace PSTests.YourNameSpace +{ +} +``` + +[xunit-filter]: https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests \ No newline at end of file diff --git a/test/csharp/test_Binders.cs b/test/xUnit/csharp/test_Binders.cs similarity index 100% rename from test/csharp/test_Binders.cs rename to test/xUnit/csharp/test_Binders.cs diff --git a/test/csharp/test_CorePsPlatform.cs b/test/xUnit/csharp/test_CorePsPlatform.cs similarity index 100% rename from test/csharp/test_CorePsPlatform.cs rename to test/xUnit/csharp/test_CorePsPlatform.cs diff --git a/test/csharp/test_ExtensionMethods.cs b/test/xUnit/csharp/test_ExtensionMethods.cs similarity index 100% rename from test/csharp/test_ExtensionMethods.cs rename to test/xUnit/csharp/test_ExtensionMethods.cs diff --git a/test/csharp/test_FileSystemProvider.cs b/test/xUnit/csharp/test_FileSystemProvider.cs similarity index 100% rename from test/csharp/test_FileSystemProvider.cs rename to test/xUnit/csharp/test_FileSystemProvider.cs diff --git a/test/csharp/test_MshSnapinInfo.cs b/test/xUnit/csharp/test_MshSnapinInfo.cs similarity index 100% rename from test/csharp/test_MshSnapinInfo.cs rename to test/xUnit/csharp/test_MshSnapinInfo.cs diff --git a/test/csharp/test_PSConfiguration.cs b/test/xUnit/csharp/test_PSConfiguration.cs similarity index 99% rename from test/csharp/test_PSConfiguration.cs rename to test/xUnit/csharp/test_PSConfiguration.cs index 173dea6810e..af47feee603 100644 --- a/test/csharp/test_PSConfiguration.cs +++ b/test/xUnit/csharp/test_PSConfiguration.cs @@ -12,6 +12,7 @@ namespace PSTests.Sequential { + [TestCaseOrderer("TestOrder.TestCaseOrdering.PriorityOrderer", "powershell-tests")] public class PowerShellPolicyFixture : IDisposable { private const string configFileName = "powershell.config.json"; @@ -344,7 +345,7 @@ public PowerShellPolicyTests(PowerShellPolicyFixture fixture) this.fixture = fixture; } - [Fact] + [Fact, TestPriority(1)] public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotEmpty() { fixture.SetupConfigFile1(); @@ -358,7 +359,7 @@ public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotEmpty() fixture.CompareTwoPolicies(userPolicies, fixture.CurrentUserPolicies); } - [Fact] + [Fact, TestPriority(2)] public void PowerShellConfig_GetPowerShellPolicies_EmptyUserConfig() { fixture.SetupConfigFile2(); @@ -371,7 +372,7 @@ public void PowerShellConfig_GetPowerShellPolicies_EmptyUserConfig() fixture.CompareTwoPolicies(sysPolicies, fixture.SystemWidePolicies); } - [Fact] + [Fact, TestPriority(3)] public void PowerShellConfig_GetPowerShellPolicies_EmptySystemConfig() { fixture.SetupConfigFile3(); @@ -384,7 +385,7 @@ public void PowerShellConfig_GetPowerShellPolicies_EmptySystemConfig() fixture.CompareTwoPolicies(userPolicies, fixture.CurrentUserPolicies); } - [Fact] + [Fact, TestPriority(4)] public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesEmpty() { fixture.SetupConfigFile4(); @@ -395,7 +396,7 @@ public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesEmpty() Assert.Null(userPolicies); } - [Fact] + [Fact, TestPriority(5)] public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotExist() { fixture.CleanupConfigFiles(); @@ -406,7 +407,7 @@ public void PowerShellConfig_GetPowerShellPolicies_BothConfigFilesNotExist() Assert.Null(userPolicies); } - [Fact] + [Fact, TestPriority(6)] public void Utils_GetPolicySetting_BothConfigFilesNotEmpty() { fixture.SetupConfigFile1(); @@ -504,7 +505,7 @@ public void Utils_GetPolicySetting_BothConfigFilesNotEmpty() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, fixture.SystemWidePolicies.ConsoleSessionConfiguration); } - [Fact] + [Fact, TestPriority(7)] public void Utils_GetPolicySetting_EmptyUserConfig() { fixture.SetupConfigFile2(); @@ -602,7 +603,7 @@ public void Utils_GetPolicySetting_EmptyUserConfig() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, fixture.SystemWidePolicies.ConsoleSessionConfiguration); } - [Fact] + [Fact, TestPriority(8)] public void Utils_GetPolicySetting_EmptySystemConfig() { fixture.SetupConfigFile3(); @@ -701,7 +702,7 @@ public void Utils_GetPolicySetting_EmptySystemConfig() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, null); } - [Fact] + [Fact, TestPriority(9)] public void Utils_GetPolicySetting_BothConfigFilesEmpty() { fixture.SetupConfigFile4(); @@ -800,7 +801,7 @@ public void Utils_GetPolicySetting_BothConfigFilesEmpty() fixture.CompareConsoleSessionConfiguration(consoleSessionConfiguration, null); } - [Fact] + [Fact, TestPriority(10)] public void Utils_GetPolicySetting_BothConfigFilesNotExist() { fixture.CleanupConfigFiles(); diff --git a/test/csharp/test_PSVersionInfo.cs b/test/xUnit/csharp/test_PSVersionInfo.cs similarity index 100% rename from test/csharp/test_PSVersionInfo.cs rename to test/xUnit/csharp/test_PSVersionInfo.cs diff --git a/test/csharp/test_Runspace.cs b/test/xUnit/csharp/test_Runspace.cs similarity index 98% rename from test/csharp/test_Runspace.cs rename to test/xUnit/csharp/test_Runspace.cs index c9f06112407..5b72618026e 100644 --- a/test/csharp/test_Runspace.cs +++ b/test/xUnit/csharp/test_Runspace.cs @@ -66,7 +66,7 @@ public void TestRunspaceWithPowerShell() [Fact] public void TestRunspaceWithPowerShellAndInitialSessionState() { - InitialSessionState iss = InitialSessionState.CreateDefault2(); + InitialSessionState iss = InitialSessionState.CreateDefault(); // NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output // in addition to just the PSObjects @@ -90,9 +90,11 @@ public void TestRunspaceWithPowerShellAndInitialSessionState() ++objCount; Assert.NotNull(result); } + Assert.Equal(count, objCount); - powerShell.Dispose(); } + + runspace.Close(); } } } diff --git a/test/csharp/test_SecuritySupport.cs b/test/xUnit/csharp/test_SecuritySupport.cs similarity index 100% rename from test/csharp/test_SecuritySupport.cs rename to test/xUnit/csharp/test_SecuritySupport.cs diff --git a/test/csharp/test_SessionState.cs b/test/xUnit/csharp/test_SessionState.cs similarity index 100% rename from test/csharp/test_SessionState.cs rename to test/xUnit/csharp/test_SessionState.cs diff --git a/test/csharp/test_Utils.cs b/test/xUnit/csharp/test_Utils.cs similarity index 100% rename from test/csharp/test_Utils.cs rename to test/xUnit/csharp/test_Utils.cs diff --git a/test/csharp/csharp.tests.csproj b/test/xUnit/xUnit.tests.csproj similarity index 95% rename from test/csharp/csharp.tests.csproj rename to test/xUnit/xUnit.tests.csproj index af62b5447e6..72f52593915 100644 --- a/test/csharp/csharp.tests.csproj +++ b/test/xUnit/xUnit.tests.csproj @@ -5,6 +5,7 @@ PowerShell xUnit Tests powershell-tests + true win7-x86;win7-x64;osx-x64;linux-x64 @@ -26,5 +27,4 @@ - diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index 34164db5fc3..cda875998a3 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -369,7 +369,6 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Run CoreCLR tests' $testResultsNonAdminFile = "$pwd\TestsResultsNonAdmin.xml" $testResultsAdminFile = "$pwd\TestsResultsAdmin.xml" - $SequentialXUnitTestResultsFile = "$pwd\SequentialXUnitTestResults.xml" $ParallelXUnitTestResultsFile = "$pwd\ParallelXUnitTestResults.xml" if(!(Test-Path "$env:CoreOutput\pwsh.exe")) { @@ -443,19 +442,13 @@ function Invoke-AppVeyorTest Write-Host -Foreground Green 'Upload CoreCLR Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsAdminFile - Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile + Start-PSxUnit -ParallelTestResultsFile $ParallelXUnitTestResultsFile Write-Host -ForegroundColor Green 'Uploading PSxUnit test results' - Update-AppVeyorTestResults -resultsFile $SequentialXUnitTestResultsFile Update-AppVeyorTestResults -resultsFile $ParallelXUnitTestResultsFile # Fail the build, if tests failed Test-PSPesterResults -TestResultsFile $testResultsAdminFile - @( - $SequentialXUnitTestResultsFile, - $ParallelXUnitTestResultsFile - ) | ForEach-Object { - Test-XUnitTestResults -TestResultsFile $_ - } + Test-XUnitTestResults -TestResultsFile $ParallelXUnitTestResultsFile # Run tests with specified experimental features enabled foreach ($entry in $ExperimentalFeatureTests.GetEnumerator()) { diff --git a/tools/travis.ps1 b/tools/travis.ps1 index a9823e2a6cd..33498d89ec7 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -330,12 +330,11 @@ elseif($Stage -eq 'Build') } try { - $SequentialXUnitTestResultsFile = "$pwd/SequentialXUnitTestResults.xml" $ParallelXUnitTestResultsFile = "$pwd/ParallelXUnitTestResults.xml" - Start-PSxUnit -SequentialTestResultsFile $SequentialXUnitTestResultsFile -ParallelTestResultsFile $ParallelXUnitTestResultsFile + Start-PSxUnit -ParallelTestResultsFile $ParallelXUnitTestResultsFile # If there are failures, Test-XUnitTestResults throws - $SequentialXUnitTestResultsFile, $ParallelXUnitTestResultsFile | ForEach-Object { Test-XUnitTestResults -TestResultsFile $_ } + Test-XUnitTestResults -TestResultsFile $ParallelXUnitTestResultsFile } catch { $result = "FAIL" From ca3243da3cf421d106cb97560020231f44e90b26 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Tue, 4 Dec 2018 09:36:33 +0500 Subject: [PATCH 6/9] Add copyright --- test/xUnit/Asserts/PriorityAttribute.cs | 3 +++ test/xUnit/Asserts/PriorityOrderer.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/xUnit/Asserts/PriorityAttribute.cs b/test/xUnit/Asserts/PriorityAttribute.cs index 741dd12391d..626ac5ac233 100644 --- a/test/xUnit/Asserts/PriorityAttribute.cs +++ b/test/xUnit/Asserts/PriorityAttribute.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + using System; [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] diff --git a/test/xUnit/Asserts/PriorityOrderer.cs b/test/xUnit/Asserts/PriorityOrderer.cs index b0675b55f1d..72eff865a93 100644 --- a/test/xUnit/Asserts/PriorityOrderer.cs +++ b/test/xUnit/Asserts/PriorityOrderer.cs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + using System; using System.Collections.Generic; using System.Linq; From 422ebf2d60c5e16452bdf699025d0d630834f012 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Tue, 4 Dec 2018 09:37:44 +0500 Subject: [PATCH 7/9] Revert to CreateDefault2 --- test/xUnit/csharp/test_Runspace.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/xUnit/csharp/test_Runspace.cs b/test/xUnit/csharp/test_Runspace.cs index 5b72618026e..b68b193d329 100644 --- a/test/xUnit/csharp/test_Runspace.cs +++ b/test/xUnit/csharp/test_Runspace.cs @@ -66,7 +66,7 @@ public void TestRunspaceWithPowerShell() [Fact] public void TestRunspaceWithPowerShellAndInitialSessionState() { - InitialSessionState iss = InitialSessionState.CreateDefault(); + InitialSessionState iss = InitialSessionState.CreateDefault2(); // NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output // in addition to just the PSObjects From f6512de2c3673e66fceda827673c4efa03c48c38 Mon Sep 17 00:00:00 2001 From: iSazonov Date: Thu, 6 Dec 2018 08:20:03 +0500 Subject: [PATCH 8/9] Remove GenerateProgramFile --- test/xUnit/xUnit.tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/test/xUnit/xUnit.tests.csproj b/test/xUnit/xUnit.tests.csproj index 72f52593915..13ebee7fae8 100644 --- a/test/xUnit/xUnit.tests.csproj +++ b/test/xUnit/xUnit.tests.csproj @@ -5,7 +5,6 @@ PowerShell xUnit Tests powershell-tests - true win7-x86;win7-x64;osx-x64;linux-x64 From 3e6fc6d627cb5bba5b3784c6c0565542d40b9804 Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 13 Dec 2018 17:30:03 +0500 Subject: [PATCH 9/9] Use CreateDefault() in TestRunspaceWithPowerShellAndInitialSessionState --- test/xUnit/csharp/test_Runspace.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/xUnit/csharp/test_Runspace.cs b/test/xUnit/csharp/test_Runspace.cs index 7d1d0d64abe..16254354666 100644 --- a/test/xUnit/csharp/test_Runspace.cs +++ b/test/xUnit/csharp/test_Runspace.cs @@ -67,7 +67,7 @@ public void TestRunspaceWithPowerShell() public void TestRunspaceWithPowerShellAndInitialSessionState() { // CreateDefault2 is intentional. - InitialSessionState iss = InitialSessionState.CreateDefault2(); + InitialSessionState iss = InitialSessionState.CreateDefault(); // NOTE: instantiate custom host myHost for the next line to capture stdout and stderr output // in addition to just the PSObjects