@@ -77,19 +77,44 @@ jobs:
7777 shell : pwsh
7878 run : |
7979 cd ${{ github.workspace }}
80+
81+ # Set up environment
82+ $testRoot = Join-Path $PWD.Path "test/unit-tests"
83+ $env:PSModulePath = "$testRoot;" + $env:PSModulePath
84+
85+ # Import test framework
86+ $frameworkPath = Join-Path $testRoot "test_framework.ps1"
87+ . $frameworkPath
88+
89+ # Import all test functions
90+ $functionsPath = Join-Path $testRoot "test_functions"
91+ Get-ChildItem $functionsPath -Filter "*.ps1" | ForEach-Object {
92+ Write-Host "Importing function: $($_.FullName)"
93+ . $_.FullName
94+ }
95+
96+ # Get list of available test functions
97+ $availableFunctions = (Get-ChildItem $functionsPath -Filter "*.ps1").BaseName
98+ Write-Host "Available test functions: $($availableFunctions -join ', ')"
99+
100+ # Find corresponding test files that have matching functions
101+ $testCasesPath = Join-Path $testRoot "test_cases"
102+ $validTestFiles = Get-ChildItem $testCasesPath -Filter "*.ps1" | Where-Object {
103+ $testName = $_.BaseName -replace "^Test-"
104+ $testName -in $availableFunctions -or
105+ $availableFunctions -contains "Get-$testName" -or
106+ $availableFunctions -contains "Is-$testName"
107+ }
108+ Write-Host "Valid test files to run: $($validTestFiles.BaseName -join ', ')"
109+
110+ # Configure Pester
80111 $config = New-PesterConfiguration
81- $config.Run.Path = "./test/unit-tests/test_cases"
82- $config.Run.TestExtension = ".ps1"
112+ $config.Run.Path = $validTestFiles.FullName
83113 $config.Output.Verbosity = "Detailed"
84114 $config.Run.PassThru = $true
85115 $config.TestResult.Enabled = $true
86116 $config.TestResult.OutputFormat = "NUnitXml"
87117 $config.TestResult.OutputPath = "test-results.xml"
88- # Import test framework and functions
89- Import-Module "./test/unit-tests/test_framework.ps1"
90- Get-ChildItem "./test/unit-tests/test_functions" -Filter "*.ps1" | ForEach-Object {
91- Import-Module $_.FullName -Force
92- }
93118 # Run all test files in test_cases directory
94119 $result = Invoke-Pester -Configuration $config
95120
0 commit comments