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

Fails to exclude source files from HQRM tests #142

Open
johlju opened this issue Nov 19, 2024 · 1 comment
Open

Fails to exclude source files from HQRM tests #142

johlju opened this issue Nov 19, 2024 · 1 comment

Comments

@johlju
Copy link
Member

johlju commented Nov 19, 2024

Details of the scenario you tried and the problem that is occurring

When running the HQRM test for a repo using Pester 4 it seems it fails to exclude source files that are excluded in the build configuration.

Se more information in PR dsccommunity/SharePointDsc#1440.

Steps to reproduce the problem

In a source file suppress the rule PSAvoidUsingWriteHost, for example in the source file in the relative path SharePointDsc/Modules/SharePointDsc.Reverse/SharePointDsc.Reverse.psm1:

[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function', Target = '*')]
param ()

Then try to exclude the relative path in the build configuration:

DscTest:
  ExcludeSourceFile:
    - output
    - 'SharePointDsc/Modules/SharePointDsc.Reverse/SharePointDsc.Reverse.psm1'

Expected behavior

Should exclude the file and the tests should not fail.

Current behavior

Does not exclude the file and the test fails due to suppressing a required rule.

Suggested solution to the issue

It should exclude the source files according to the code but it doesn't happen. Haven't debugged so not sure where the issue is.

It should filter out the excluded files here:

$dscResourcesPsm1Files = @(Get-ChildItem -Path $SourcePath -Include *.psm1 -Recurse | WhereSourceFileNotExcluded)

Using the filter:

filter WhereSourceFileNotExcluded

The operating system the target node is running

Windows and also using Pester 4

Version and build of PowerShell the target node is running

PowerShell 5.1

Version of the module that was used

v0.16.3

@dan-hughes
Copy link
Contributor

$ExcludeSourceFile is not passed down to/available in the filter. I think the logic on the if statement is broken too, but without the exclusions being seen in the filter it never does anything.

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

Successfully merging a pull request may close this issue.

2 participants