mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Ensure assemblies listed FileList are not loaded (#12968)
Co-authored-by: Aditya Patwardhan <Aditya Patwardhan>
This commit is contained in:
co-authored by
Aditya Patwardhan
parent
0c8aa53a90
commit
808bf22d2f
@@ -361,3 +361,36 @@ Describe "Import-Module -Force behaviour" -Tag "CI" {
|
||||
{ Test-Two } | Should -Throw -ErrorId 'CommandNotFoundException'
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Module with FileList" -Tag "CI" {
|
||||
BeforeAll {
|
||||
$src = @"
|
||||
using System;
|
||||
namespace ModuleCmdlets
|
||||
{
|
||||
public class FileListLoad
|
||||
{
|
||||
}
|
||||
}
|
||||
"@
|
||||
|
||||
$originalPSModulePath = $env:PSModulePath
|
||||
New-Item -ItemType Directory -Path "$testdrive\Modules\FileListLoadTest\" -Force > $null
|
||||
|
||||
$asmPath = "$TESTDRIVE\Modules\FileListLoadTest\FileListLoadTest.dll"
|
||||
Add-Type -TypeDefinition $src -OutputAssembly $asmPath
|
||||
|
||||
$env:PSModulePath += [System.IO.Path]::PathSeparator + "$testdrive\Modules"
|
||||
New-ModuleManifest -Path "$testdrive\Modules\FileListLoadTest\FileListLoadTest.psd1" -FileList @("FileListLoadTest.dll")
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
$env:PSModulePath = $originalPSModulePath
|
||||
}
|
||||
|
||||
It "Assemblies in FileList are not loaded" {
|
||||
Import-Module FileListLoadTest
|
||||
$asms = [System.AppDomain]::CurrentDomain.GetAssemblies().Location
|
||||
$asmPath | Should -Not -BeIn $asms
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user