Skip to content

[net11.0] 'dotnet watch' works again now, so enable the corresponding tests.#25712

Draft
rolfbjarne wants to merge 3 commits into
net11.0from
dev/rolf/dotnet-watch-tests
Draft

[net11.0] 'dotnet watch' works again now, so enable the corresponding tests.#25712
rolfbjarne wants to merge 3 commits into
net11.0from
dev/rolf/dotnet-watch-tests

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Also a few improvements, because this test turned out rather unpredictable locally:

  • Detect if the build failed, and terminate the test early. The build shouldn't fail, but yet it randomly does, and this makes the test fail immediately instead of having the test time out (after a 2 min wait).
  • Don't give stdin to 'dotnet watch', because 'dotnet test' goes bananas. Deadlocks everywhere (dozens of threads stuck while trying to determine the cursor position in the terminal, etc).
  • Disable build servers. Not sure if it helps, but when random things fail, random stuff gets tried, and this won't hurt.
  • Don't run desktop test apps with 'open', because then the test app's process is not a descendent of the 'dotnet watch' process, and if something goes wrong and the test needs to kill 'dotnet watch', the test app won't be killed.
  • Always cancel the 'dotnet watch' process at the end. Copilot suggested doing this, and it sounded good so here it is.
  • Augment the 'Execution' class to kill the entire process tree. Once again, Copilot suggested doing this, and it sounds like a good thing to do.
  • Add CoreCLR mobile variations.

… tests.

Also a few improvements, because this test turned out rather unpredictable locally:

* Detect if the build failed, and terminate the test early. The build shouldn't fail, but yet it randomly does, and this makes the test fail immediately instead of having the test time out (after a 2 min wait).
* Don't give stdin to 'dotnet watch', because 'dotnet test' goes bananas. Deadlocks everywhere (dozens of threads stuck while trying to determine the cursor position in the terminal, etc).
* Disable build servers. Not sure if it helps, but when random things fail, random stuff gets tried, and this won't hurt.
* Don't run desktop test apps with 'open', because then the test app's process is not a descendent of the 'dotnet watch' process, and if something goes wrong and the test needs to kill 'dotnet watch', the test app won't be killed.
* Always cancel the 'dotnet watch' process at the end. Copilot suggested doing this, and it sounded good so here it is.
* Augment the 'Execution' class to kill the entire process tree. Once again, Copilot suggested doing this, and it sounds like a good thing to do.
* Add CoreCLR mobile variations.
@rolfbjarne rolfbjarne requested a review from Copilot June 17, 2026 13:14
@rolfbjarne

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR re-enables and expands the dotnet watch unit tests on the net11.0 branch, while improving test reliability and process handling in the shared Execution helper used by tests/tools.

Changes:

  • Extend Execution to optionally close stdin for spawned processes, and to kill process trees on cancellation/timeout (where supported).
  • Re-enable/expand DotNetWatchTest across additional Apple platforms and add CoreCLR/Mono runtime variations.
  • Improve DotNetWatchTest robustness (detect initial build failures earlier, avoid stdin deadlocks, and adjust cleanup behavior).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
tools/common/Execution.cs Adds stdin-closing option and introduces process-tree kill helper used on cancellation/timeout.
tests/dotnet/UnitTests/DotNetWatchTest.cs Re-enables/enlarges dotnet watch coverage and hardens the test flow & cleanup.

