-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Make polling use the symbolic link target's LastWriteTime #55664
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
Changes from 1 commit
f515710
08233ba
d780995
ac4a845
b4895ad
ebb0326
1164e33
98b737a
75fcf96
144335a
9c50a3a
b2f9bad
d8d143a
c7e28d4
5b85631
5c27cae
19dd9c3
8c1b3a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…o debug CI failures and increase delay between writes
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,7 @@ | |
|
|
||
| using System; | ||
| using System.IO; | ||
| using System.Threading; | ||
| using Microsoft.Extensions.FileProviders.Physical; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Extensions.Primitives; | ||
| using Xunit; | ||
|
|
||
|
|
@@ -15,7 +14,7 @@ public partial class PhysicalFileProviderTests | |
| [Theory] | ||
| [InlineData(false)] | ||
| [InlineData(true)] | ||
| public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink(bool useWildcard) | ||
| public async Task UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink(bool useWildcard) | ||
| { | ||
| // Arrange | ||
| using var rootOfFile = new DisposableFileSystem(); | ||
|
|
@@ -32,12 +31,12 @@ public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink(bool | |
| Assert.False(token.HasChanged); | ||
|
|
||
| // Act | ||
| Thread.Sleep(100); // Wait a bit before writing again, see https://github.com/dotnet/runtime/issues/55951. | ||
| await Task.Delay(200); // Wait a bit before writing again, see https://github.com/dotnet/runtime/issues/55951. | ||
| File.WriteAllText(filePath, "v1.2"); | ||
| Thread.Sleep(GetTokenPollingInterval(token)); | ||
| await Task.Delay(GetTokenPollingInterval(token)); | ||
|
|
||
| // Assert | ||
| Assert.True(token.HasChanged); | ||
| Assert.True(token.HasChanged, $"Current time: {DateTime.UtcNow:O} file LastWriteTime: {File.GetLastWriteTimeUtc(filePath):O}"); | ||
| } | ||
|
|
||
| [Theory] | ||
|
|
@@ -64,7 +63,7 @@ public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_Targe | |
| [InlineData(false, true)] | ||
| [InlineData(true, false)] | ||
| [InlineData(true, true)] | ||
| public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_TargetChanged(bool useWildcard, bool fromTargetNonExistent) | ||
| public async Task UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_TargetChanged(bool useWildcard, bool linkWasBroken) | ||
| { | ||
| // Arrange | ||
| using var rootOfFile = new DisposableFileSystem(); | ||
|
|
@@ -73,9 +72,9 @@ public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_Targe | |
| File.WriteAllText(file2Path, "v2.1"); | ||
|
|
||
| string file1Path = Path.Combine(rootOfFile.RootPath, Path.GetRandomFileName()); | ||
| if (!fromTargetNonExistent) | ||
| if (!linkWasBroken) | ||
| { | ||
| Thread.Sleep(100); // Wait a bit before writing again, see https://github.com/dotnet/runtime/issues/55951. | ||
| await Task.Delay(200); // Wait a bit before writing again, see https://github.com/dotnet/runtime/issues/55951. | ||
| File.WriteAllText(file1Path, "v1.1"); | ||
| } | ||
|
|
||
|
|
@@ -92,16 +91,16 @@ public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_Targe | |
| // Act - Change link target to file 2. | ||
| File.Delete(linkPath); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to reset the target without deleting the link?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Through For Unix, I know that you can use the -f switch in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ln.html says that |
||
| File.CreateSymbolicLink(linkPath, file2Path); | ||
| Thread.Sleep(GetTokenPollingInterval(token)); | ||
| await Task.Delay(GetTokenPollingInterval(token)); | ||
|
|
||
| // Assert | ||
| Assert.True(token.HasChanged); // It should report the change regardless of the timestamp being older. | ||
| // Assert - It should report the change regardless of the timestamp being older. | ||
| Assert.True(token.HasChanged, $"Current time: {DateTime.UtcNow:O} file 1 LastWriteTime: {File.GetLastWriteTimeUtc(file1Path):O} file 2 LastWriteTime: {File.GetLastWriteTimeUtc(file2Path):O}"); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(false)] | ||
| [InlineData(true)] | ||
| public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_TargetDeleted(bool useWildcard) | ||
| public async Task UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_TargetDeleted(bool useWildcard) | ||
| { | ||
| // Arrange | ||
| using var rootOfFile = new DisposableFileSystem(); | ||
|
|
@@ -121,10 +120,10 @@ public void UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_Targe | |
|
|
||
| // Act | ||
| File.Delete(linkPath); | ||
| Thread.Sleep(GetTokenPollingInterval(token)); | ||
| await Task.Delay(GetTokenPollingInterval(token)); | ||
|
|
||
| // Assert | ||
| Assert.True(token.HasChanged); | ||
| Assert.True(token.HasChanged, $"Current time: {DateTime.UtcNow:O} file LastWriteTime: {File.GetLastWriteTimeUtc(filePath):O}"); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.