Test-ModuleManifest should not load unnecessary modules#4541
Test-ModuleManifest should not load unnecessary modules#4541daxian-dbw merged 3 commits intoPowerShell:masterfrom
Conversation
69f192f to
5b61238
Compare
There was a problem hiding this comment.
Something is wrong with your change in this file. The diff is messed up.
daxian-dbw
left a comment
There was a problem hiding this comment.
Please fix the change in TestModuleManifestCommand.cs
|
@daxian-dbw code file format fixed |
|
@chunqingchen Thanks! Will continue the review. |
daxian-dbw
left a comment
There was a problem hiding this comment.
The test assert folder testmodulerunspace should be moved to engine\Module\assets folder. Create assets folder if it doesn't exist.
All test assets should follow this pattern, take a look at the test\powershell\engine\Help\assets folder as an example.
There was a problem hiding this comment.
Setup should go in BeforeAll block.
There was a problem hiding this comment.
Cleanup should go in AfterAll block.
There was a problem hiding this comment.
This is not UserModulePath. If you want to use the Module folder that's next to powershell.exe, then replace ...currentdomain.basedirectory with $pshome.
And also, there is no need to use $script: for this variable.
There was a problem hiding this comment.
Setup should go in BeforeAll
There was a problem hiding this comment.
this catch doesn't seem necessary -- if it just rethrows the exception, why would you catch it?
There was a problem hiding this comment.
Don't you need to wait for the job to finish to read all verbose message?
There was a problem hiding this comment.
What does the number 50 mean here? Why do you think -le 50 means it doesn't load unnecessary modules?
There was a problem hiding this comment.
Prior to the fix test-modulemanifest will load all the modules in the $pshome, creating a far more big verbose list.
50 is a random small number that small enough to make sure the issue doesn't repro.
It can't be fixed as well since the verbose message contains other information that may vary.
I've changed the number to an even smaller number 15.
There was a problem hiding this comment.
Can you please remove all comments in this file? They make it hard to see what fields are actually used.
There was a problem hiding this comment.
Same here, please remove all comments.
There was a problem hiding this comment.
I don't see this file used in ModuleWithDependencies2.psd1, is it really needed?
There was a problem hiding this comment.
this is a sync fix of the bug fix under windows bug 7980238.
so I would prefer to keep the code the way the original fix was
There was a problem hiding this comment.
I think they should be made named parameters (as well as the other GetModule call in the same file). We don't make any changes to the original fix when re-submitting it for the sake of less churn. Now when making changes to the Github code base, we want the changes to follow best practices.
There was a problem hiding this comment.
The comment regarding named parameters is not resolved yet.
There was a problem hiding this comment.
Please fix indentation
There was a problem hiding this comment.
Do not need \Modules, Modules should be sufficient
There was a problem hiding this comment.
Join-path "$pshome\Modules"
Does this call to Join-Path even work?
There was a problem hiding this comment.
You should use BeLessThan here. See https://github.com/pester/Pester/wiki/Should#belessthan
There was a problem hiding this comment.
And please put your rational about using the number '15' in comments here, so that people look at this code later will understand it.
There was a problem hiding this comment.
There are so many comments in this file that you haven't deleted yet.
There was a problem hiding this comment.
i thought you mean the comments added in addition to the auto generated ones. resolved.
45d680f to
ab26a46
Compare
|
@daxian-dbw @adityapatwardhan your comments are resolved |
There was a problem hiding this comment.
typo frefresh -> refresh
There was a problem hiding this comment.
resolved, thank you
There was a problem hiding this comment.
This can be
$TestModulesPath = Join-path -Path "$PSScriptRoot\assets" -ChildPath $TestModulesFolder -AdditionalChildPath 'testmodulerunspace'There was a problem hiding this comment.
I didn't get it. Any good besides it putting two lines into one? It also throws error once I copied it. Can we just skip this comment?
There was a problem hiding this comment.
This should be FunctionsToExport = @()
There was a problem hiding this comment.
resolved, thanks
There was a problem hiding this comment.
This should be CmdletsToExport = @()
There was a problem hiding this comment.
This should be AliasesToExport = @()
There was a problem hiding this comment.
Same comments as the other module.
There was a problem hiding this comment.
Should be -ErrorAction SilentlyContinue
There was a problem hiding this comment.
resolved, thanks
There was a problem hiding this comment.
Should be -ErrorAction SilentlyContinue
| @@ -0,0 +1 @@ | |||
| function Get-NestedRequiredModule1 { Get-Date } No newline at end of file | |||
There was a problem hiding this comment.
missing new line at end of file.
Fix issue #4533
Summary of the issue:
Test-ModuleManifest is loading unnecessary modules
Fix:
Change the recursive loading flag from 'true' to 'false'