From bd5c95a330ff802cd33d2d7e34e6e5a03333a2e9 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Thu, 15 Aug 2024 09:40:15 -0700 Subject: [PATCH] (#3461,#3487) Add an all packages source for tests We have added some tests for the install all command. This adds a new package source to the testing environment so that we can run the tests locally and in Test Kitchen. --- Invoke-Tests.ps1 | 27 +++++++++++++++++++++++++-- tests/Vagrantfile | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Invoke-Tests.ps1 b/Invoke-Tests.ps1 index d6ce96f030..8d2044732a 100644 --- a/Invoke-Tests.ps1 +++ b/Invoke-Tests.ps1 @@ -54,12 +54,34 @@ else { if (-not (Test-Path "$TestPath/packages") -or -not $SkipPackaging) { $null = New-Item -Path "$TestPath/packages" -ItemType Directory -Force # Get and pack packages - $nuspecs = Get-ChildItem -Path $PSScriptRoot/src/chocolatey.tests.integration, $PSScriptRoot/tests/packages -Recurse -Include *.nuspec | Where-Object FullName -notmatch 'bin' + $nuspecs = Get-ChildItem -Path $PSScriptRoot/src/chocolatey.tests.integration, $PSScriptRoot/tests/packages -Recurse -Include *.nuspec | Where-Object FullName -NotMatch 'bin' Get-ChildItem -Path $PSScriptRoot/tests/packages -Recurse -Include *.nupkg | Copy-Item -Destination "$TestPath/packages" foreach ($file in $nuspecs) { Write-Host "Packaging $file" - $null = choco pack $file.FullName --out "$TestPath/packages" + # Include allow-unofficial in case an unofficial Chocolatey has been installed globally for testing + $null = choco pack $file.FullName --out "$TestPath/packages" --allow-unofficial + } +} + +if (-not (Test-Path "$TestPath/all-packages") -or -not $SkipPackaging) { + $null = New-Item -Path "$TestPath/all-packages" -ItemType Directory -Force + + # These are the package ids that are loaded into the all packages test repository. + $AllPackagesRepository = @( + 'isdependency' + 'hasdependency' + 'hasnesteddependency' + # These packages may be causing issues with the install all... + 'downgradesdependency' + 'dependencyfailure' + 'hasfailingnesteddependency' + 'failingdependency' + 'isexactversiondependency' + ) + + foreach ($package in $AllPackagesRepository) { + $null = Copy-Item "$TestPath/packages/$package.*.nupkg" "$TestPath/all-packages/" } } @@ -97,6 +119,7 @@ try { Import-Module $PSScriptRoot\tests\helpers\common-helpers.psm1 -Force $null = Invoke-Choco source add --name hermes --source "$TestPath/packages" + $null = Invoke-Choco source add --name hermes-all --source "$TestPath/all-packages" Enable-ChocolateyFeature -Name allowGlobalConfirmation $PesterConfiguration = [PesterConfiguration]@{ Run = @{ diff --git a/tests/Vagrantfile b/tests/Vagrantfile index a6bd2bf065..ceef065bc1 100644 --- a/tests/Vagrantfile +++ b/tests/Vagrantfile @@ -69,6 +69,7 @@ Vagrant.configure("2") do |config| config.vm.provision "shell", name: "clear-packages", inline: <<-SHELL Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Clearing the packages directory" Remove-Item "$env:TEMP/chocolateyTests/packages" -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item "$env:TEMP/chocolateyTests/all-packages" -Recurse -Force -ErrorAction SilentlyContinue SHELL config.vm.provision "shell", name: "test", inline: <<-SHELL # Copy changed files.