mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Clean up workflow logic in the module loading component (#6523)
Clean up workflow logic in the module loading component. Workflow module is not supported in PSCore. Currently, Import-Module throws a terminating error when seeing .xaml modules. After the change, Import-Module throws a non-terminating error when seeing .xaml modules.
This commit is contained in:
committed by
Travis Plunk
parent
610ae1a63f
commit
d1cf82ec20
@@ -146,7 +146,7 @@ namespace ModuleCmdlets
|
||||
|
||||
$psdFile = Join-Path $TESTDRIVE test.psd1
|
||||
$nestedModule = Join-Path NOExistedPath Microsoft.PowerShell.Commands.Utility.dll
|
||||
New-ModuleManifest -Path $psdFile -NestedModules $nestedModule
|
||||
New-ModuleManifest -Path $psdFile -NestedModules $nestedModule
|
||||
try
|
||||
{
|
||||
$module = Import-Module $psdFile -PassThru
|
||||
@@ -158,7 +158,7 @@ namespace ModuleCmdlets
|
||||
{
|
||||
Remove-Module $module -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,3 +200,34 @@ Describe "Import-Module should be case insensitive" -Tags 'CI' {
|
||||
Get-Module tESTmODULE | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Workflow .Xaml module is not supported in PSCore" -tags "Feature" {
|
||||
BeforeAll {
|
||||
$xamlFile = Join-Path $TestDrive "XamlTest.xaml"
|
||||
New-Item -Path $xamlFile -ItemType File -Force
|
||||
|
||||
$xamlRootModule = Join-Path $TestDrive "XamlRootModule"
|
||||
New-Item -Path $xamlRootModule -ItemType Directory -Force
|
||||
Copy-Item $xamlFile $xamlRootModule
|
||||
$xamlRootModuleManifest = Join-Path $xamlRootModule "XamlRootModule.psd1"
|
||||
New-ModuleManifest -Path $xamlRootModuleManifest -RootModule "XamlTest.xaml"
|
||||
|
||||
$xamlNestedModule = Join-Path $TestDrive "XamlNestedModule"
|
||||
New-Item -Path $xamlNestedModule -ItemType Directory -Force
|
||||
Copy-Item $xamlFile $xamlNestedModule
|
||||
$xamlNestedModuleManifest = Join-Path $xamlNestedModule "XamlNestedModule.psd1"
|
||||
New-ModuleManifest -Path $xamlNestedModuleManifest -NestedModules "XamlTest.xaml"
|
||||
}
|
||||
|
||||
It "Import a XAML file directly should raise a 'NotSupported' error" {
|
||||
{ Import-Module $xamlFile -ErrorAction Stop } | Should -Throw -ErrorId "Modules_WorkflowModuleNotSupported,Microsoft.PowerShell.Commands.ImportModuleCommand"
|
||||
}
|
||||
|
||||
It "Import a module with XAML root module should raise a 'NotSupportd' error" {
|
||||
{ Import-Module $xamlRootModule -ErrorAction Stop } | Should -Throw -ErrorId "Modules_WorkflowModuleNotSupported,Microsoft.PowerShell.Commands.ImportModuleCommand"
|
||||
}
|
||||
|
||||
It "Import a module with XAML nested module should raise a 'NotSupported' error" {
|
||||
{ Import-Module $xamlNestedModule -ErrorAction Stop } | Should -Throw -ErrorId "Modules_WorkflowModuleNotSupported,Microsoft.PowerShell.Commands.ImportModuleCommand"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user