[devops] Fix a few issues with pwsh tests and test result parsing.#24516
[devops] Fix a few issues with pwsh tests and test result parsing.#24516rolfbjarne merged 2 commits intomainfrom
Conversation
* Fix an issue parsing test results, causing errors like:
Failed to compute test summaries: Method invocation failed because [System.Char] does not contain a method named 'Contains'.
* Fix tests related to checking if a commit is the last in a PR.
There was a problem hiding this comment.
Pull request overview
This PR fixes two issues in the DevOps automation scripts: a PowerShell parsing error when processing test results that occurred when calling .Contains() on a character instead of a string, and improves tests for checking if a commit is the latest in a PR by using a public function instead of directly instantiating internal classes.
Changes:
- Fixed test result parsing by wrapping
Get-Contentoutput in an array to ensure string methods are available - Separated logic for adding
<summary>and<details>tags based on what's found in test result files - Added a public wrapper function
Get-IsCurrentCommitLatestInPRfor better testability - Updated tests to use the new public function instead of directly manipulating internal class instances
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/devops/automation/scripts/TestResults.psm1 | Fixed parsing logic to handle test result files correctly by ensuring array output and separating <summary> and <details> handling |
| tools/devops/automation/scripts/TestResults.Tests.ps1 | Updated expected test output to match the corrected parsing behavior |
| tools/devops/automation/scripts/GitHub.psm1 | Added public wrapper function Get-IsCurrentCommitLatestInPR and exported it |
| tools/devops/automation/scripts/GitHub.Tests.ps1 | Updated tests to use the new public function instead of directly instantiating internal classes |
| Mock Invoke-Request { | ||
| return @{ | ||
| "head" = @{ | ||
| "sha" = "different123hash" | ||
| } | ||
| } | ||
| } -ModuleName 'GitHub' |
There was a problem hiding this comment.
The mock in the test 'returns true when not in PR context' is unnecessary. Since an empty PR IDs array is passed, the IsCurrentCommitLatestInPR method will return true without making any API call, so this mock will never be invoked. The mock should be removed or the test should verify that Invoke-Request is not called.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #f0dc8ba] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #f0dc8ba] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #f0dc8ba] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #f0dc8ba] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #f0dc8ba] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #f0dc8ba] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #f0dc8ba] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #f0dc8ba] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
🚀 [CI Build #f0dc8ba] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 117 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
…24516) * Fix an issue parsing test results, causing errors like: Failed to compute test summaries: Method invocation failed because [System.Char] does not contain a method named 'Contains'. * Fix tests related to checking if a commit is the last in a PR.
…24516) * Fix an issue parsing test results, causing errors like: Failed to compute test summaries: Method invocation failed because [System.Char] does not contain a method named 'Contains'. * Fix tests related to checking if a commit is the last in a PR.
Fix an issue parsing test results, causing errors like:
Failed to compute test summaries: Method invocation failed because [System.Char] does not contain a method named 'Contains'.
Fix tests related to checking if a commit is the last in a PR.