[macOS] Add test to check opened windows (#5052)

* Add test to check opened windows

* Move check before xcode

* Move check after homebrew

* Exclude NotificationCenter

* Update pester test
This commit is contained in:
Aleksandr Chebotov
2022-02-10 18:10:43 +03:00
committed by GitHub
parent 84450e8a9d
commit a31ed06b10
6 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#!/bin/bash -e -o pipefail
openwindows=$(osascript -e 'tell application "System Events" to get every window of (every process whose class of windows contains window)')
IFS=',' read -r -a windowslist <<< "$openwindows"
if [ -n "${openwindows}" ]; then
echo "Found opened window:"
fi
for window in "${windowslist[@]}"; do
if [[ $window =~ "NotificationCenter" ]]; then
echo "[Warning] $window"
else
echo " - ${window}" | xargs
scripterror=true
fi
done
if [ "${scripterror}" = true ]; then
exit 1
fi

View File

@@ -131,6 +131,7 @@
"scripts": [
"./provision/core/xcode-clt.sh",
"./provision/core/homebrew.sh",
"./provision/core/open_windows_check.sh",
"./provision/core/powershell.sh",
"./provision/core/dotnet.sh",
"./provision/core/python.sh",

View File

@@ -136,6 +136,7 @@
"pause_before": "30s",
"scripts": [
"./provision/core/homebrew.sh",
"./provision/core/open_windows_check.sh",
"./provision/core/powershell.sh",
"./provision/core/dotnet.sh",
"./provision/core/python.sh",

View File

@@ -135,6 +135,7 @@ build {
pause_before = "30s"
scripts = [
"./provision/core/homebrew.sh",
"./provision/core/open_windows_check.sh",
"./provision/core/powershell.sh",
"./provision/core/dotnet.sh",
"./provision/core/python.sh",

View File

@@ -136,6 +136,7 @@
"pause_before": "30s",
"scripts": [
"./provision/core/homebrew.sh",
"./provision/core/open_windows_check.sh",
"./provision/core/powershell.sh",
"./provision/core/dotnet.sh",
"./provision/core/python.sh",

View File

@@ -46,3 +46,11 @@ Describe "Screen Resolution" {
system_profiler SPDisplaysDataType | Select-String "Resolution" | Should -Match "1176 x 885|1920 x 1080"
}
}
Describe "Open windows" {
It "Opened windows not found" {
$cmd = "osascript -e 'tell application \""System Events\"" to get every window of (every process whose class of windows contains window)'"
$openWindows = bash -c $cmd
$openWindows.Split(",").Trim() | Where-Object { $_ -notmatch "NotificationCenter" } | Should -BeNullOrEmpty
}
}