Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@maryamariyan
Copy link

@maryamariyan maryamariyan commented Jun 29, 2018

Fixing osx filesystem test customizing assert per driver format.

Switching assert for different driver formats

Fixes #30742

Assert.All(TimeFunctions(), (function) =>
{
DateTime time = function.Getter(item);
Assert.NotEqual(0, time.Millisecond);
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this more? Why are we verifying it's equal on hfs and not equal on everything else?

Copy link
Member

Choose a reason for hiding this comment

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

You can't rely on milliseconds != 0 -- it will fail 1 in 1000 times. It needs to use the same approach as TimesIncludeMillisecondPart_Windows.

Copy link
Member

Choose a reason for hiding this comment

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

Is it that every other file system other than hfs on macOS support milliseconds times?

If so,
a) seems like a potential reliability issue to assert NotEqual, as 0 is a valid number of milliseconds, so this test would theoretically fail 1/1000 times, which will make this very flaky in CI where the test potentially runs hundreds of times a day.
b) seems like the test should really be refactored, e.g. so that https://github.com/dotnet/corefx/pull/30763/files#diff-170a22c34cffbe331bbbc9364e76aa75L74 is used when on non-hfs and this test remains for hfs.

Copy link
Member

Choose a reason for hiding this comment

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

What @stephentoub suggests is fine too.

// if this ever changes so we can enable the actual test
[PlatformSpecific(TestPlatforms.OSX)]
public void TimesIncludeMillisecondPart_OSX()
{
Copy link
Member

Choose a reason for hiding this comment

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

comment above is now outdated

Assert.Equal(0, time.Millisecond);
});
}
else
Copy link
Member

Choose a reason for hiding this comment

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

I actually think it's not worth bothering doing anything on hfs. Just make the test skip if driveFormat != apfs.

- non any linux or
- OSX non-HFS driver formats

Fixes dotnet#30472
@maryamariyan maryamariyan changed the title Fixing osx filesystem test customizing assert per driver format Updating FileSystem tests that check milisecond granularity for OSX Jul 3, 2018
@maryamariyan maryamariyan changed the title Updating FileSystem tests that check milisecond granularity for OSX Combines/Updates Unix FileSystem tests that check millisecond granularity Jul 3, 2018
@maryamariyan maryamariyan changed the title Combines/Updates Unix FileSystem tests that check millisecond granularity Updates Unix FileSystem tests that check millisecond granularity Jul 3, 2018
@maryamariyan
Copy link
Author

The windows test failure in System.IO.Pipelines.Tests is unrelated to this PR.

string driveFormat = new DriveInfo(GetItemPath(item)).DriveFormat;

Assert.All(TimeFunctions(), (function) =>
if (!PlatformDetection.IsOSX ||
Copy link
Member

@danmoseley danmoseley Jul 3, 2018

Choose a reason for hiding this comment

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

Style nit, sometimes !(A && B) is easier to read than !A || !B. In this case I read "if it's not Mac or it's not HFS" whereas what a human would say is "if it's not HFS on Mac" so I believe

!(PlatformDetection.IsOSX && 
  driveFormat.Equals(HFS, StringComparison.InvariantCultureIgnoreCase)

may be easier to read.

Copy link
Member

Choose a reason for hiding this comment

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

No need to go back to fix, just general observation

@danmoseley
Copy link
Member

thanks!

@danmoseley danmoseley merged commit a399e51 into dotnet:master Jul 3, 2018
@karelz karelz added this to the 3.0 milestone Jul 8, 2018
maryamariyan added a commit to maryamariyan/corefx that referenced this pull request Aug 7, 2018
- non any linux or
- OSX non-HFS driver formats

Fixes dotnet#30472
maryamariyan added a commit that referenced this pull request Aug 10, 2018
- non any linux or
- OSX non-HFS driver formats

Fixes #30742
@maryamariyan maryamariyan deleted the fix-filesystem branch August 15, 2018 23:09
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
- non any linux or
- OSX non-HFS driver formats

Fixes dotnet/corefx#30472

Commit migrated from dotnet/corefx@a399e51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants