Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected override void ProcessRecord()
{
foreach (ModuleSpecification requiredModule in requiredModules)
{
var modules = GetModule(new[] { requiredModule.Name }, false, true);
var modules = GetModule(new[] { requiredModule.Name }, all: false, refresh: true);
if (modules.Count == 0)
{
string errorMsg = StringUtil.Format(Modules.InvalidRequiredModulesinModuleManifest, requiredModule.Name, filePath);
Expand Down Expand Up @@ -216,7 +216,7 @@ protected override void ProcessRecord()
{
foreach (ModuleSpecification moduleListModule in moduleListModules)
{
var modules = GetModule(new[] { moduleListModule.Name }, true, true);
var modules = GetModule(new[] { moduleListModule.Name }, all: false, refresh: true);
if (modules.Count == 0)
{
string errorMsg = StringUtil.Format(Modules.InvalidModuleListinModuleManifest, moduleListModule.Name, filePath);
Expand Down
26 changes: 26 additions & 0 deletions test/powershell/engine/Module/TestModuleManifest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,29 @@ Describe "Tests for circular references in required modules" -tags "CI" {
{ TestImportModule $false $false $true } | ShouldBeErrorId "Modules_InvalidManifest,Microsoft.PowerShell.Commands.ImportModuleCommand"
}
}

Describe "Test-ModuleManifest Performance bug followup" -tags "CI" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

BeforeAll {
$TestModulesPath = [System.IO.Path]::Combine($PSScriptRoot, 'assets', 'testmodulerunspace')
$UserModulesPath = "$pshome\Modules"

# Install the Test Module
Copy-Item $TestModulesPath\* $UserModulesPath -Recurse -Force
}

It "Test-ModuleManifest should not load unnessary modules" {

$job = start-job -name "job1" -ScriptBlock {test-modulemanifest "$using:UserModulesPath\ModuleWithDependencies2\2.0\ModuleWithDependencies2.psd1" -verbose} | Wait-Job

$verbose = $job.ChildJobs[0].Verbose.ReadAll()
# Before the fix, all modules under $pshome will be imported and will be far more than 15 verbose messages. However, we cannot fix the number in case verbose message may vary.
$verbose.Count | Should BeLessThan 15
}

AfterAll {
#clean up the test modules
Remove-Item $UserModulesPath\ModuleWithDependencies2 -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $UserModulesPath\NestedRequiredModule1 -Recurse -Force -ErrorAction SilentlyContinue
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

@{

# Version number of this module.
ModuleVersion = '2.0'

# ID used to uniquely identify this module
GUID = '0eae34da-99dd-4608-8d28-c614fe7b0841'

# Author of this module
Author = 'manikb'

# Company or vendor of this module
CompanyName = 'Unknown'

# Copyright statement for this module
Copyright = '(c) 2015 manikb. All rights reserved.'

# Description of the functionality provided by this module
Description = 'ModuleWithDependencies2 module'

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @('NestedRequiredModule1')

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('NestedRequiredModule1')

# Functions to export from this module
FunctionsToExport = @()

# Cmdlets to export from this module
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = @()

# Aliases to export from this module
AliasesToExport = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Tag1', 'Tag2', 'Tag-ModuleWithDependencies2-2.0'

# A URL to the license for this module.
LicenseUri = 'http://modulewithdependencies2.com/license'

# A URL to the main website for this project.
ProjectUri = 'http://modulewithdependencies2.com/'

# A URL to an icon representing this module.
IconUri = 'http://modulewithdependencies2.com/icon'

# ReleaseNotes of this module
ReleaseNotes = 'ModuleWithDependencies2 release notes'

} # End of PSData hashtable

} # End of PrivateData hashtable

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

@{

# Version number of this module.
ModuleVersion = '2.5'

# ID used to uniquely identify this module
GUID = '369f0ee4-4cda-4ac3-a5c5-08e7bbc06e1a'

# Author of this module
Author = 'manikb'

# Company or vendor of this module
CompanyName = 'Unknown'

# Copyright statement for this module
Copyright = '(c) 2015 manikb. All rights reserved.'

# Description of the functionality provided by this module
Description = 'NestedRequiredModule1 module'

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('NestedRequiredModule1.psm1')

# Functions to export from this module
FunctionsToExport = @()

# Cmdlets to export from this module
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = @()

# Aliases to export from this module
AliasesToExport = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Tag1', 'Tag2', 'Tag-NestedRequiredModule1-2.5'

# A URL to the license for this module.
LicenseUri = 'http://nestedrequiredmodule1.com/license'

# A URL to the main website for this project.
ProjectUri = 'http://nestedrequiredmodule1.com/'

# A URL to an icon representing this module.
IconUri = 'http://nestedrequiredmodule1.com/icon'

# ReleaseNotes of this module
ReleaseNotes = 'NestedRequiredModule1 release notes'

} # End of PSData hashtable

} # End of PrivateData hashtable

}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function Get-NestedRequiredModule1 { Get-Date }