diff --git a/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs b/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs index cdd33cef8cee7..63e305a303e97 100644 --- a/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs +++ b/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs @@ -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(); @@ -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); @@ -79,12 +84,22 @@ 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}]"); } } @@ -92,11 +107,15 @@ public void ComponentWithNoDependenciesCaseChangedOnAsm() [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(); @@ -122,12 +141,22 @@ 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}]"); } } @@ -135,11 +164,15 @@ public void ComponentWithNoDependenciesCaseChangedOnDepsAndAsm() [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(); @@ -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); @@ -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}]"); } }