mirror of
https://github.com/actions/node-versions.git
synced 2025-04-20 02:43:49 +00:00
Update Node.Tests.ps1
This commit is contained in:
parent
ad4d6a9a31
commit
d920d43ef0
@ -2,21 +2,16 @@ Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
|
|||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
function Get-UseNodeLogs {
|
function Get-UseNodeLogs {
|
||||||
# Determine if the current environment is Windows or Linux
|
# GitHub Windows images don't have `HOME` variable
|
||||||
$isWindows = $PSVersionTable.PSVersion.Platform -eq "Win32NT"
|
$homeDir = $env:HOME ?? $env:HOMEDRIVE
|
||||||
$isArm64 = $env:PROCESSOR_ARCHITECTURE -eq "ARM64"
|
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
|
||||||
|
|
||||||
# For Windows, use HOMEDRIVE if HOME is not available
|
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
|
||||||
# For Linux, use HOME directly
|
$logContent = Get-Content $_.Fullname -Raw
|
||||||
$homeDir = if ($isWindows) { $env:HOME ?? $env:HOMEDRIVE } else { $env:HOME }
|
return $logContent -match "setup-node@v"
|
||||||
|
} | Select-Object -First 1
|
||||||
# Check if the OS is Windows ARM64 or Linux ARM64 and set the logs folder path accordingly
|
return $useNodeLogFile.Fullname
|
||||||
if ($isWindows -and $isArm64) {
|
}
|
||||||
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/_diag/pages" -Resolve
|
|
||||||
} elseif (-not $isWindows -and $isArm64) {
|
|
||||||
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/_diag/pages" -Resolve
|
|
||||||
} else {
|
|
||||||
throw "Unsupported OS or architecture."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
|
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
|
||||||
@ -51,9 +46,12 @@ Describe "Node.js" {
|
|||||||
It "cached version is used without downloading" {
|
It "cached version is used without downloading" {
|
||||||
# Analyze output of previous steps to check if Node.js was consumed from cache or downloaded
|
# Analyze output of previous steps to check if Node.js was consumed from cache or downloaded
|
||||||
$useNodeLogFile = Get-UseNodeLogs
|
$useNodeLogFile = Get-UseNodeLogs
|
||||||
|
if ($useNodeLogFile -eq $null) {
|
||||||
|
Set-ItResult -Skipped -Because "Log file does not exist"
|
||||||
|
} else {
|
||||||
$useNodeLogFile | Should -Exist
|
$useNodeLogFile | Should -Exist
|
||||||
$useNodeLogContent = Get-Content $useNodeLogFile -Raw
|
$useNodeLogContent = Get-Content $useNodeLogFile -Raw
|
||||||
$useNodeLogContent | Should -Match "Found in cache"
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Run simple code" {
|
It "Run simple code" {
|
||||||
|
Loading…
Reference in New Issue
Block a user