-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix loading app-local ICU #77065
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
Merged
Merged
Fix loading app-local ICU #77065
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a2911b8
Fix loading app-local ICU
tarekgh 8607651
Restrict the platforms to run the tests on
tarekgh 299d255
Adjust the test supported platforms
tarekgh 13ce1cb
Test Platforms
tarekgh ea10dcf
Fix the test OS filtering
tarekgh 563ae4b
address the feedback
tarekgh 66b46f5
More feedback addressing
tarekgh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>$(NetCoreAppCurrent)</TargetFramework> | ||
| <TestRuntime>true</TestRuntime> | ||
| <IncludeRemoteExecutor>true</IncludeRemoteExecutor> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="IcuAppLocal.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" /> | ||
|
|
||
| <!-- | ||
| We define this switch dynamically during the runtime using RemoteExecutor. | ||
| The reason is, if we enable ICU app-local here, this test will compile and run | ||
| on all supported OSs even the ICU NuGet package not have native bits support such OSs. | ||
| Note, it doesn't matter if we have test case conditioned to not run on such OSs, because | ||
| the test has to start running first before filtering the test cases and teh globalization | ||
| code will run at that time and will fail fast at that time. | ||
tarekgh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" /> | ||
| --> | ||
| </ItemGroup> | ||
| </Project> | ||
50 changes: 50 additions & 0 deletions
50
src/libraries/System.Globalization/tests/IcuAppLocal/IcuAppLocal.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Microsoft.DotNet.RemoteExecutor; | ||
| using System.Diagnostics; | ||
| using System.Reflection; | ||
| using Xunit; | ||
|
|
||
| namespace System.Globalization.Tests | ||
| { | ||
| public class IcuAppLocalTests | ||
| { | ||
|
|
||
| private static bool SupportIcuPackageDownload => PlatformDetection.Is64BitProcess && | ||
tarekgh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| PlatformDetection.IsNotOSX && | ||
tarekgh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| PlatformDetection.IsNotMobile && | ||
| !PlatformDetection.IsAlpine && | ||
| !PlatformDetection.IsLinuxBionic && | ||
| RemoteExecutor.IsSupported; | ||
|
|
||
| [ConditionalFact(nameof(SupportIcuPackageDownload))] | ||
tarekgh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public void TestIcuAppLocal() | ||
| { | ||
| // We define this switch dynamically during the runtime using RemoteExecutor. | ||
| // The reason is, if we enable ICU app-local here, this test will compile and run | ||
| // on all supported OSs even the ICU NuGet package not have native bits support such OSs. | ||
| // Note, it doesn't matter if we have test case conditioned to not run on such OSs, because | ||
| // the test has to start running first before filtering the test cases and the globalization | ||
| // code will run at that time and will fail fast at that time. | ||
|
|
||
| ProcessStartInfo psi = new ProcessStartInfo() { UseShellExecute = false }; | ||
tarekgh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| psi.Environment.Add("DOTNET_SYSTEM_GLOBALIZATION_APPLOCALICU", "68.2.0.9"); | ||
|
|
||
| RemoteExecutor.Invoke(() => | ||
| { | ||
| Type? interopGlobalization = Type.GetType("Interop+Globalization, System.Private.CoreLib"); | ||
| Assert.NotNull(interopGlobalization); | ||
|
|
||
| MethodInfo? methodInfo = interopGlobalization.GetMethod("GetICUVersion", BindingFlags.NonPublic | BindingFlags.Static); | ||
| Assert.NotNull(methodInfo); | ||
|
|
||
| // Assert the ICU version 0x44020009 is 68.2.0.9 | ||
| Assert.Equal(0x44020009, (int)methodInfo.Invoke(null, null)); | ||
|
|
||
| // Now call globalization API to ensure the binding working without any problem. | ||
| Assert.Equal(-1, CultureInfo.GetCultureInfo("en-US").CompareInfo.Compare("sample\u0000", "Sample\u0000", CompareOptions.IgnoreSymbols)); | ||
| }, new RemoteInvokeOptions { StartInfo = psi }).Dispose(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.