Skip to content

Commit

Permalink
(maint) Update Test Developer Experience
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
corbob committed May 22, 2024
1 parent ae60a79 commit 083eafe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Invoke-Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Module @{ ModuleName = 'pester'; ModuleVersion = '5.3.1' }
#Requires -Module @{ ModuleName = 'pester'; ModuleVersion = '5.3.1' }
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion tests/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 083eafe

Please sign in to comment.