Comment thread tools/common/Execution.cs Outdated
Comment thread tools/common/Execution.cs
Comment on lines +216 to 218
Log?.WriteLine ($"Command '{p.StartInfo.FileName} {p.StartInfo.Arguments}' (pid: {pid}) was cancelled, and will be killed.");
KillProcess (p, pid, Log);
} catch (Exception ex) {
Comment thread tools/common/Execution.cs
Comment on lines +226 to 230
Log?.WriteLine ($"Command '{p.StartInfo.FileName} {p.StartInfo.Arguments}' (pid: {pid}) didn't finish in {Timeout.Value.TotalMilliseconds} ms, and will be killed.");
TimedOut = true;
try {
p.Kill ();
KillProcess (p, pid, Log);
} catch (Exception ex) {
Comment on lines +157 to +161
// Wait for the app to start and show initial output
debugLog.WriteLine ("Waiting for app start...");
if (!appStarted.Task.Wait (TimeSpan.FromMinutes (1)))
Assert.Fail ($"Timed out waiting for the app to start. Output:\n{string.Join ("\n", output)}\nDebug output:\n{string.Join ("\n", File.ReadAllLines (debugLogPath))}");
debugLog.WriteLine ("App started!");
Comment on lines +182 to +188
try {
debugLog.WriteLine ("Waiting for exit...");
watchTask.Wait (TimeSpan.FromSeconds (30));
debugLog.WriteLine ("Waited for exit");
} catch {
// Expected - the process was cancelled
}
Comment on lines +163 to +167
debugLog.WriteLine ("Waiting for 'dotnet watch' to be waiting for changes...");
if (!waitingForChanges.Task.Wait (TimeSpan.FromMinutes (1)))
Assert.Fail ($"Timed out waiting for the 'dotnet watch' to be waiting for changes. Output:\n{string.Join ("\n", output)}\nDebug output:\n{string.Join ("\n", File.ReadAllLines (debugLogPath))}");
debugLog.WriteLine ("Waiting for changes!");
Assert.That (waitingForChanges.Task.Result, Is.True, "Build failed");
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

- Remove unused pid/log parameters from KillProcess.
- Detect build failures early while waiting for app start, instead of
  timing out after 1 minute.
- Move 'Waiting for changes!' log after confirming the build succeeded.
- Log exceptions and timeout in cleanup path instead of swallowing them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #e373f1e] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: e373f1efe69766c9837781f9797643f90080683e [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #e373f1e] Build passed (Build packages) ✅

Pipeline on Agent
Hash: e373f1efe69766c9837781f9797643f90080683e [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: e373f1efe69766c9837781f9797643f90080683e [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #e373f1e] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: e373f1efe69766c9837781f9797643f90080683e [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #e373f1e] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 36 tests failed, 169 tests passed.

Failures

❌ fsharp tests

2 tests failed, 2 tests passed.

Failed tests

  • fsharp/iOS - simulator/Debug: LaunchTimedOut
  • fsharp/tvOS - simulator/Debug: LaunchTimedOut

Html Report (VSDrops) Download

❌ introspection tests

6 tests failed, 3 tests passed.

Failed tests

  • introspection/iOS - simulator/Debug: LaunchTimedOut
  • introspection/iOS - simulator/CoreCLR: LaunchTimedOut
  • introspection/iOS - simulator/Debug (ARM64): LaunchTimedOut
  • introspection/tvOS - simulator/Debug: LaunchTimedOut
  • introspection/tvOS - simulator/CoreCLR: LaunchTimedOut
  • introspection/tvOS - simulator/Debug (ARM64): LaunchTimedOut

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

26 tests failed, 0 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Debug: LaunchTimedOut
  • monotouch-test/tvOS - simulator/Debug (CoreCLR): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (CoreCLR, ARM64): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (CoreCLR, x64): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (CoreCLR, Universal): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (link sdk): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (link all): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Debug (static registrar): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (all optimizations): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Debug (ARM64): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (NativeAOT, ARM64): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, NativeAOT, ARM64): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Debug (managed static registrar): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Debug (trimmable static registrar): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (managed static registrar, all optimizations): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, all optimizations): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (NativeAOT, x64): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, NativeAOT, x64): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Debug (interpreter): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (interpreter): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (compat inline Class.GetHandle): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (strict inline Class.GetHandle): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (compat inline dlfcn): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (strict inline dlfcn, link sdk): LaunchTimedOut
  • monotouch-test/tvOS - simulator/Release (NativeAOT, .NET 11 defaults): LaunchTimedOut

Html Report (VSDrops) Download

❌ Tests on macOS Sonoma (14) tests

2 tests failed, 3 tests passed.

Failed tests

  • introspection: Failed (exit code 2)
    • CheckFailAttachments : System.NullReferenceException : Object reference not set to an instance of an object.
  • monotouch-test: Failed (exit code 2)
    • No test failure details available. stderr output:
      • Got a SIGABRT while executing native code. This usually indicates
      • a fatal error in the runtime or one of the native libraries
      • used by your application.
      • make[1]: *** [exec-maccatalyst-dotnet-x64-monotouch-test] Error 134
      • sed: ../.git: No such file or directory
      • fatal: not a git repository (or any of the parent directories): .git
      • fatal: not a git repository (or any of the parent directories): .git
      • ../Make.config:218: The required Xcode (26.5) is not installed in /Applications/Xcode_26.5.0.app/Contents/Developer - this directory does not exist. Any parts of the build that require Xcode will be disabled.
      • /bin/sh: ./create-make-config.sh: No such file or directory
      • make: *** [exec-monotouch-test] Error 1

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 26 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 30 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 23 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: e373f1efe69766c9837781f9797643f90080683e [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants