mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-22 15:42:20 +03:00
Add PS1 checks on error handling
This commit is contained in:
parent
290a7564d7
commit
02eb244d1d
@ -32,6 +32,19 @@ while read -r script ; do
|
||||
fi
|
||||
done < <(find . -type f -name "*.sh")
|
||||
|
||||
# Check *PS1 error handling at line 2
|
||||
echo "------------------------------------------------------------------------------------------"
|
||||
while read -r script ; do
|
||||
if [ "$(head -1 "$script" | grep -c "Set-StrictMode -Version latest" || true)" -eq 0 ] ; then
|
||||
echo "Missing [Set-StrictMode -Version latest] in first line of ${color_red}${script}${color_reset}"
|
||||
((errors_count++))
|
||||
fi
|
||||
if [ "$(head -2 "$script" | tail -1 | grep -c "\$ErrorActionPreference = 'Stop'" || true)" -eq 0 ] ; then
|
||||
echo "Missing [\$ErrorActionPreference = 'Stop'] in second line of ${color_red}${script}${color_reset}"
|
||||
((errors_count++))
|
||||
fi
|
||||
done < <(find . -type f -name "*.PS1")
|
||||
|
||||
# Control errors count
|
||||
if [ "${errors_count}" -gt 0 ] ; then
|
||||
exit 1
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- context -----"
|
||||
|
||||
# get windows infos
|
||||
@ -8,9 +11,12 @@ Get-ComputerInfo -Property WindowsProductName,WindowsVersion,OsHardwareAbstracti
|
||||
|
||||
# get vcpkg infos
|
||||
vcpkg --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# get python infos
|
||||
python -V
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# get cargo info
|
||||
cargo --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
@ -1,12 +1,21 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- install system prerequisites -----"
|
||||
|
||||
# install libxml and libcurl[openssl]
|
||||
$vcpkg_dir=(Get-command vcpkg).Source
|
||||
if (Test-Path $vcpkg_dir\installed\x64-windows\bin\libssl-3-x64.dll) {echo "curl[openssl] already installed"} else {vcpkg install --recurse curl[openssl]:x64-windows}
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
if (Test-Path $vcpkg_dir\installed\x64-windows\bin\libxml2.dll) {echo "libxml2 already installed"} else {vcpkg install --recurse libxml2:x64-windows}
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
vcpkg update
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
vcpkg upgrade --no-dry-run
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
vcpkg integrate install
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# update pip
|
||||
python -m pip install --upgrade pip --quiet
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- create windows64 installer -----"
|
||||
|
||||
$actual_dir=(Get-Location).Path
|
||||
@ -10,5 +13,6 @@ Expand-Archive -Path "$PSScriptRoot\..\..\bin\windows\EnVar_plugin.zip" -Destina
|
||||
# create win64 installer
|
||||
cd $PSScriptRoot\..\..\target\win-package
|
||||
makensis.exe /NOCD /V4 ..\..\bin\windows\hurl.nsi
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
cd $actual_dir
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- create windows64 zip package -----"
|
||||
|
||||
$actual_dir=(Get-Location).Path
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- install windows64 installer -----"
|
||||
|
||||
$actual_dir=(Get-Location).Path
|
||||
@ -6,6 +9,7 @@ $project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
|
||||
# install windows64 installer
|
||||
$package_dir="$project_root_path\target\win-package"
|
||||
Start-Process powershell "$package_dir\*win64-installer.exe /S" -NoNewWindow -Wait -PassThru
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# refresh env
|
||||
$registry_user_path=(Get-ItemProperty -Path 'HKCU:\Environment').Path
|
||||
@ -18,6 +22,8 @@ sleep 10
|
||||
(Get-Command hurl).Path
|
||||
(Get-Command hurlfmt).Path
|
||||
hurl --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
hurlfmt --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
cd $actual_dir
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- install windows64 zip -----"
|
||||
|
||||
$actual_dir=(Get-Location).Path
|
||||
@ -21,6 +24,8 @@ sleep 10
|
||||
(Get-Command hurl).Path
|
||||
(Get-Command hurlfmt).Path
|
||||
hurl --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
hurlfmt --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
cd $actual_dir
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- build release -----"
|
||||
|
||||
$actual_dir=(Get-Location).Path
|
||||
@ -5,6 +8,7 @@ $project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
|
||||
|
||||
# build
|
||||
cargo build --release --verbose --locked
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# create final package
|
||||
$release_dir="$project_root_path\target\release"
|
||||
@ -25,6 +29,8 @@ sleep 10
|
||||
(Get-Command hurl).Path
|
||||
(Get-Command hurlfmt).Path
|
||||
hurl --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
hurlfmt --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
cd $actual_dir
|
||||
|
@ -1,5 +1,11 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- tests -----"
|
||||
|
||||
& $PSScriptRoot\test_prerequisites.ps1
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
& $PSScriptRoot\test_unit.ps1
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
& $PSScriptRoot\test_integ.ps1
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- integration tests -----"
|
||||
|
||||
$actual_dir=(Get-Location).Path
|
||||
@ -7,10 +10,13 @@ $project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
|
||||
(Get-Command hurl).Path
|
||||
(Get-Command hurlfmt).Path
|
||||
hurl --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
hurlfmt --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# run integration tests
|
||||
cd $project_root_path\integration
|
||||
python integration.py
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
cd $actual_dir
|
||||
|
@ -1,3 +1,6 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- install tests prerequisites -----"
|
||||
|
||||
$actual_dir=(Get-Location).Path
|
||||
@ -5,16 +8,23 @@ $project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
|
||||
|
||||
# install python libs
|
||||
pip3 install --requirement $project_root_path\bin\requirements-frozen.txt
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# start mock servers
|
||||
cd $project_root_path\integration
|
||||
|
||||
Start-Process powershell -WindowStyle Hidden { mitmdump --listen-port 8888 --modify-header "/From-Proxy/Hello" 2>&1 > mitmdump.log }
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
sleep 5
|
||||
if (netstat -ano | Select-String LISTENING | Select-string 0.0.0.0:8888) {powershell write-host -foregroundcolor Green "mitmdump is up"} else {powershell write-host -foregroundcolor Red "mitmdump is down" ; exit 1}
|
||||
|
||||
Start-Process powershell -WindowStyle Hidden { python server.py 2>&1 > server.log }
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
sleep 5
|
||||
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8000) {powershell write-host -foregroundcolor Green "server is up"} else {powershell write-host -foregroundcolor Red "server is down" ; exit 1}
|
||||
|
||||
Start-Process powershell -WindowStyle Hidden { python ssl/server.py 2>&1 > server-ssl.log }
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
sleep 5
|
||||
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8001) {powershell write-host -foregroundcolor Green "server-ssl up"} else {powershell write-host -foregroundcolor Red "server-ssl is down" ; exit 1}
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
powershell write-host -foregroundcolor Cyan "----- unit tests -----"
|
||||
|
||||
# run test units
|
||||
cargo test --release --features strict --tests
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
||||
# create test package
|
||||
$project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
|
||||
@ -21,4 +25,6 @@ sleep 10
|
||||
(Get-Command hurl).Path
|
||||
(Get-Command hurlfmt).Path
|
||||
hurl --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
hurlfmt --version
|
||||
if ($LASTEXITCODE) { Throw }
|
||||
|
@ -1,4 +1,5 @@
|
||||
$ErrorActionPreference = 'Stop';
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop';
|
||||
$SoftwareName = 'hurl'
|
||||
|
||||
$HashArguments = @{
|
||||
|
Loading…
Reference in New Issue
Block a user