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

Test fixes for casing #42879

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ public void ComponentWithNoDependenciesAndNoDeps()
[Fact]
public void ComponentWithNoDependenciesCaseChangedOnAsm()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Remove once https://github.com/dotnet/runtime/issues/42334 is resolved
return;
}
// Scenario: change the case of the first letter of component.AppDll file name

// Changing the casing of the first letter of a dependent assembly have different behavior in the 3 platforms
// Wisely the product code stays out of casing on dependent assemblies choosing the 1st assembly
// Linux: we fail
// Windows and Mac, probing succeeds but
// Windows: probing returns the original name
// Mac: probing return the new name including 2 assembly probing with the same new name and the changed deps file

var component = sharedTestState.ComponentWithNoDependencies.Copy();

Expand All @@ -65,6 +68,8 @@ public void ComponentWithNoDependenciesCaseChangedOnAsm()
string nameWOExtension = Path.GetFileNameWithoutExtension(fileName);
string nameWOExtensionCaseChanged = (Char.IsUpper(nameWOExtension[0]) ? nameWOExtension[0].ToString().ToLower() : nameWOExtension[0].ToString().ToUpper()) + nameWOExtension.Substring(1);
string changeFile = Path.Combine(Path.GetDirectoryName(fileName), (nameWOExtensionCaseChanged + Path.GetExtension(fileName)));
// on mac, hostpolicy returns the changed name for deps file as well
string changeDepsFile = Path.Combine(Path.GetDirectoryName(component.DepsJson), (nameWOExtensionCaseChanged + ".deps" + Path.GetExtension(component.DepsJson)));

// Rename
File.Move(fileName, changeFile);
Expand All @@ -79,24 +84,38 @@ public void ComponentWithNoDependenciesCaseChangedOnAsm()
.And.HaveStdErrContaining($"deps='{component.DepsJson}'")
.And.HaveStdErrContaining($"mgd_app='{component.AppDll}'");
}
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]")
.And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'")
.And.HaveStdErrContaining($"deps='{changeDepsFile}'")
.And.HaveStdErrContaining($"mgd_app='{changeFile}'");
}
else
{
// See https://github.com/dotnet/runtime/issues/42334
// OSPlatform.Linux
// We expect the test to fail due to the the case change of AppDll
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.Should().Fail()
.And.HaveStdErrContaining($"Failed to locate managed application [{component.AppDll}]");
}
}

[Fact]
public void ComponentWithNoDependenciesCaseChangedOnDepsAndAsm()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Remove once https://github.com/dotnet/runtime/issues/42334 is resolved
return;
}

// Scenario: change the case of the first letter of component.AppDll and component.DepsJson file names

// Changing the casing of the first letter of a dependent assembly have different behavior in the 3 platforms
// Wisely the product code stays out of casing on dependent assemblies choosing the 1st assembly
// Linux: we fail
// Windows and Mac, probing succeeds but
// Windows: probing returns the original name
// Mac: probing return the new name including 2 assembly probing with the same new name and the changed deps file

var component = sharedTestState.ComponentWithNoDependencies.Copy();

Expand All @@ -122,24 +141,38 @@ public void ComponentWithNoDependenciesCaseChangedOnDepsAndAsm()
.And.HaveStdErrContaining($"deps='{component.DepsJson}'")
.And.HaveStdErrContaining($"mgd_app='{component.AppDll}'");
}
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]")
.And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'")
.And.HaveStdErrContaining($"deps='{changeDepsFile}'")
.And.HaveStdErrContaining($"mgd_app='{changeFile}'");
}
else
{
// See https://github.com/dotnet/runtime/issues/42334
// OSPlatform.Linux
// We expect the test to fail due to the the case change of AppDll
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.Should().Fail()
.And.HaveStdErrContaining($"Failed to locate managed application [{component.AppDll}]");
}
}

[Fact]
public void ComponentWithNoDependenciesNoDepsCaseChangedOnAsm()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Remove once https://github.com/dotnet/runtime/issues/42334 is resolved
return;
}

// Scenario: change the case of the first letter of component.AppDll file name and delete component.DepsJson file

// Changing the casing of the first letter of a dependent assembly have different behavior in the 3 platforms
// Wisely the product code stays out of casing on dependent assemblies choosing the 1st assembly
// Linux: we fail
// Windows and Mac, probing succeeds but
// Windows: probing returns the original name
// Mac: probing return the new name including assembly probing with the new name and the changed deps file

var component = sharedTestState.ComponentWithNoDependencies.Copy();

Expand All @@ -148,6 +181,8 @@ public void ComponentWithNoDependenciesNoDepsCaseChangedOnAsm()
string nameWOExtension = Path.GetFileNameWithoutExtension(fileName);
string nameWOExtensionCaseChanged = (Char.IsUpper(nameWOExtension[0]) ? nameWOExtension[0].ToString().ToLower() : nameWOExtension[0].ToString().ToUpper()) + nameWOExtension.Substring(1);
string changeFile = Path.Combine(Path.GetDirectoryName(fileName), (nameWOExtensionCaseChanged + Path.GetExtension(fileName)));
// on mac, hostpolicy returns the changed name for deps file as well
string changeDepsFile = Path.Combine(Path.GetDirectoryName(component.DepsJson), (nameWOExtensionCaseChanged + ".deps" + Path.GetExtension(component.DepsJson)));

// Rename
File.Move(fileName, changeFile);
Expand All @@ -164,12 +199,22 @@ public void ComponentWithNoDependenciesNoDepsCaseChangedOnAsm()
.And.HaveStdErrContaining($"deps='{component.DepsJson}'")
.And.HaveStdErrContaining($"mgd_app='{component.AppDll}'");
}
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success")
.And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}]")
.And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'")
.And.HaveStdErrContaining($"deps='{changeDepsFile}'")
.And.HaveStdErrContaining($"mgd_app='{changeFile}'");
}
else
{
// See https://github.com/dotnet/runtime/issues/42334
// OSPlatform.Linux
// We expect the test to fail due to the the case change of AppDll
sharedTestState.RunComponentResolutionTest(component)
.Should().Pass()
.Should().Fail()
.And.HaveStdErrContaining($"Failed to locate managed application [{component.AppDll}]");
}
}
Expand Down