Skip to content

Commit

Permalink
Refactor source build tests to used common extracted sdk (#44568)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSimons authored Nov 1, 2024
1 parent 3ec0aba commit be243d5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ public DotNetHelper(ITestOutputHelper outputHelper)

lock (s_lockObj)
{
if (!Directory.Exists(Config.DotNetDirectory))
{
if (!File.Exists(Config.SdkTarballPath))
{
throw new InvalidOperationException($"Tarball path '{Config.SdkTarballPath}' specified in {Config.SdkTarballPath} does not exist.");
}

Directory.CreateDirectory(Config.DotNetDirectory);
Utilities.ExtractTarball(Config.SdkTarballPath, Config.DotNetDirectory, outputHelper);
}
IsMonoRuntime = DetermineIsMonoRuntime(Config.DotNetDirectory);

if (!Directory.Exists(ProjectsDirectory))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<Value>$(ArtifactsTestResultsDir)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).DotNetDirectory">
<Value>$(TargetDir)extracted-sdk</Value>
<Value>$(DotNetSdkExtractDir)</Value>
</RuntimeHostConfigurationOption>
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).TargetRid">
<Value>$(TargetRid)</Value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.DotNet.SourceBuild.Tests;
public class SourceBuiltArtifactsTests : SdkTests
{
public static bool IncludeSourceBuiltArtifactsTests => !string.IsNullOrWhiteSpace(Config.SourceBuiltArtifactsPath);

public SourceBuiltArtifactsTests(ITestOutputHelper outputHelper) : base(outputHelper) { }

[ConditionalFact(typeof(SourceBuiltArtifactsTests), nameof(IncludeSourceBuiltArtifactsTests))]
Expand Down Expand Up @@ -55,9 +55,8 @@ public void VerifyVersionFile()

string sdkVersion = versionLines[1];

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

0 comments on commit be243d5

Please sign in to comment.