Skip to content

Commit f87da41

Browse files
committed
Fix
1 parent 11d997a commit f87da41

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

integration-test/Integration.Tests.Android.SauceLabs.ps1

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,9 @@ function script:Invoke-SauceLabsApp {
252252
$logResponse = Invoke-SauceLabsApi -Method POST -Uri "$baseUri/log" -Body $logBody
253253

254254
if ($logResponse.value -and $logResponse.value.Count -gt $script:LogLineCount) {
255-
$newLogs = @($logResponse.value | Select-Object -Skip $script:LogLineCount)
256-
$logMessages = @($newLogs | ForEach-Object { $_.message })
255+
# Use array slicing instead of Select-Object -Skip (more reliable)
256+
$newLogs = @($logResponse.value[$script:LogLineCount..($logResponse.value.Count - 1)])
257+
$logMessages = @($newLogs | ForEach-Object { if ($_) { $_.message } })
257258

258259
# Check for completion markers
259260
if (($logMessages | Where-Object { $_ -match "TEST_RESULT:" }) -or
@@ -286,8 +287,8 @@ function script:Invoke-SauceLabsApp {
286287
Write-Debug "Total logs in response: $totalLogCount, Previously read: $script:LogLineCount"
287288

288289
if ($totalLogCount -gt $script:LogLineCount) {
289-
# Get only new logs (skip previously read lines)
290-
$allLogs = @($logResponse.value | Select-Object -Skip $script:LogLineCount)
290+
# Get only new logs using array slicing (more reliable than Select-Object -Skip)
291+
$allLogs = @($logResponse.value[$script:LogLineCount..($totalLogCount - 1)])
291292
Write-Host "Retrieved $($allLogs.Count) new log lines" -ForegroundColor Cyan
292293
} else {
293294
Write-Host "No new log lines since last read" -ForegroundColor Yellow
@@ -303,11 +304,13 @@ function script:Invoke-SauceLabsApp {
303304
$logCache = @()
304305
if ($allLogs -and $allLogs.Count -gt 0) {
305306
$logCache = $allLogs | ForEach-Object {
306-
$timestamp = if ($_.timestamp) { $_.timestamp } else { "" }
307-
$level = if ($_.level) { $_.level } else { "" }
308-
$message = if ($_.message) { $_.message } else { "" }
309-
"$timestamp $level $message"
310-
}
307+
if ($_) {
308+
$timestamp = if ($_.timestamp) { $_.timestamp } else { "" }
309+
$level = if ($_.level) { $_.level } else { "" }
310+
$message = if ($_.message) { $_.message } else { "" }
311+
"$timestamp $level $message"
312+
}
313+
} | Where-Object { $_ } # Filter out any nulls
311314
}
312315

313316
# Save logs to file if OutputDir specified

0 commit comments

Comments
 (0)