From fd95dd19b90e7cb5d0094f52503b59c59ec1ca5b Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 28 Jun 2017 17:15:43 -0700 Subject: [PATCH 1/6] Update to ResourceManagerCache --- .../DisplayDatabase/displayDescriptionData.cs | 1 + .../displayResourceManagerCache.cs | 5 +- .../DisplayDatabase/typeDataXmlLoader.cs | 3 +- .../utils/ResourceManagerCache.cs | 33 ++++++- .../FileInfo.format.ps1xml | 88 +++++++++++++++++++ .../Update-FormatData.Tests.ps1 | 47 ++++++++++ 6 files changed, 172 insertions(+), 5 deletions(-) create mode 100644 test/powershell/Modules/Microsoft.PowerShell.Utility/FileInfo.format.ps1xml diff --git a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs index c8d0b26aeda..a098b08f15f 100644 --- a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs +++ b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayDescriptionData.cs @@ -574,6 +574,7 @@ internal sealed class StringResourceReference { internal DatabaseLoadingInfo loadingInfo = null; internal string assemblyName = null; + internal string assemblyLocation = null; internal string baseName = null; internal string resourceId = null; } diff --git a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs index 04cbdf9a108..84dac06266c 100644 --- a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs +++ b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/displayResourceManagerCache.cs @@ -77,7 +77,10 @@ private string GetStringHelper(StringResourceReference resourceReference, out Lo result = LoadingResult.AssemblyNotFound; return null; } - + else + { + resourceReference.assemblyLocation = loadResult.a.Location; + }; // load now the resource from the resource manager cache try diff --git a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs index 81bb4148f4a..b5ef5a277a9 100644 --- a/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs +++ b/src/System.Management.Automation/commands/utility/FormatAndOutput/common/DisplayDatabase/typeDataXmlLoader.cs @@ -1832,8 +1832,7 @@ private void ReportStringResourceFailure(StringResourceReference resource, { case DisplayResourceManagerCache.AssemblyBindingStatus.FoundInPath: { - assemblyDisplayName = - System.IO.Path.Combine(resource.loadingInfo.fileDirectory, resource.assemblyName); + assemblyDisplayName = resource.assemblyLocation; } break; case DisplayResourceManagerCache.AssemblyBindingStatus.FoundInGac: diff --git a/src/System.Management.Automation/utils/ResourceManagerCache.cs b/src/System.Management.Automation/utils/ResourceManagerCache.cs index 11c72b60b30..8a57eb08cf8 100644 --- a/src/System.Management.Automation/utils/ResourceManagerCache.cs +++ b/src/System.Management.Automation/utils/ResourceManagerCache.cs @@ -177,8 +177,37 @@ internal static string GetResourceString( throw PSTraceSource.NewArgumentException("resourceId"); } - ResourceManager resourceManager = GetResourceManager(assembly, baseName); - string text = resourceManager.GetString(resourceId); + ResourceManager resourceManager = null; + string text = string.Empty; + + // FYI: for a non-existing resource defined by {assembly,baseName,resourceId} + // MissingManifestResourceException is thrown only at the time when resource retrieval method such as ResourceManager.GetString or ResourceManager.GetObject is called, + // Not when you instantiate a ResourceManager object. + try + { + // try with original baseName + resourceManager = GetResourceManager(assembly, baseName); + text = resourceManager.GetString(resourceId); + } + catch (MissingManifestResourceException) + { + // original baseName failed; lets try with alternative resource path format + const string resourcesSubstring = ".resources."; + int resourcesSubstringIndex = baseName.IndexOf(resourcesSubstring); + string newBaseName = string.Empty; + if (resourcesSubstringIndex != -1) + { + newBaseName = baseName.Substring(resourcesSubstringIndex + resourcesSubstring.Length); // e.g. "FileSystemProviderStrings" + } + else + { + newBaseName = assembly.GetName().Name + resourcesSubstring + baseName; // e.g. "System.Management.Automation.resources.FileSystemProviderStrings" + } + + resourceManager = GetResourceManager(assembly, newBaseName); + text = resourceManager.GetString(resourceId); + } + if (String.IsNullOrEmpty(text) && s_DFT_monitorFailingResourceLookup) { Diagnostics.Assert(false, diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/FileInfo.format.ps1xml b/test/powershell/Modules/Microsoft.PowerShell.Utility/FileInfo.format.ps1xml new file mode 100644 index 00000000000..aafe851168d --- /dev/null +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/FileInfo.format.ps1xml @@ -0,0 +1,88 @@ + + + + FileSystemTypes + + System.IO.DirectoryInfo + System.IO.FileInfo + + + + + + + FileSystemTypes-GroupingFormat + + + + + + 0 + + + + + $_.PSParentPath.Replace("Microsoft.PowerShell.Core\FileSystem::", "") + + + + + + + + + + + + + + + FileSystemItems + + FileSystemTypes + + + PSParentPath + FileSystemTypes-GroupingFormat + + + + + + 10 + left + + + + 25 + + + + 15 + right + + + + + + + + + Mode + + + LastWriteTime + + + Length + + + Name + + + + + + + + \ No newline at end of file diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 index 3e679a49be7..135148a7f42 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 @@ -57,3 +57,50 @@ Describe "Update-FormatData basic functionality" -Tags "CI" { { Update-FormatData -Prepend $testfile -WhatIf } | Should Not Throw } } + + +Describe "Update-FormatData with resources in CustomControls" -Tags "CI" { + + BeforeAll { + $templatePath = Join-Path $PSScriptRoot 'FileInfo.format.ps1xml' + $formatFilePath = Join-Path $TestDrive 'FileInfo.format.ps1xml' + $ps = [powershell]::Create() + $iss = [system.management.automation.runspaces.initialsessionstate]::CreateDefault2() + $rs = [system.management.automation.runspaces.runspacefactory]::CreateRunspace($iss) + $rs.Open() + $ps.Runspace = $rs + } + AfterAll { + $rs.Close() + $ps.Dispose() + } + Context "Validate Update-FormatData" { + It "Resources in WindowsPS syntax should be loaded successfully" { + $format = Get-Content -Path $templatePath -Raw + $format.Replace("%BaseName%","FileSystemProviderStrings") | Set-Content -Path $formatFilePath -Force + $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") + $ps.Streams.Error.Clear() + $ps.Invoke() + $ps.HadErrors | Should be $false + + } + It "Resources in CorePS syntax should be loaded successfully" { + $format = Get-Content -Path $templatePath -Raw + $format.Replace("%BaseName%","System.Management.Automation.resources.FileSystemProviderStrings") | Set-Content -Path $formatFilePath -Force + $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") + $ps.Streams.Error.Clear() + $ps.Invoke() + $ps.HadErrors | Should be $false + } + It "Verify assembly path in error message when resource is Not found" { + $format = Get-Content -Path $templatePath -Raw + $format.Replace("%BaseName%","NonExistingResource") | Set-Content -Path $formatFilePath -Force + $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") + $ps.Streams.Error.Clear() + $ps.Invoke() + $sma = [appdomain]::CurrentDomain.GetAssemblies() | ? { if ($_.Location) {$_.Location.EndsWith("System.Management.Automation.dll")}} + $smaLocation = $sma.Location + $ps.Streams.Error | %{ $_.Exception.Message.Contains($smaLocation) | Should be $true } + } + } +} \ No newline at end of file From b1bc8f9178099ac8f074dc3408415840c836033d Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 11 Jul 2017 12:00:55 -0700 Subject: [PATCH 2/6] PR feedback --- .../utils/ResourceManagerCache.cs | 2 +- .../Update-FormatData.Tests.ps1 | 7 ++++--- ...o.format.ps1xml => UpdateFormatDataTests.format.ps1xml} | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) rename test/powershell/Modules/Microsoft.PowerShell.Utility/{FileInfo.format.ps1xml => UpdateFormatDataTests.format.ps1xml} (97%) diff --git a/src/System.Management.Automation/utils/ResourceManagerCache.cs b/src/System.Management.Automation/utils/ResourceManagerCache.cs index 8a57eb08cf8..ca57990422d 100644 --- a/src/System.Management.Automation/utils/ResourceManagerCache.cs +++ b/src/System.Management.Automation/utils/ResourceManagerCache.cs @@ -201,7 +201,7 @@ internal static string GetResourceString( } else { - newBaseName = assembly.GetName().Name + resourcesSubstring + baseName; // e.g. "System.Management.Automation.resources.FileSystemProviderStrings" + newBaseName = string.Concat(assembly.GetName().Name, resourcesSubstring, baseName); // e.g. "System.Management.Automation.resources.FileSystemProviderStrings" } resourceManager = GetResourceManager(assembly, newBaseName); diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 index 135148a7f42..c9ad5b6c08e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 @@ -62,8 +62,8 @@ Describe "Update-FormatData basic functionality" -Tags "CI" { Describe "Update-FormatData with resources in CustomControls" -Tags "CI" { BeforeAll { - $templatePath = Join-Path $PSScriptRoot 'FileInfo.format.ps1xml' - $formatFilePath = Join-Path $TestDrive 'FileInfo.format.ps1xml' + $templatePath = Join-Path $PSScriptRoot 'UpdateFormatDataTests.format.ps1xml' + $formatFilePath = Join-Path $TestDrive 'UpdateFormatDataTests.format.ps1xml' $ps = [powershell]::Create() $iss = [system.management.automation.runspaces.initialsessionstate]::CreateDefault2() $rs = [system.management.automation.runspaces.runspacefactory]::CreateRunspace($iss) @@ -101,6 +101,7 @@ Describe "Update-FormatData with resources in CustomControls" -Tags "CI" { $sma = [appdomain]::CurrentDomain.GetAssemblies() | ? { if ($_.Location) {$_.Location.EndsWith("System.Management.Automation.dll")}} $smaLocation = $sma.Location $ps.Streams.Error | %{ $_.Exception.Message.Contains($smaLocation) | Should be $true } + $ps.Streams.Error | %{ $_.FullyQualifiedErrorId | Should Match 'FormatXmlUpdateException' } } } -} \ No newline at end of file +} diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/FileInfo.format.ps1xml b/test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml similarity index 97% rename from test/powershell/Modules/Microsoft.PowerShell.Utility/FileInfo.format.ps1xml rename to test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml index aafe851168d..85e289b8f30 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/FileInfo.format.ps1xml +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml @@ -85,4 +85,4 @@ - \ No newline at end of file + From baddeeb8e0b122fd67b20b196928440fc304b272 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 11 Jul 2017 14:48:17 -0700 Subject: [PATCH 3/6] Updated format ps1xml --- .../UpdateFormatDataTests.format.ps1xml | 63 +------------------ 1 file changed, 3 insertions(+), 60 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml b/test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml index 85e289b8f30..8d4091035c1 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml @@ -1,17 +1,16 @@ - FileSystemTypes + TestTypes - System.IO.DirectoryInfo - System.IO.FileInfo + NonExistingTestType - FileSystemTypes-GroupingFormat + TestTypes-GroupingFormat @@ -20,11 +19,6 @@ 0 - - - $_.PSParentPath.Replace("Microsoft.PowerShell.Core\FileSystem::", "") - - @@ -34,55 +28,4 @@ - - - - FileSystemItems - - FileSystemTypes - - - PSParentPath - FileSystemTypes-GroupingFormat - - - - - - 10 - left - - - - 25 - - - - 15 - right - - - - - - - - - Mode - - - LastWriteTime - - - Length - - - Name - - - - - - - From 4ed51b0bffbb148f80f47cca0274b48e8b43d18a Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Jul 2017 13:22:36 -0700 Subject: [PATCH 4/6] fixed tabs in indentation --- .../Update-FormatData.Tests.ps1 | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 index c9ad5b6c08e..baf75c16ac9 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 @@ -14,16 +14,16 @@ Describe "Update-FormatData" -Tags "CI" { } Context "Validate Update-FormatData update correctly" { - It "Should not throw upon reloading previous formatting file" { - { Update-FormatData } | Should Not throw - } + It "Should not throw upon reloading previous formatting file" { + { Update-FormatData } | Should Not throw + } - It "Should validly load formatting data" { - Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path $path + It "Should validly load formatting data" { + Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path $path $null = $ps.AddScript("Update-FormatData -prependPath $path") $ps.Invoke() $ps.HadErrors | Should be $false - } + } } } @@ -32,7 +32,7 @@ Describe "Update-FormatData basic functionality" -Tags "CI" { $testfilename = "testfile.ps1xml" $testfile = Join-Path -Path $TestDrive -ChildPath $testfilename - $xmlContent=@" + $xmlContent=@" AnyName @@ -48,14 +48,14 @@ Describe "Update-FormatData basic functionality" -Tags "CI" { "@ - $xmlContent > $testfile + $xmlContent > $testfile } - It "Update-FormatData with WhatIf should work"{ + It "Update-FormatData with WhatIf should work"{ { Update-FormatData -Append $testfile -WhatIf } | Should Not Throw { Update-FormatData -Prepend $testfile -WhatIf } | Should Not Throw - } + } } @@ -75,33 +75,33 @@ Describe "Update-FormatData with resources in CustomControls" -Tags "CI" { $ps.Dispose() } Context "Validate Update-FormatData" { - It "Resources in WindowsPS syntax should be loaded successfully" { - $format = Get-Content -Path $templatePath -Raw - $format.Replace("%BaseName%","FileSystemProviderStrings") | Set-Content -Path $formatFilePath -Force - $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") - $ps.Streams.Error.Clear() + It "Resources in WindowsPS syntax should be loaded successfully" { + $format = Get-Content -Path $templatePath -Raw + $format.Replace("%BaseName%","FileSystemProviderStrings") | Set-Content -Path $formatFilePath -Force + $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") + $ps.Streams.Error.Clear() $ps.Invoke() $ps.HadErrors | Should be $false - } - It "Resources in CorePS syntax should be loaded successfully" { - $format = Get-Content -Path $templatePath -Raw - $format.Replace("%BaseName%","System.Management.Automation.resources.FileSystemProviderStrings") | Set-Content -Path $formatFilePath -Force - $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") - $ps.Streams.Error.Clear() + } + It "Resources in CorePS syntax should be loaded successfully" { + $format = Get-Content -Path $templatePath -Raw + $format.Replace("%BaseName%","System.Management.Automation.resources.FileSystemProviderStrings") | Set-Content -Path $formatFilePath -Force + $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") + $ps.Streams.Error.Clear() $ps.Invoke() $ps.HadErrors | Should be $false - } - It "Verify assembly path in error message when resource is Not found" { - $format = Get-Content -Path $templatePath -Raw - $format.Replace("%BaseName%","NonExistingResource") | Set-Content -Path $formatFilePath -Force - $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") - $ps.Streams.Error.Clear() + } + It "Verify assembly path in error message when resource is Not found" { + $format = Get-Content -Path $templatePath -Raw + $format.Replace("%BaseName%","NonExistingResource") | Set-Content -Path $formatFilePath -Force + $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") + $ps.Streams.Error.Clear() $ps.Invoke() - $sma = [appdomain]::CurrentDomain.GetAssemblies() | ? { if ($_.Location) {$_.Location.EndsWith("System.Management.Automation.dll")}} - $smaLocation = $sma.Location - $ps.Streams.Error | %{ $_.Exception.Message.Contains($smaLocation) | Should be $true } - $ps.Streams.Error | %{ $_.FullyQualifiedErrorId | Should Match 'FormatXmlUpdateException' } - } + $sma = [appdomain]::CurrentDomain.GetAssemblies() | ? { if ($_.Location) {$_.Location.EndsWith("System.Management.Automation.dll")}} + $smaLocation = $sma.Location + $ps.Streams.Error | %{ $_.Exception.Message.Contains($smaLocation) | Should be $true } + $ps.Streams.Error | %{ $_.FullyQualifiedErrorId | Should Match 'FormatXmlUpdateException' } + } } } From 5bc33443f3437a82358877be04f74817bd2c3c48 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Jul 2017 13:50:49 -0700 Subject: [PATCH 5/6] PR feedback --- .../utils/ResourceManagerCache.cs | 57 ++++++++++--------- .../Update-FormatData.Tests.ps1 | 2 +- .../UpdateFormatDataTests.format.ps1xml | 0 3 files changed, 30 insertions(+), 29 deletions(-) rename test/powershell/Modules/Microsoft.PowerShell.Utility/{ => assets}/UpdateFormatDataTests.format.ps1xml (100%) diff --git a/src/System.Management.Automation/utils/ResourceManagerCache.cs b/src/System.Management.Automation/utils/ResourceManagerCache.cs index ca57990422d..cc9db9bae25 100644 --- a/src/System.Management.Automation/utils/ResourceManagerCache.cs +++ b/src/System.Management.Automation/utils/ResourceManagerCache.cs @@ -177,37 +177,38 @@ internal static string GetResourceString( throw PSTraceSource.NewArgumentException("resourceId"); } - ResourceManager resourceManager = null; - string text = string.Empty; - - // FYI: for a non-existing resource defined by {assembly,baseName,resourceId} - // MissingManifestResourceException is thrown only at the time when resource retrieval method such as ResourceManager.GetString or ResourceManager.GetObject is called, - // Not when you instantiate a ResourceManager object. - try - { - // try with original baseName + ResourceManager resourceManager = null; + string text = string.Empty; + + // For a non-existing resource defined by {assembly,baseName,resourceId} + // MissingManifestResourceException is thrown only at the time when resource retrieval method + // such as ResourceManager.GetString or ResourceManager.GetObject is called, + // not when you instantiate a ResourceManager object. + try + { + // try with original baseName first + // if it fails then try with alternative resource path format resourceManager = GetResourceManager(assembly, baseName); - text = resourceManager.GetString(resourceId); + text = resourceManager.GetString(resourceId); } catch (MissingManifestResourceException) - { - // original baseName failed; lets try with alternative resource path format - const string resourcesSubstring = ".resources."; - int resourcesSubstringIndex = baseName.IndexOf(resourcesSubstring); - string newBaseName = string.Empty; - if (resourcesSubstringIndex != -1) - { - newBaseName = baseName.Substring(resourcesSubstringIndex + resourcesSubstring.Length); // e.g. "FileSystemProviderStrings" - } - else - { - newBaseName = string.Concat(assembly.GetName().Name, resourcesSubstring, baseName); // e.g. "System.Management.Automation.resources.FileSystemProviderStrings" - } - - resourceManager = GetResourceManager(assembly, newBaseName); - text = resourceManager.GetString(resourceId); - } - + { + const string resourcesSubstring = ".resources."; + int resourcesSubstringIndex = baseName.IndexOf(resourcesSubstring); + string newBaseName = string.Empty; + if (resourcesSubstringIndex != -1) + { + newBaseName = baseName.Substring(resourcesSubstringIndex + resourcesSubstring.Length); // e.g. "FileSystemProviderStrings" + } + else + { + newBaseName = string.Concat(assembly.GetName().Name, resourcesSubstring, baseName); // e.g. "System.Management.Automation.resources.FileSystemProviderStrings" + } + + resourceManager = GetResourceManager(assembly, newBaseName); + text = resourceManager.GetString(resourceId); + } + if (String.IsNullOrEmpty(text) && s_DFT_monitorFailingResourceLookup) { Diagnostics.Assert(false, diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 index baf75c16ac9..591bfb016ea 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 @@ -62,7 +62,7 @@ Describe "Update-FormatData basic functionality" -Tags "CI" { Describe "Update-FormatData with resources in CustomControls" -Tags "CI" { BeforeAll { - $templatePath = Join-Path $PSScriptRoot 'UpdateFormatDataTests.format.ps1xml' + $templatePath = Join-Path $PSScriptRoot (Join-Path 'assets' 'UpdateFormatDataTests.format.ps1xml') $formatFilePath = Join-Path $TestDrive 'UpdateFormatDataTests.format.ps1xml' $ps = [powershell]::Create() $iss = [system.management.automation.runspaces.initialsessionstate]::CreateDefault2() diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml b/test/powershell/Modules/Microsoft.PowerShell.Utility/assets/UpdateFormatDataTests.format.ps1xml similarity index 100% rename from test/powershell/Modules/Microsoft.PowerShell.Utility/UpdateFormatDataTests.format.ps1xml rename to test/powershell/Modules/Microsoft.PowerShell.Utility/assets/UpdateFormatDataTests.format.ps1xml From 70d5bbd8ba4c1d4ae4389a6c067070e945f7d234 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 24 Jul 2017 12:57:25 -0700 Subject: [PATCH 6/6] minor update to verification in tests --- .../Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 index 591bfb016ea..3c54917f6e9 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Update-FormatData.Tests.ps1 @@ -81,7 +81,7 @@ Describe "Update-FormatData with resources in CustomControls" -Tags "CI" { $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") $ps.Streams.Error.Clear() $ps.Invoke() - $ps.HadErrors | Should be $false + $ps.Streams.Error | Should BeNullOrEmpty } It "Resources in CorePS syntax should be loaded successfully" { @@ -90,7 +90,7 @@ Describe "Update-FormatData with resources in CustomControls" -Tags "CI" { $null = $ps.AddScript("Update-FormatData -PrependPath $formatFilePath") $ps.Streams.Error.Clear() $ps.Invoke() - $ps.HadErrors | Should be $false + $ps.Streams.Error | Should BeNullOrEmpty } It "Verify assembly path in error message when resource is Not found" { $format = Get-Content -Path $templatePath -Raw