Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleHelp.Tests.ps1 throws false positives #1417

Closed
Jawz84 opened this issue Feb 17, 2020 · 4 comments · Fixed by #1418
Closed

ModuleHelp.Tests.ps1 throws false positives #1417

Jawz84 opened this issue Feb 17, 2020 · 4 comments · Fixed by #1418

Comments

@Jawz84
Copy link
Contributor

Jawz84 commented Feb 17, 2020

There are small problems in the ModuleHelp.Tests.ps1 file when running tests on Pwsh, or running on an environment without PSScriptAnalyzer actually installed.

affected areas:

  1. test failure when PSScriptAnalyzer is not installed (only loaded from the .\out\ directory)
  2. test failure on Pwsh due to non-supported 'Workspace' command type

Steps to reproduce

  1. on a system without PSScriptAnalyzer module installed
  2. when build configuration is set to DEBUG
.\PSScriptAnalyzer\build.ps1
.\PSScriptAnalyzer\build.ps1 -Test

Expected behavior

  1. No test failures
  2. No test failures

Actual behavior

  1. Test fails to properly check module version, because it was not installed, only loaded from .\PSScriptAnalyzer\out\
  2. Test fails with an error that the 'AttachAndDebug' parameter for Invoke-ScriptAnalyzer and Invoke-Formatter does not have Help.
@SydneyhSmith
Copy link
Collaborator

@Jawz84 thanks for opening this issue and linking the PR

bergmeister pushed a commit that referenced this issue Feb 25, 2020
* fix modulehelp false positives

When looking up module version, if the module is not installed, also check if it is loaded and get module version from loaded module
Add 'AttachAndDebug' to paramBlackList, so it does not throw false positives for DEBUG builds.
Small bugfix for the actual blacklist check, the property 'name' of the $parameter variable needs to be used to check against the blacklist.

* undo check for loaded module, because $env:psmodulepath is set to .\out\ module during testing, the built module will always appear 'installed'.

* simplify command discovery
@bergmeister
Copy link
Collaborator

Yes, thanks, I've merged it in now. I've changed the labels though from bug to build as this is not a bug in the actual product but rather the internal build/test system

@Jawz84
Copy link
Contributor Author

Jawz84 commented Feb 25, 2020

Thanks for taking the time to write that, I understand you had to try a few times and do it from mobile because it wouldn't work from desktop 👍

@bergmeister
Copy link
Collaborator

No worries, that problem I mentioned on Twitter earlier applied to this much bigger comment actually (where I decide to just copy paste the text into a draft email to be able to copy paste from my mobile...) 😅 Commenting works now again from Desktop :-) I've seen some of the updates in your other PR and want to take some time this week to fully review it but from a glance it looks already good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants