Skip to content

Commit be243d5

Browse files
Refactor source build tests to used common extracted sdk (#44568)
1 parent 3ec0aba commit be243d5

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/DotNetHelper.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ public DotNetHelper(ITestOutputHelper outputHelper)
3131

3232
lock (s_lockObj)
3333
{
34-
if (!Directory.Exists(Config.DotNetDirectory))
35-
{
36-
if (!File.Exists(Config.SdkTarballPath))
37-
{
38-
throw new InvalidOperationException($"Tarball path '{Config.SdkTarballPath}' specified in {Config.SdkTarballPath} does not exist.");
39-
}
40-
41-
Directory.CreateDirectory(Config.DotNetDirectory);
42-
Utilities.ExtractTarball(Config.SdkTarballPath, Config.DotNetDirectory, outputHelper);
43-
}
4434
IsMonoRuntime = DetermineIsMonoRuntime(Config.DotNetDirectory);
4535

4636
if (!Directory.Exists(ProjectsDirectory))

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/Microsoft.DotNet.SourceBuild.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<Value>$(ArtifactsTestResultsDir)</Value>
5353
</RuntimeHostConfigurationOption>
5454
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).DotNetDirectory">
55-
<Value>$(TargetDir)extracted-sdk</Value>
55+
<Value>$(DotNetSdkExtractDir)</Value>
5656
</RuntimeHostConfigurationOption>
5757
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).TargetRid">
5858
<Value>$(TargetRid)</Value>

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.Tests/SourceBuiltArtifactsTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.DotNet.SourceBuild.Tests;
1717
public class SourceBuiltArtifactsTests : SdkTests
1818
{
1919
public static bool IncludeSourceBuiltArtifactsTests => !string.IsNullOrWhiteSpace(Config.SourceBuiltArtifactsPath);
20-
20+
2121
public SourceBuiltArtifactsTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
2222

2323
[ConditionalFact(typeof(SourceBuiltArtifactsTests), nameof(IncludeSourceBuiltArtifactsTests))]
@@ -55,9 +55,8 @@ public void VerifyVersionFile()
5555

5656
string sdkVersion = versionLines[1];
5757

58-
// Find the expected SDK version by getting it from the SDK tarball
59-
Utilities.ExtractTarball(Config.SdkTarballPath ?? string.Empty, outputDir, "./sdk/*/.version");
60-
DirectoryInfo sdkDir = new DirectoryInfo(Path.Combine(outputDir, "sdk"));
58+
// Find the expected SDK version by getting it from the source built SDK
59+
DirectoryInfo sdkDir = new DirectoryInfo(Path.Combine(Config.DotNetDirectory, "sdk"));
6160
string sdkVersionPath = sdkDir.GetFiles(".version", SearchOption.AllDirectories).Single().FullName;
6261
string[] sdkVersionLines = File.ReadAllLines(Path.Combine(outputDir, sdkVersionPath));
6362
string expectedSdkVersion = sdkVersionLines[3]; // Get the unique, non-stable, SDK version

0 commit comments

Comments
 (0)