Skip to content

Parallell bug #2816

Description

@nohwnd

@nohwnd I have an edge case that fails when running in parallel. One of my modules that I use for infrastructure testing KBInfrastructureTesting requires specific version of Pester in the manifest:

RequiredModules = @(
    @{ModuleName = 'KBActiveDirectory'; ModuleVersion = '7.0.0'},
    @{ModuleName = 'KBSystemFunctions'; ModuleVersion = '7.0.0'},
    @{ModuleName = 'KBSystemManagement'; ModuleVersion = '7.0.0'},
    @{ModuleName = 'KBServiceManagement'; ModuleVersion = '7.0.0'},
    @{ModuleName = 'KBDomainComputerManagement'; ModuleVersion = '7.0.0'},
    @{ModuleName = 'Pester'; ModuleVersion = '5.7.1'},
    @{ModuleName = 'PowerShellHumanizer'; ModuleVersion = '13.2.1'},
    'SQLServer',
    'Microsoft.PowerShell.ThreadJob'
)

In one of my tests I'm testing module import, and this fails now:

Context 'Module Import' {
    It '[<_.Name>] Module imports successfully' {
        {Import-Module -ModuleInfo $_ -Force -Verbose:$false -ErrorAction Stop} |
            Should -Not -Throw
    }
}

The error:

[Bukem@VOYAGER]≥# gmo KBInfrastructureTesting -ListAvailable | Test-KBModule -Tag Manifest
Running tests from 1 files in parallel.
[-] Manifest Specification In Module: "KBInfrastructureTesting".Module Integrity.Manifest Property.Module Import.[KBInfrastructureTesting] Module imports successfully 2.87s
 Expected no exception to be thrown, but an exception "The required module 'Pester' was not loaded because no valid module file was found in any module directory." was thrown from D:\Users\Bukem\Documents\PowerShell\.projects\Modules\KBDevelopmentTools\Integration\01-Manifest.Tests.ps1:236 char:22
     + …            {Import-Module -ModuleInfo $_ -Force -Verbose:$false -Erro …
     +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
Tests completed in 4.42s
Tests Passed: 21, Failed: 1, Skipped: 0, Inconclusive: 0, NotRun: 0
Exception: Pester run failed, because 1 test failed

The fix is easy. I could move the Pester module specification from RequiredModules to ExternalModuleDependecies and then check for the required version in the root module. But I just wanted to let you know anyways.

Originally posted by @kborowinski in #2795

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions