From 2f3c7f6fc5a35331c5983c466756f22b9b875f47 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 15 May 2024 11:09:58 +0200 Subject: [PATCH 1/3] [test_install] Support lnk for packages directory Allow the `packages` folder in the same directory to be a link to the actual directory. This is useful when testing packages in a shared folder. --- scripts/test/test_install.ps1 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/test/test_install.ps1 b/scripts/test/test_install.ps1 index eb617d6a6..3d48d7df6 100644 --- a/scripts/test/test_install.ps1 +++ b/scripts/test/test_install.ps1 @@ -1,6 +1,8 @@ -# Build the packages in the 'packages' directory given as argument (or all if none provided) into the 'built_pkgs'. -# Install the built packages. If a package install fails and the $all switch is not provided, -# the rest of the packages are not installed +# Build the packages in the 'packages' directory (or lnk to directory) given as +# argument (or all if none provided) into the 'built_pkgs'. +# Install the built packages. +# If a package install fails and the $all switch is not provided, +# the rest of the packages are not installed. # Examples ## ./test_install @@ -26,14 +28,20 @@ $result_file = "success_failure.json" $root = Get-Location $built_pkgs_dir = New-Item -ItemType Directory -Force $built_pkgs_dir_name +$packages_dir = (Get-Item "$packages_dir_name*")[0] +if ($packages_dir.Extension -eq ".lnk") { + $shell = New-Object -ComObject WScript.Shell + $packages_dir = $shell.CreateShortcut($packages_dir).TargetPath +} + if ($package_names) { $packages = $package_names.Split(" ") } else { - $packages = Get-ChildItem -Path $packages_dir_name | Select-Object -ExpandProperty Name + $packages = Get-ChildItem -Path $packages_dir | Select-Object -ExpandProperty Name } foreach ($package in $packages) { - Set-Location "$root\$packages_dir_name\$package" + Set-Location "$packages_dir\$package" choco pack -y -out $built_pkgs_dir if ($LASTEXITCODE -ne 0) { Exit 1 } # Abort with the first failing build } From 5ff7df5125e80c0d359865d8431acea4780b64f0 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 15 May 2024 11:12:17 +0200 Subject: [PATCH 2/3] [test_install] Delete packages in built_pkgs Delete previously built packages in `built_pkgs` to avoid testing old packages. --- scripts/test/test_install.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/test/test_install.ps1 b/scripts/test/test_install.ps1 index 3d48d7df6..0edc63106 100644 --- a/scripts/test/test_install.ps1 +++ b/scripts/test/test_install.ps1 @@ -27,6 +27,8 @@ $result_file = "success_failure.json" $root = Get-Location $built_pkgs_dir = New-Item -ItemType Directory -Force $built_pkgs_dir_name +# Delete previously built packages to avoid testing old packages +Remove-Item "$built_pkgs_dir\*" -Force -ea 0 | Out-Null $packages_dir = (Get-Item "$packages_dir_name*")[0] if ($packages_dir.Extension -eq ".lnk") { From 3cc3ffc7316b34bf36865186271e923220f4ac59 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 15 May 2024 11:56:40 +0200 Subject: [PATCH 3/3] [test_install] Simplify restoring location `-PassThru` displays the location and `| Out-Null` discard the output, so we can remove both to simplify this command. --- scripts/test/test_install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test/test_install.ps1 b/scripts/test/test_install.ps1 index 0edc63106..a77bade4c 100644 --- a/scripts/test/test_install.ps1 +++ b/scripts/test/test_install.ps1 @@ -79,7 +79,7 @@ foreach ($package in $built_pkgs) { } # Restore the original location -Set-Location -Path $root -PassThru | Out-Null +Set-Location $root Write-Host -ForegroundColor Green "`nSUCCESS:$success" Write-Host -ForegroundColor Red "FAILURE:$failed"