From 083eafed110d072d1d9039ca0f0a792f741c0270 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Wed, 22 May 2024 11:47:08 -0700 Subject: [PATCH] (maint) Update Test Developer Experience Enhance the local testing process for developers. Instead of building all nuspec files we find, filter out ones that may have been built as part of previous tests. Update the vagrantfile to copy over changed files when running the test provisioner, but only purge the tests directory. Update the vagrantfile to set a hostname on the VM to prevent on-screen error messages that don't seem to affect anything. --- Invoke-Tests.ps1 | 4 ++-- tests/Vagrantfile | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Invoke-Tests.ps1 b/Invoke-Tests.ps1 index 4dbbbec82..3ba4e5bb5 100644 --- a/Invoke-Tests.ps1 +++ b/Invoke-Tests.ps1 @@ -1,4 +1,4 @@ -#Requires -Module @{ ModuleName = 'pester'; ModuleVersion = '5.3.1' } +#Requires -Module @{ ModuleName = 'pester'; ModuleVersion = '5.3.1' } #Requires -RunAsAdministrator <# .SYNOPSIS @@ -50,7 +50,7 @@ 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 + $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) { diff --git a/tests/Vagrantfile b/tests/Vagrantfile index ad4b21aa3..a6bd2bf06 100644 --- a/tests/Vagrantfile +++ b/tests/Vagrantfile @@ -3,6 +3,8 @@ Vagrant.configure("2") do |config| config.vm.box = "StefanScherer/windows_2022" + # Set Hostname to prevent error messages. https://github.com/hashicorp/vagrant/issues/12644 + config.vm.hostname = 'chocolatey-tests' config.vm.boot_timeout = 600 # windows @@ -54,7 +56,7 @@ Vagrant.configure("2") do |config| $null = robocopy c:/chocoRoot c:/code/choco /e /copy:dt /purge Push-Location c:/code/choco Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Files have been copied, beginning build process." - $CakeOutput = ./build.bat 2>&1 + $CakeOutput = ./build.bat --verbosity=diagnostic --target=CI --testExecutionType=none --shouldRunalyze=false --shouldRunNuGet=false 2>&1 if ($LastExitCode -ne 0) { Set-Content c:/vagrant/buildOutput.log -Value $CakeOutput @@ -69,6 +71,9 @@ Vagrant.configure("2") do |config| Remove-Item "$env:TEMP/chocolateyTests/packages" -Recurse -Force -ErrorAction SilentlyContinue SHELL config.vm.provision "shell", name: "test", inline: <<-SHELL + # Copy changed files. + $null = robocopy c:/chocoRoot c:/code/choco /e /copy:dt + # Purge any tests files that have been removed. $null = robocopy c:/chocoRoot/tests c:/code/choco/tests /e /copy:dt /purge Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Starting Test Execution" Push-Location c:/code/choco