Skip to content

Commit

Permalink
Convert test to theory, and add VB test
Browse files Browse the repository at this point in the history
  • Loading branch information
khyperia committed Nov 9, 2017
1 parent 6c1e33a commit 07fd8ad
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
35 changes: 13 additions & 22 deletions src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2524,29 +2524,20 @@ public void Bug9288_keycontainer()
#region PathMap Linux Tests
// Like the above (CoreCLR Signing Tests), these aren't actually syntax tests, but this is in one of only two assemblies tested on linux

[Fact]
public void PathMapKeepsCrossPlatformRoot()
[Theory]
[InlineData("C:\\", "/", "C:\\", "/")]
[InlineData("C:\\temp\\", "/temp/", "C:\\temp", "/temp")]
[InlineData("C:\\temp\\", "/temp/", "C:\\temp\\", "/temp/")]
[InlineData("/", "C:\\", "/", "C:\\")]
[InlineData("/temp/", "C:\\temp\\", "/temp", "C:\\temp")]
[InlineData("/temp/", "C:\\temp\\", "/temp/", "C:\\temp\\")]
public void PathMapKeepsCrossPlatformRoot(string expectedFrom, string expectedTo, string sourceFrom, string sourceTo)
{
CSharpCommandLineArguments parse(params string[] args)
{
var parsedArgs = CSharpCommandLineParser.Default.Parse(args, TempRoot.Root, RuntimeEnvironment.GetRuntimeDirectory(), null);
parsedArgs.Errors.Verify();
return parsedArgs;
}

Assert.Equal(new KeyValuePair<string, string>("C:\\", "/"), parse("/pathmap:C:\\=/", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("C:\\", "/temp/"), parse("/pathmap:C:\\=/temp", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("C:\\", "/temp/"), parse("/pathmap:C:\\=/temp/", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("C:\\temp\\", "/"), parse("/pathmap:C:\\temp\\=/", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("C:\\temp\\", "/temp/"), parse("/pathmap:C:\\temp=/temp", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("C:\\temp\\", "/temp/"), parse("/pathmap:C:\\temp\\=/temp/", "a.cs").PathMap[0]);

Assert.Equal(new KeyValuePair<string, string>("/", "C:\\"), parse("/pathmap:/=C:\\", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("/", "C:\\temp\\"), parse("/pathmap:/=C:\\temp", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("/", "C:\\temp\\"), parse("/pathmap:/=C:\\temp\\", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("/temp/", "C:\\"), parse("/pathmap:/temp/=C:\\", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("/temp/", "C:\\temp\\"), parse("/pathmap:/temp=C:\\temp", "a.cs").PathMap[0]);
Assert.Equal(new KeyValuePair<string, string>("/temp/", "C:\\temp\\"), parse("/pathmap:/temp/=C:\\temp\\", "a.cs").PathMap[0]);
var pathmapArg = $"/pathmap:{sourceFrom}={sourceTo}";
var parsedArgs = CSharpCommandLineParser.Default.Parse(new[] { pathmapArg, "a.cs" }, TempRoot.Root, RuntimeEnvironment.GetRuntimeDirectory(), null);
parsedArgs.Errors.Verify();
var expected = new KeyValuePair<string, string>(expectedFrom, expectedTo);
Assert.Equal(expected, parsedArgs.PathMap[0]);
}

[Fact]
Expand Down
33 changes: 33 additions & 0 deletions src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,39 @@ print Goodbye, World"
Assert.Equal(KeyValuePair.Create("K 2\", "V 2\"), parsedArgs.PathMap(1))
End Sub

' PathMapKeepsCrossPlatformRoot and PathMapInconsistentSlashes should be in an
' assembly that is ran cross-platform, but as no visual basic test assemblies are
' run cross-platform, put this here in the hopes that this will eventually be ported.
<Theory>
<InlineData("C:\", "/", "C:\", "/")>
<InlineData("C:\temp\", "/temp/", "C:\temp", "/temp")>
<InlineData("C:\temp\", "/temp/", "C:\temp\", "/temp/")>
<InlineData("/", "C:\", "/", "C:\")>
<InlineData("/temp/", "C:\temp\", "/temp", "C:\temp")>
<InlineData("/temp/", "C:\temp\", "/temp/", "C:\temp\")>
Public Sub PathMapKeepsCrossPlatformRoot(expectedFrom As String, expectedTo As String, sourceFrom As String, sourceTo As String)
Dim pathmapArg = $"/pathmap:{sourceFrom}={sourceTo}"
Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse({pathmapArg, "a.cs"}, TempRoot.Root, RuntimeEnvironment.GetRuntimeDirectory(), Nothing)
parsedArgs.Errors.Verify()
Dim expected = New KeyValuePair(Of String, String)(expectedFrom, expectedTo)
Assert.Equal(expected, parsedArgs.PathMap(0))
End Sub

<Fact>
Public Sub PathMapInconsistentSlashes()
Dim Parse = Function(args() As String) As VisualBasicCommandLineArguments
Dim parsedArgs = VisualBasicCommandLineParser.Default.Parse(args, TempRoot.Root, RuntimeEnvironment.GetRuntimeDirectory(), Nothing)
parsedArgs.Errors.Verify()
Return parsedArgs
End Function
Dim sep = PathUtilities.DirectorySeparatorChar
Assert.Equal(New KeyValuePair(Of String, String)("C:\temp/goo" + sep, "/temp\goo" + sep), Parse({"/pathmap:C:\temp/goo=/temp\goo", "a.cs"}).PathMap(0))
Assert.Equal(New KeyValuePair(Of String, String)("noslash" + sep, "withoutslash" + sep), Parse({"/pathmap:noslash=withoutslash", "a.cs"}).PathMap(0))
Dim doublemap = Parse({"/pathmap:/temp=/goo,/temp/=/bar", "a.cs"}).PathMap
Assert.Equal(New KeyValuePair(Of String, String)("/temp/", "/goo/"), doublemap(0))
Assert.Equal(New KeyValuePair(Of String, String)("/temp/", "/bar/"), doublemap(1))
End Sub

<CompilerTrait(CompilerFeature.Determinism)>
<Fact>
Public Sub PathMapPdbDeterminism()
Expand Down

0 comments on commit 07fd8ad

Please sign in to comment.