[tests] Take a screenshot on test timeout in run-packaged-macos-tests#25921
[tests] Take a screenshot on test timeout in run-packaged-macos-tests#25921rolfbjarne wants to merge 1 commit into
Conversation
When a test run times out (either the launch timeout or the execution timeout), take a screenshot of the screen using screencapture. The screenshot is then copied to the HTML report directory and shown as a download link in the report table. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
There was a problem hiding this comment.
Pull request overview
This PR enhances the macOS packaged test runner so that when a test launch or execution hits a timeout, it captures a screenshot via screencapture and exposes it in the generated HTML report, aiding diagnosis of hung UI prompts or stalled tests.
Changes:
- Extended
ExecuteWithTimeoutto return a screenshot path when a launch/execution timeout occurs. - Added a
TakeScreenshothelper that invokes/usr/sbin/screencaptureand stores the image in the test output directory. - Updated HTML report generation to copy screenshots into the report directory and add a “Screenshot” column with download links.
| string output; | ||
| var screenshotPath = ""; | ||
|
|
||
| for (var attempt = 0; attempt < maxLaunchAttempts; attempt++) { |
| var p = Process.Start (new ProcessStartInfo { | ||
| FileName = "/usr/sbin/screencapture", | ||
| ArgumentList = { "-x", "-T", "0", path }, | ||
| UseShellExecute = false, | ||
| }); | ||
| if (p is not null) { | ||
| p.WaitForExit (TimeSpan.FromSeconds (10)); | ||
| if (File.Exists (path)) { | ||
| Console.WriteLine ($"Screenshot saved to {path}"); | ||
| return path; | ||
| } | ||
| } |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #95a2707] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [PR Build #95a2707] Build passed (Build packages) ✅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 |
✅ [PR Build #95a2707] Build passed (Build macOS tests) ✅Pipeline on Agent |
🚀 [CI Build #95a2707] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 199 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
When a test run times out (either the launch timeout or the execution timeout), take a screenshot of the screen using screencapture. The screenshot is then copied to the HTML report directory and shown as a download link in the report table.
🤖 Pull request created by Copilot