diff --git a/tools/ci/Convert-CarayaReport.ps1 b/tools/ci/Convert-CarayaReport.ps1 index 5ad160e..d96da04 100644 --- a/tools/ci/Convert-CarayaReport.ps1 +++ b/tools/ci/Convert-CarayaReport.ps1 @@ -9,9 +9,14 @@ Markdown table with one row per test and its asserts. TestStatus is the exit code of tools\ci\Invoke-CliTest.ps1 for the suite; with 2 (LabVIEW not reachable) the report says that the tests did not run -instead of showing a failure. ProtocolReportPath and ProtocolStatus add a -section for tests\Run_Protocol_Tests_CLI.vi (tools\test\Test-McpServer.ps1 -against a running server). +instead of showing a failure, and with "not-run" (the workflow skipped the +step because finding LabVIEW or installing the packages failed) it says +that. ProtocolReportPath and ProtocolStatus (the same values) add a section +for tests\Run_Protocol_Tests_CLI.vi (tools\test\Test-McpServer.ps1 against a +running server). + +Labels and VI names are escaped for the Markdown table, and the protocol +tester's output is put in a code fence that no line of it can close. Exit code is always 0; whether the run passed is decided by the test step. #> @@ -24,6 +29,7 @@ param( ) $ErrorActionPreference = 'Stop' +Import-Module (Join-Path $PSScriptRoot 'LabVIEWCi.psm1') -Force $utf8 = New-Object System.Text.UTF8Encoding $false $md = New-Object System.Text.StringBuilder @@ -36,18 +42,17 @@ function Add-ProtocolSection { '0' { [void]$md.AppendLine(':white_check_mark: `Test-McpServer.ps1` passed against the test server.') } '2' { [void]$md.AppendLine(':warning: Not run: LabVIEW could not be reached (LabVIEW CLI error -350000).') } '3' { [void]$md.AppendLine('Not run: `tests\Run_Protocol_Tests_CLI.vi` does not exist on this branch.') } + 'not-run' { [void]$md.AppendLine(':warning: Not run: an earlier step (finding LabVIEW, installing the packages) failed, or LabVIEW was not reachable; see the job log.') } default { [void]$md.AppendLine(':x: `Test-McpServer.ps1` reported failed required checks against the test server.') } } [void]$md.AppendLine() - if ($ProtocolReportPath -and (Test-Path $ProtocolReportPath)) { - $lines = @(Get-Content $ProtocolReportPath) + if ($ProtocolStatus -ne 'not-run' -and $ProtocolReportPath -and (Test-Path -LiteralPath $ProtocolReportPath)) { + $lines = @(Get-Content -LiteralPath $ProtocolReportPath -Encoding UTF8) $fails = @($lines | Where-Object { $_ -match '^\[FAIL\] \(required\)' }) $open = if ($ProtocolStatus -ne '0') { ' open' } else { '' } [void]$md.AppendLine("Protocol tester output ($($fails.Count) failed required checks)") [void]$md.AppendLine() - [void]$md.AppendLine('```') - foreach ($line in $lines) { [void]$md.AppendLine($line) } - [void]$md.AppendLine('```') + [void]$md.AppendLine((Format-MarkdownCodeBlock ($lines -join "`n"))) [void]$md.AppendLine() [void]$md.AppendLine('') [void]$md.AppendLine() @@ -69,7 +74,14 @@ if ($TestStatus -eq '2') { return } -if (-not (Test-Path $ReportPath)) { +if ($TestStatus -eq 'not-run') { + [void]$md.AppendLine(':warning: The tests did not run: finding LabVIEW or installing the packages failed before them. See the job log.') + [void]$md.AppendLine() + Save-Report + return +} + +if (-not (Test-Path -LiteralPath $ReportPath)) { [void]$md.AppendLine('No per-test report was produced. `tests\Run_Tests_CLI.vi` on this branch does not write `tests\results\caraya-report.txt` yet (update the branch from main), or the run stopped before the suite finished.') Save-Report return @@ -80,35 +92,53 @@ function Format-Result([string]$Result) { return ":x: $($Result.ToLower())" } -# Caraya indents by call depth, and that depth depends on how the suite was -# started (LabVIEWCLI adds its own callers on top). The deepest lines are the -# asserts; the lines one step (two spaces) above them are the tests. +# The report, one line per entry: "