-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add SYSTEM_CORELIB_DIRECTORY host property for explicit CoreLib location #128734
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
+110
−1
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
07a8307
Add SYSTEM_CORELIB_DIRECTORY host property for explicit CoreLib location
elinor-fung 258613e
Add test for SYSTEM_CORELIB_DIRECTORY host property
elinor-fung 92b88d7
PR feedback
elinor-fung 05a5cdb
Update docs/design/features/host-runtime-information.md
elinor-fung 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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
src/tests/Loader/SystemCoreLibDirectory/SystemCoreLibDirectory.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,37 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using Xunit; | ||
|
|
||
| public class SystemCoreLibDirectory | ||
| { | ||
| [ConditionalFact(typeof(TestLibrary.Utilities), nameof(TestLibrary.Utilities.HasAssemblyFiles))] | ||
| public static void HostProvidedPath() | ||
| { | ||
| string configuredDirectory = AppContext.GetData("SYSTEM_CORELIB_DIRECTORY") as string; | ||
| Assert.False(string.IsNullOrEmpty(configuredDirectory), "SYSTEM_CORELIB_DIRECTORY should be set by the test harness"); | ||
| Assert.True(Directory.Exists(configuredDirectory), $"SYSTEM_CORELIB_DIRECTORY should reference an existing directory: '{configuredDirectory}'"); | ||
|
|
||
| string spclLocation = Path.GetFullPath(typeof(object).Assembly.Location); | ||
| string expectedLocation = Path.GetFullPath(Path.Combine(configuredDirectory, "System.Private.CoreLib.dll")); | ||
|
|
||
| StringComparison comparison = OperatingSystem.IsWindows() | ||
| ? StringComparison.OrdinalIgnoreCase | ||
| : StringComparison.Ordinal; | ||
|
|
||
| Assert.True( | ||
| string.Equals(spclLocation, expectedLocation, comparison), | ||
| $"SPCL should be loaded from '{expectedLocation}', but was loaded from '{spclLocation}'"); | ||
|
|
||
| string coreRoot = Environment.GetEnvironmentVariable("CORE_ROOT"); | ||
| if (!string.IsNullOrEmpty(coreRoot)) | ||
| { | ||
| string defaultPath = Path.Combine(coreRoot, "System.Private.CoreLib.dll"); | ||
| Assert.False( | ||
| string.Equals(spclLocation, Path.GetFullPath(defaultPath), comparison), | ||
| $"SPCL should not be loaded from the default location beside coreclr: '{defaultPath}'"); | ||
| } | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/tests/Loader/SystemCoreLibDirectory/SystemCoreLibDirectory.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,35 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <RequiresProcessIsolation>true</RequiresProcessIsolation> | ||
| <NativeAotIncompatible>true</NativeAotIncompatible> | ||
| <!-- This test exercises the CoreCLR system assembly binder --> | ||
| <CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="SystemCoreLibDirectory.cs" /> | ||
|
|
||
| <ProjectReference Include="$(TestLibraryProjectPath)" /> | ||
|
|
||
| <!-- Point the runtime at the Subdirectory created by the pre-commands below to look for | ||
| System.Private.CoreLib.dll. The %25cd%25 / $%28pwd) tokens expand at script execution | ||
| time to the test working directory. --> | ||
| <RuntimeHostConfigurationOption Include="SYSTEM_CORELIB_DIRECTORY" | ||
| Value="%25cd%25\Subdirectory" | ||
| Condition="'$(TestWrapperTargetsWindows)' == 'true'" /> | ||
| <RuntimeHostConfigurationOption Include="SYSTEM_CORELIB_DIRECTORY" | ||
| Value="$%28pwd)/Subdirectory" | ||
| Condition="'$(TestWrapperTargetsWindows)' != 'true'" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <CoreLibSetupBatch><![CDATA[ | ||
| mkdir Subdirectory | ||
| copy /Y "%CORE_ROOT%\System.Private.CoreLib.dll" "Subdirectory\" | ||
| ]]></CoreLibSetupBatch> | ||
| <CoreLibSetupBash><![CDATA[ | ||
| mkdir -p Subdirectory | ||
| cp "$CORE_ROOT/System.Private.CoreLib.dll" "Subdirectory/" | ||
| ]]></CoreLibSetupBash> | ||
| <CLRTestBatchPreCommands>$(CLRTestBatchPreCommands);$(CoreLibSetupBatch)</CLRTestBatchPreCommands> | ||
| <CLRTestBashPreCommands>$(CLRTestBashPreCommands);$(CoreLibSetupBash)</CLRTestBashPreCommands> | ||
| </PropertyGroup> | ||
| </Project> |
Oops, something went wrong.
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.