Modules/businessdev.ALbuild.Apps/Private/Get-BcTestAppFolder.ps1
|
function Get-BcTestAppFolder { <# .SYNOPSIS Discovers AL test app folders under a workspace and loads each app's project config. .DESCRIPTION Internal, host-side helper. Walks the workspace folder for app.json manifests and returns the ones that look like AL test apps (manifest "test" reference, a Microsoft test/assert dependency, or AL source with a "Subtype = Test" object). For each test app it loads the effective ALbuild project configuration (Get-ALbuildProjectConfig), merging the workspace-root 'albuild.json' with the app-folder 'albuild.json' (deprecated 'pipeline.config' is still honoured). That config carries the per-app knobs the test runner uses - the test-runner codeunit, test suite and isolation. .PARAMETER ProjectFolder The workspace root to search recursively (also the workspace-level config location). .OUTPUTS PSCustomObject per test app: Folder, Id, Name, Publisher, Version, ProjectConfig. #> [CmdletBinding()] [OutputType([PSCustomObject])] param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $ProjectFolder ) if (-not (Test-Path -LiteralPath $ProjectFolder)) { throw "Project folder '$ProjectFolder' does not exist." } $results = [System.Collections.Generic.List[PSCustomObject]]::new() foreach ($manifestFile in (Get-ChildItem -LiteralPath $ProjectFolder -Filter 'app.json' -Recurse -File)) { $appFolder = Split-Path -Path $manifestFile.FullName -Parent try { $manifest = Get-Content -LiteralPath $manifestFile.FullName -Raw -Encoding UTF8 | ConvertFrom-Json } catch { Write-ALbuildLog -Level Warning "Skipping '$($manifestFile.FullName)': $($_.Exception.Message)" continue } if (-not (Test-BcIsTestApp -Manifest $manifest -AppFolder $appFolder)) { continue } $projectConfig = Get-ALbuildProjectConfig -AppFolder $appFolder -WorkspaceRoot $ProjectFolder $results.Add([PSCustomObject]@{ Folder = $appFolder Id = "$($manifest.id)" Name = "$($manifest.name)" Publisher = "$($manifest.publisher)" Version = "$($manifest.version)" ProjectConfig = $projectConfig }) } return @($results | Sort-Object -Property Name) } |