Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Moseley <danmose@microsoft.com>2018-03-01 08:45:20 +0300
committerGitHub <noreply@github.com>2018-03-01 08:45:20 +0300
commit0c4fe29556861d5e728cd1f47afb687eb2711623 (patch)
tree22d42e68bf66e4fe168d1c9d50fbff647b4f9a14 /src/System.IO.FileSystem/tests
parente6b1cb21b46136f1753d4504d58f72ee4810bf9c (diff)
Logging for TimesIncludeMillisecondPart test and reenable for Linux (#27559)
* Logging for TimesIncludeMillisecondPart test * Enable test for Linux * Formatting
Diffstat (limited to 'src/System.IO.FileSystem/tests')
-rw-r--r--src/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs b/src/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs
index f650ae07f3..e070f6166b 100644
--- a/src/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs
+++ b/src/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
+using System.Threading;
using Xunit;
namespace System.IO.Tests
@@ -68,19 +69,31 @@ namespace System.IO.Tests
}
[Fact]
- [ActiveIssue(26349, TestPlatforms.AnyUnix)]
+ [PlatformSpecific(~TestPlatforms.OSX)] // OSX does not currently support millisec granularity
public void TimesIncludeMillisecondPart()
{
T item = GetExistingItem();
Assert.All(TimeFunctions(), (function) =>
{
var msec = 0;
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 5; i++)
{
- msec = function.Getter(item).Millisecond;
+ DateTime time = function.Getter(item);
+ msec = time.Millisecond;
if (msec != 0)
break;
+ // This case should only happen 1/1000 times, unless the OS/Filesystem does
+ // not support millisecond granularity.
+
+ // If it's 1/1000, or low granularity, this may help:
+ Thread.Sleep(1234);
+
+ // If it's the OS/Filesystem often returns 0 for the millisecond part, this may
+ // help prove it. This should only be written 1/1000 runs, unless the test is going to
+ // fail.
+ Console.WriteLine($"TimesIncludeMillisecondPart got a file time of {time.ToString("o")}");
+
item = GetExistingItem(); // try a new file/directory
}
@@ -88,6 +101,20 @@ namespace System.IO.Tests
});
}
+ [Fact]
+ // OSX does not currently support millisec granularity: use this test as a canary to flag
+ // if this ever changes so we can enable the actual test
+ [PlatformSpecific(TestPlatforms.OSX)]
+ public void TimesIncludeMillisecondPart_OSX()
+ {
+ T item = GetExistingItem();
+ Assert.All(TimeFunctions(), (function) =>
+ {
+ DateTime time = function.Getter(item);
+ Assert.Equal(0, time.Millisecond);
+ });
+ }
+
protected void ValidateSetTimes(T item, DateTime beforeTime, DateTime afterTime)
{
Assert.All(TimeFunctions(), (function) =>