Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix a couple of dotnet-watch test failures #49558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
Merged

Fix a couple of dotnet-watch test failures #49558

merged 2 commits into from
Jun 25, 2025

Conversation

tmat
Copy link
Member

@tmat tmat commented Jun 25, 2025

When validating DefaultItemExcludes account for Unix directory separators (not sure why the test passed CI).
AddSourceFile tested adding and then updating source files. Apparently, the file system may reorder these operations and dotnet-watch might observe the update before the addition and try apply change, which will fail.

@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 15:31
@tmat tmat requested review from arunchndr and a team as code owners June 25, 2025 15:31
Copy link
Contributor

@Copilot Copilot AI left a comment

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 fixes a couple of dotnet-watch test failures by adding regex-based output assertions, improving update logging, and updating tests to use the new assertions for cross-platform path separators.

  • Added AssertOutputContains(Regex) in WatchableApp and implemented AssertEx.ContainsPattern.
  • Enhanced UpdateSourceFile to distinguish between added and updated files in test logs.
  • Updated existing tests to use regex assertions to handle path separator variations.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/dotnet-watch.Tests/Watch/Utilities/WatchableApp.cs Added AssertOutputContains(Regex) overload and imported Regex.
test/dotnet-watch.Tests/Watch/Utilities/DotNetWatchTestBase.cs Improved UpdateSourceFile to log whether a file was added or updated.
test/dotnet-watch.Tests/Utilities/AssertEx.cs Implemented ContainsPattern to assert regex matches in output.
test/dotnet-watch.Tests/HotReload/ApplyDeltaTests.cs Updated test to use AssertOutputContains(new Regex(...)) for path globs.
Comments suppressed due to low confidence (2)

test/dotnet-watch.Tests/Watch/Utilities/DotNetWatchTestBase.cs:33

  • [nitpick] The variable name 'existed' is ambiguous; consider renaming it to 'fileExisted' or 'didExist' for clearer intent.
        var existed = File.Exists(path);

test/dotnet-watch.Tests/Utilities/AssertEx.cs:258

  • The new ContainsPattern assertion method isn't directly covered by its own unit tests. Add dedicated tests for both matching and non-matching scenarios to ensure it behaves as expected.
        public static void ContainsPattern(Regex expected, IEnumerable<string> items)

@tmat
Copy link
Member Author

tmat commented Jun 25, 2025

@DustinCampbell ptal

@tmat tmat merged commit c6eaa69 into dotnet:main Jun 25, 2025
27 checks passed
@tmat tmat deleted the FixTest branch June 25, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants