[Windows] Apply code style rules to Windows scripts (#8957)

* Apply code style rules to Windows scripts

* Fix typo

* Fix configure-toolset script

* Fix parameters in Msys2 installation script

* Improve log readability

* Remove broken exit code validation
This commit is contained in:
Vasilii Polikarpov
2023-12-11 22:23:36 +01:00
committed by GitHub
parent 76d6f0f574
commit 7fe65a2204
54 changed files with 544 additions and 418 deletions

View File

@@ -5,15 +5,15 @@ Describe "MongoDB" {
@{ ToolName = "mongod" }
) {
$toolsetVersion = (Get-ToolsetContent).mongodb.version
(&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*"
(& $ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*"
}
}
Context "Service" {
$mongoService = Get-Service -Name mongodb -ErrorAction Ignore
$mongoServiceTests = @{
Name = $mongoService.Name
Status = $mongoService.Status
Name = $mongoService.Name
Status = $mongoService.Status
StartType = $mongoService.StartType
}
@@ -29,9 +29,9 @@ Describe "MongoDB" {
Describe "PostgreSQL" {
$psqlTests = @(
@{envVar = "PGROOT"; pgPath = Get-EnvironmentVariable "PGROOT"}
@{envVar = "PGBIN"; pgPath = Get-EnvironmentVariable "PGBIN"}
@{envVar = "PGDATA"; pgPath = Get-EnvironmentVariable "PGDATA"}
@{envVar = "PGROOT"; pgPath = Get-EnvironmentVariable "PGROOT" }
@{envVar = "PGBIN"; pgPath = Get-EnvironmentVariable "PGBIN" }
@{envVar = "PGDATA"; pgPath = Get-EnvironmentVariable "PGDATA" }
)
Context "Environment variable" {
@@ -57,8 +57,8 @@ Describe "PostgreSQL" {
Context "Service" {
$psqlService = Get-Service -Name postgresql*
$psqlServiceTests = @{
Name = $psqlService.Name
Status = $psqlService.Status
Name = $psqlService.Name
Status = $psqlService.Status
StartType = $psqlService.StartType
}
@@ -75,9 +75,9 @@ Describe "PostgreSQL" {
It "PostgreSQL version should correspond to the version in the toolset" {
$toolsetVersion = (Get-ToolsetContent).postgresql.version
# Client version
(&$Env:PGBIN\psql --version).split()[-1] | Should -BeLike "$toolsetVersion*"
(& $env:PGBIN\psql --version).split()[-1] | Should -BeLike "$toolsetVersion*"
# Server version
(&$Env:PGBIN\pg_config --version).split()[-1] | Should -BeLike "$toolsetVersion*"
(& $env:PGBIN\pg_config --version).split()[-1] | Should -BeLike "$toolsetVersion*"
}
}
}

View File

@@ -23,19 +23,19 @@ Describe "Bazel" {
Describe "CodeQL Bundle" {
It "Single distribution installed" {
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionsWildcard = Join-Path $env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Should -HaveCount 1
}
It "Contains CodeQL executable" {
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionsWildcard = Join-Path $env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Sort-Object -Descending | Select-Object -First 1 -Expand FullName
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql.exe"
"$CodeQLPath version --quiet" | Should -ReturnZeroExitCode
}
It "Contains CodeQL packs" {
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionsWildcard = Join-Path $env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Sort-Object -Descending | Select-Object -First 1 -Expand FullName
$CodeQLPacksPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "qlpacks"
$CodeQLPacksPath | Should -Exist
@@ -119,7 +119,7 @@ Describe "NET48" {
Describe "NSIS" {
It "NSIS" {
"makensis /VERSION" | Should -ReturnZeroExitCode
"makensis /VERSION" | Should -ReturnZeroExitCode
}
}
@@ -201,9 +201,9 @@ Describe "Pipx" {
}
Describe "Kotlin" {
$kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlin-dce-js", "kotlinc-jvm")
$kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlin-dce-js", "kotlinc-jvm")
It "<toolName> is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) {
It "<toolName> is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) {
"$toolName -version" | Should -ReturnZeroExitCode
}
}

View File

@@ -12,7 +12,7 @@ $toolsExecutables = @{
@{ Binary = "npm"; Arguments = "--version" }
)
Go = @(
@{ Binary = "bin\go.exe"; Arguments = "version" }
@{ Binary = "bin\go.exe"; Arguments = "version" }
)
Ruby = @(
@{ Binary = "bin\ruby.exe"; Arguments = "--version" }

View File

@@ -17,7 +17,7 @@ Describe "WindowsFeatures" {
Describe "DiskSpace" {
It "The image has enough disk space"{
$availableSpaceMB = [math]::Round((Get-PSDrive -Name C).Free / 1MB)
$availableSpaceMB = [math]::Round((Get-PSDrive -Name C).Free / 1MB)
$minimumFreeSpaceMB = 18 * 1024
$availableSpaceMB | Should -BeGreaterThan $minimumFreeSpaceMB
@@ -26,7 +26,7 @@ Describe "DiskSpace" {
Describe "DynamicPorts" {
It "Test TCP dynamicport start=49152 num=16384" {
$tcpPorts = Get-NetTCPSetting | Where-Object {$_.SettingName -ne "Automatic"} | Where-Object {
$tcpPorts = Get-NetTCPSetting | Where-Object { $_.SettingName -ne "Automatic" } | Where-Object {
$_.DynamicPortRangeStartPort -ne 49152 -or $_.DynamicPortRangeNumberOfPorts -ne 16384
}
@@ -52,7 +52,7 @@ Describe "GDIProcessHandleQuota" {
}
Describe "Test Signed Drivers" {
It "bcdedit testsigning should be Yes"{
It "bcdedit testsigning should be Yes" {
"$(bcdedit)" | Should -Match "testsigning\s+Yes"
}
}
@@ -64,7 +64,7 @@ Describe "Windows Updates" {
$testCases = Get-WindowsUpdateStates | Sort-Object Title | ForEach-Object {
@{
Title = $_.Title
Title = $_.Title
State = $_.State
}
}