Skip to content

Some tests do not perform proper Module cleanup #11058

@anmenaga

Description

@anmenaga

In CI we run several different test suites in the same PS runspace.
Some tests do Not cleanup after themselves, leaving loaded modules they were working with.
Sometimes this produces unexpected results and breaks subsequent tests.

Steps to reproduce

  1. add get-module in the beginning of each test file
  2. run tests, notice any non-standard modules
  3. find tests, where those modules are used, and update them with a proper cleanup

Actual behavior

here is example output listing modules that are loaded in the beginning of an unrelated test file

VERBOSE: Listing all loaded modules:
certificateCommon - 
CimCmdlets
HelpersCommon
HelpersRemoting
HelpersSecurity
ImportTrustedManifestWithCallOperator_System32
ImportTrustedManifestWithCmdletExport_System32
ImportTrustedManifestWithDotSourceModAndFnExport_System32
ImportTrustedManifestWithExportFn_System32
ImportTrustedManifestWithNestedModsAndFnExport_System32
ImportTrustedManifestWithNestedModsAndNoExtNoFnExport_System32
ImportTrustedManifestWithNestedModsAndNoFnExport_System32
ImportTrustedManifestWithNoFnExport_System32
ImportTrustedManifestWithTwoMods_System32
ImportTrustedManifestWithWildcardFnExport1_System32
ImportTrustedManifestWithWildcardModFnExport_System32
ImportTrustedManifestWithWildcardNameFnExport_System32
ImportTrustedModuleForTest_System32
ImportTrustedModuleTest_System32
ImportTrustedModuleWithFnExport_System32
ImportTrustedModuleWithNoFnExport_System32
ImportTrustedModuleWithWildcardFnExport_System32
ImportUntrustedManifestWithFnExport
ImportUnTrustedManifestWithFnExport_System32
ImportUntrustedManifestWithNoFnExport
ImportUnTrustedModuleWithFnExport
ImportUnTrustedModuleWithNoFnExport
Microsoft.PowerShell.Archive
Microsoft.PowerShell.Management
Microsoft.PowerShell.Security
Microsoft.PowerShell.Utility
Microsoft.WSMan.Management
ModuleDotSourceNestedExport_System32
ModuleDotSourceNoExportE_System32
ModuleDotSourceNoWildcard_System32
ModuleDotSourceWildcard_System32
ModuleDotSourceWildCardM_System32
ModuleWithUsing_System32
PackageManagement
Pester
pkiTrue
PSDiagnostics
PSSysLog
TestImport
ThreadJob
TrustedImportModule_System32
TrustedParentModule_System32
UntrustedModuleScriptBlockTest
UntrustedScriptFoo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Quality-Testissues in a test or in test infrastructure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions