Skip to content
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

Extensions: Adding FileProviders and FileSystemGlobbing #33212

Merged
merged 14 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Using PlatformSpecific instead of OSSkipCondition
  • Loading branch information
maryamariyan committed Mar 12, 2020
commit 1090288f67abb1713c4a7276900b7414a837f4ea
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

<ItemGroup>
<Compile Include="**\*.cs" />
<Compile Include="$(CommonTestPath)Extensions\TestingUtils\Microsoft.AspNetCore.Testing\src\xunit\OSSkipConditionAttribute.cs">
<Link>Common\tests\Extensions\TestingUtils\Microsoft.AspNetCore.Testing\src\xunit\OSSkipConditionAttribute.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)Extensions\TestingUtils\Microsoft.AspNetCore.Testing\src\xunit\OperatingSystems.cs">
<Link>Common\tests\Extensions\TestingUtils\Microsoft.AspNetCore.Testing\src\xunit\OperatingSystems.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)Extensions\TestingUtils\Microsoft.AspNetCore.Testing\src\xunit\ITestCondition.cs">
<Link>Common\tests\Extensions\TestingUtils\Microsoft.AspNetCore.Testing\src\xunit\ITestCondition.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ public void GetFileInfoReturnsNotFoundFileInfoForEmptyPath()
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[Theory]
[InlineData("/")]
[InlineData("///")]
[InlineData("/\\/")]
[InlineData("\\/\\/")]
// Testing Windows specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetFileInfoReturnsPhysicalFileInfoForValidPathsWithLeadingSlashes_Windows(string path)
{
GetFileInfoReturnsPhysicalFileInfoForValidPathsWithLeadingSlashes(path);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows, SkipReason = "Testing Unix specific behaviour on leading slashes.")]
[Theory]
[InlineData("/")]
[InlineData("///")]
// Testing Unix specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void GetFileInfoReturnsPhysicalFileInfoForValidPathsWithLeadingSlashes_Unix(string path)
{
GetFileInfoReturnsPhysicalFileInfoForValidPathsWithLeadingSlashes(path);
Expand All @@ -69,19 +70,20 @@ private void GetFileInfoReturnsPhysicalFileInfoForValidPathsWithLeadingSlashes(s
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[Theory]
[InlineData("/C:\\Windows\\System32")]
[InlineData("/\0/")]
// Testing Windows specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetFileInfoReturnsNotFoundFileInfoForIllegalPathWithLeadingSlashes_Windows(string path)
{
GetFileInfoReturnsNotFoundFileInfoForIllegalPathWithLeadingSlashes(path);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows, SkipReason = "Testing Unix specific behaviour on leading slashes.")]
[Theory]
[InlineData("/\0/")]
// Testing Unix specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void GetFileInfoReturnsNotFoundFileInfoForIllegalPathWithLeadingSlashes_Unix(string path)
{
GetFileInfoReturnsNotFoundFileInfoForIllegalPathWithLeadingSlashes(path);
Expand Down Expand Up @@ -122,9 +124,9 @@ public void GetFileInfoReturnsNonExistentFileInfoForIllegalPath(string path)
}
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Paths starting with / are considered relative.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Paths starting with / are considered relative.")]
[Fact]
// Paths starting with / are considered relative.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetFileInfoReturnsNotFoundFileInfoForAbsolutePath()
{
using (var provider = new PhysicalFileProvider(Path.GetTempPath()))
Expand Down Expand Up @@ -193,9 +195,9 @@ public void CreateReadStreamSucceedsOnEmptyFile()
}
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Hidden and system files only make sense on Windows.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Hidden and system files only make sense on Windows.")]
[Fact]
// Hidden and system files only make sense on Windows.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetFileInfoReturnsNotFoundFileInfoForHiddenFile()
{
using (var root = new DisposableFileSystem())
Expand All @@ -215,9 +217,9 @@ public void GetFileInfoReturnsNotFoundFileInfoForHiddenFile()
}
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Hidden and system files only make sense on Windows.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Hidden and system files only make sense on Windows.")]
[Fact]
// Hidden and system files only make sense on Windows.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetFileInfoReturnsNotFoundFileInfoForSystemFile()
{
using (var root = new DisposableFileSystem())
Expand Down Expand Up @@ -447,22 +449,21 @@ public async Task TokensFiredOnFileDeleted()
}

// On Unix the minimum invalid file path characters are / and \0
[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[Theory]
[InlineData("/test:test")]
[InlineData("/dir/name\"")]
[InlineData("/dir>/name")]
[PlatformSpecific(TestPlatforms.Windows)]
public void InvalidPath_DoesNotThrowWindows_GetFileInfo(string path)
{
InvalidPath_DoesNotThrowGeneric_GetFileInfo(path);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows)]
[Theory]
[InlineData("/test:test\0")]
[InlineData("/dir/\0name\"")]
[InlineData("/dir>/name\0")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void InvalidPath_DoesNotThrowUnix_GetFileInfo(string path)
{
InvalidPath_DoesNotThrowGeneric_GetFileInfo(path);
Expand All @@ -478,22 +479,21 @@ private void InvalidPath_DoesNotThrowGeneric_GetFileInfo(string path)
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[Theory]
[InlineData("/test:test")]
[InlineData("/dir/name\"")]
[InlineData("/dir>/name")]
[PlatformSpecific(TestPlatforms.Windows)]
public void InvalidPath_DoesNotThrowWindows_GetDirectoryContents(string path)
{
InvalidPath_DoesNotThrowGeneric_GetDirectoryContents(path);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows)]
[Theory]
[InlineData("/test:test\0")]
[InlineData("/dir/\0name\"")]
[InlineData("/dir>/name\0")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void InvalidPath_DoesNotThrowUnix_GetDirectoryContents(string path)
{
InvalidPath_DoesNotThrowGeneric_GetDirectoryContents(path);
Expand All @@ -519,22 +519,23 @@ public void GetDirectoryContentsReturnsNotFoundDirectoryContentsForNullPath()
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[Theory]
[InlineData("/")]
[InlineData("///")]
[InlineData("/\\/")]
[InlineData("\\/\\/")]
// Testing Windows specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetDirectoryContentsReturnsEnumerableDirectoryContentsForValidPathWithLeadingSlashes_Windows(string path)
{
GetDirectoryContentsReturnsEnumerableDirectoryContentsForValidPathWithLeadingSlashes(path);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows, SkipReason = "Testing Unix specific behaviour on leading slashes.")]
[Theory]
[InlineData("/")]
[InlineData("///")]
// Testing Unix specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void GetDirectoryContentsReturnsEnumerableDirectoryContentsForValidPathWithLeadingSlashes_Unix(string path)
{
GetDirectoryContentsReturnsEnumerableDirectoryContentsForValidPathWithLeadingSlashes(path);
Expand All @@ -549,24 +550,23 @@ private void GetDirectoryContentsReturnsEnumerableDirectoryContentsForValidPathW
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[Theory]
[InlineData("/C:\\Windows\\System32")]
[InlineData("/\0/")]
[MemberData(nameof(InvalidPaths))]
// Testing Windows specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetDirectoryContentsReturnsNotFoundDirectoryContentsForInvalidPath_Windows(string path)
{
GetDirectoryContentsReturnsNotFoundDirectoryContentsForInvalidPath(path);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows, SkipReason = "Testing Unix specific behaviour on leading slashes.")]
[Theory]
[InlineData("/\0/")]
[InlineData("/\\/")]
[InlineData("\\/\\/")]
[MemberData(nameof(InvalidPaths))]
// Testing Unix specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void GetDirectoryContentsReturnsNotFoundDirectoryContentsForInvalidPath_Unix(string path)
{
Expand Down Expand Up @@ -635,9 +635,9 @@ public void GetDirectoryContentsReturnsNotFoundDirectoryContentsForPathThatNavig
}
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Hidden and system files only make sense on Windows.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Hidden and system files only make sense on Windows.")]
[Fact]
// Hidden and system files only make sense on Windows.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetDirectoryContentsDoesNotReturnFileInfoForHiddenFile()
{
using (var root = new DisposableFileSystem())
Expand All @@ -660,9 +660,9 @@ public void GetDirectoryContentsDoesNotReturnFileInfoForHiddenFile()
}
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Hidden and system files only make sense on Windows.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Hidden and system files only make sense on Windows.")]
[Fact]
// Hidden and system files only make sense on Windows.
[PlatformSpecific(TestPlatforms.Windows)]
public void GetDirectoryContentsDoesNotReturnFileInfoForSystemFile()
{
using (var root = new DisposableFileSystem())
Expand Down Expand Up @@ -894,11 +894,9 @@ public void TokenForWhitespaceFilters()
}
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux,
SkipReason = "We treat forward slash differently so rooted path can happen only on windows.")]
[OSSkipCondition(OperatingSystems.MacOSX,
SkipReason = "We treat forward slash differently so rooted path can happen only on windows.")]
[Fact]
// We treat forward slash differently so rooted path can happen only on windows.
[PlatformSpecific(TestPlatforms.Windows)]
public void NoopChangeTokenForAbsolutePathFilters()
{
using (var root = new DisposableFileSystem())
Expand Down Expand Up @@ -998,22 +996,23 @@ public async Task TokenFiredForFilesUnderPathEndingWithSlash()
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[Theory]
[InlineData("/")]
[InlineData("///")]
[InlineData("/\\/")]
[InlineData("\\/\\/")]
// Testing Windows specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.Windows)]
public async Task TokenFiredForRelativePathStartingWithSlash_Windows(string slashes)
{
await TokenFiredForRelativePathStartingWithSlash(slashes);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows, SkipReason = "Testing Unix specific behaviour on leading slashes.")]
[Theory]
[InlineData("/")]
[InlineData("///")]
// Testing Unix specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.AnyUnix)]
public async Task TokenFiredForRelativePathStartingWithSlash_Unix(string slashes)
{
await TokenFiredForRelativePathStartingWithSlash(slashes);
Expand Down Expand Up @@ -1042,19 +1041,20 @@ private async Task TokenFiredForRelativePathStartingWithSlash(string slashes)
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Testing Windows specific behaviour on leading slashes.")]
[Theory]
[InlineData("/C:\\Windows\\System32")]
[InlineData("/\0/")]
// Testing Windows specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.Windows)]
public async Task TokenNotFiredForInvalidPathStartingWithSlash_Windows(string slashes)
{
await TokenNotFiredForInvalidPathStartingWithSlash(slashes);
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows, SkipReason = "Testing Unix specific behaviour on leading slashes.")]
[Theory]
[InlineData("/\0/")]
// Testing Unix specific behaviour on leading slashes.
[PlatformSpecific(TestPlatforms.AnyUnix)]
public async Task TokenNotFiredForInvalidPathStartingWithSlash_Unix(string slashes)
{
await TokenNotFiredForInvalidPathStartingWithSlash(slashes);
Expand Down Expand Up @@ -1255,9 +1255,9 @@ public async Task TokenNotFiredForFileNameStartingWithPeriod()
}
}

[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Hidden and system files only make sense on Windows.")]
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Hidden and system files only make sense on Windows.")]
[Fact]
// Hidden and system files only make sense on Windows.
[PlatformSpecific(TestPlatforms.Windows)]
public async Task TokensNotFiredForHiddenAndSystemFiles()
{
using (var root = new DisposableFileSystem())
Expand Down