Skip to content

Commit

Permalink
Merge pull request #1041 from Ana06/improve_test
Browse files Browse the repository at this point in the history
Improve test_install script
  • Loading branch information
Ana06 authored May 21, 2024
2 parents be78550 + 3cc3ffc commit caf4585
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions scripts/test/test_install.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,15 +27,23 @@ $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") {
$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
}
Expand Down Expand Up @@ -69,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"
Expand Down

0 comments on commit caf4585

Please sign in to comment.