@@ -15,16 +15,28 @@ $script:repositoryRoot = $null
1515$script :resolvedArtifactManifestPath = $null
1616$script :artifactManifestPath = $null
1717
18+ function Test-YamlArtifactManifestAvailable {
19+ [CmdletBinding ()]
20+ [OutputType ([bool ])]
21+ param ()
22+
23+ if (-not [string ]::IsNullOrWhiteSpace($env: PSMODULE_YAML_TEST_ARTIFACT )) {
24+ return $true
25+ }
26+ $repositoryRoot = (Resolve-Path - LiteralPath (Join-Path $PSScriptRoot ' ..' )).Path
27+ Test-Path - LiteralPath (Join-Path $repositoryRoot ' outputs\module\Yaml\Yaml.psd1' ) - PathType Leaf
28+ }
29+
30+ $artifactManifestAvailable = Test-YamlArtifactManifestAvailable
31+
1832BeforeAll {
1933 . (Join-Path $PSScriptRoot ' TestBootstrap.ps1' )
2034 $script :repositoryRoot = (Resolve-Path - LiteralPath (Join-Path $PSScriptRoot ' ..' )).Path
2135 $defaultArtifactManifestPath = Join-Path $script :repositoryRoot ' outputs\module\Yaml\Yaml.psd1'
22- $script :resolvedArtifactManifestPath = if (
23- -not [string ]::IsNullOrWhiteSpace($env: PSMODULE_YAML_TEST_ARTIFACT )
24- ) {
25- $env: PSMODULE_YAML_TEST_ARTIFACT
26- } elseif (Test-Path - LiteralPath $defaultArtifactManifestPath - PathType Leaf) {
36+ $script :resolvedArtifactManifestPath = if (Test-Path - LiteralPath $defaultArtifactManifestPath - PathType Leaf) {
2737 $defaultArtifactManifestPath
38+ } elseif (-not [string ]::IsNullOrWhiteSpace($env: PSMODULE_YAML_TEST_ARTIFACT )) {
39+ $env: PSMODULE_YAML_TEST_ARTIFACT
2840 } else {
2941 $null
3042 }
@@ -85,8 +97,8 @@ Describe 'Dependency-free package source' {
8597 ' ConvertTo-YamlNode.ps1' ,
8698 ' Write-YamlNodeText.ps1'
8799 ) | ForEach-Object {
88- Test-Path - LiteralPath (Join-Path $privatePath $_ ) |
89- Should - BeTrue - Because " $_ defines a required processor layer"
100+ $isPresent = Test-Path - LiteralPath (Join-Path $privatePath $_ )
101+ $isPresent | Should - BeTrue - Because " $_ defines a required processor layer"
90102 }
91103 }
92104
@@ -121,7 +133,7 @@ Describe 'Dependency-free package source' {
121133
122134Describe ' Generated artifact package' {
123135 It ' has no RequiredAssemblies or packaged DLL and has a complete FileList' `
124- - Skip:([ string ]::IsNullOrWhiteSpace( $ env: PSMODULE_YAML_TEST_ARTIFACT ) -and - not ( Test-Path - LiteralPath ( Join-Path ( Resolve-Path - LiteralPath ( Join-Path $PSScriptRoot ' .. ' )).Path ' outputs\module\Yaml\Yaml.psd1 ' ) - PathType Leaf) ) {
136+ - Skip:(- not $artifactManifestAvailable ) {
125137 $manifest = Import-PowerShellDataFile - Path $script :artifactManifestPath
126138 $moduleBase = Split-Path - Parent $script :artifactManifestPath
127139
@@ -139,7 +151,9 @@ Describe 'Generated artifact package' {
139151 }
140152
141153 It ' imports in a fresh PowerShell 7 process and preserves arrays, aliases, and depth' `
142- - Skip:(([string ]::IsNullOrWhiteSpace($env: PSMODULE_YAML_TEST_ARTIFACT ) -and -not (Test-Path - LiteralPath (Join-Path (Resolve-Path - LiteralPath (Join-Path $PSScriptRoot ' ..' )).Path ' outputs\module\Yaml\Yaml.psd1' ) - PathType Leaf)) -or $null -eq (Get-Command pwsh - ErrorAction SilentlyContinue)) {
154+ - Skip:((
155+ -not $artifactManifestAvailable
156+ ) -or ($null -eq (Get-Command pwsh - ErrorAction SilentlyContinue))) {
143157 $script = @'
144158$ErrorActionPreference = 'Stop'
145159$ps = $PSVersionTable.PSVersion
0 commit comments