From 49750423f19aeb2aa8d92e53d8592b379ec3b258 Mon Sep 17 00:00:00 2001 From: aparnajyothi-y <147696841+aparnajyothi-y@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:27:46 +0530 Subject: [PATCH] Update Node.Tests.ps1 --- tests/Node.Tests.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Node.Tests.ps1 b/tests/Node.Tests.ps1 index 890b881..60043db 100644 --- a/tests/Node.Tests.ps1 +++ b/tests/Node.Tests.ps1 @@ -3,14 +3,18 @@ Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1") BeforeAll { function Get-UseNodeLogs { - # GitHub Windows images don't have `HOME` variable - $homeDir = $env:HOME ?? $env:HOMEDRIVE - $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve + # Set the logs folder path based on whether the runner is self-hosted or GitHub-hosted + $logsFolderPath = $env:SELF_HOSTED_RUNNER -eq 'true' ? "/Users/runneradmin/runners/_diag" : "/home/runner/runners/_diag" + + if (-not (Test-Path -Path $logsFolderPath)) { + throw "Directory '$logsFolderPath' does not exist." + } $useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object { $logContent = Get-Content $_.Fullname -Raw return $logContent -match "setup-node@v" } | Select-Object -First 1 + return $useNodeLogFile.Fullname } }