
* Update .vsts-ci.yml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220205.1 (#13179) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Override Microsoft.Net.Sdk.WindowsDesktop references during source-build in Roslyn (#13093) * override SDK for Microsoft.Net.Sdk.WindowsDesktop references in roslyn * add new EmptySdk in the source build tarball * remove roslyn solution filter patch * Update dependencies from https://github.com/dotnet/arcade build 20220207.2 (#13186) Microsoft.DotNet.CMake.Sdk , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.22102.3 -> To Version 6.0.0-beta.22107.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/6.0.1xx] Windows SDK projection update * Update asp.net templates (#13193) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220210.1 (#13215) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Add test to compare msft and sb sdk contents (#13153) * Update to SDK and previously-source-built 6.0.102. (#13221) * Add CentOS Stream 9 container to CI matrix (#12955) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220215.1 (#13229) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Gather additional smoke test prereqs (#13233) * Remove bootstrapping for CI builds now that we use CentOS7 previously-source-built (#13232) * Update Version.Details.xml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220303.2 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 6.0.0-servicing.22151.1 -> To Version 6.0.0-servicing.22153.2 Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Logan Bussell <loganbussell@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Sean Reeser <v-seanreeser@microsoft.com> Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com> Co-authored-by: William Godbe <wigodbe@microsoft.com> Co-authored-by: vseanreesermsft <78103370+vseanreesermsft@users.noreply.github.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: Chris Rummel <crummel@microsoft.com> Co-authored-by: Omair Majid <omajid@redhat.com>
92 lines
4 KiB
C#
92 lines
4 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text.RegularExpressions;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
|
|
|
public class SdkContentTests
|
|
{
|
|
private ITestOutputHelper OutputHelper { get; }
|
|
private DotNetHelper DotNetHelper { get; }
|
|
|
|
public SdkContentTests(ITestOutputHelper outputHelper)
|
|
{
|
|
OutputHelper = outputHelper;
|
|
DotNetHelper = new DotNetHelper(outputHelper);
|
|
}
|
|
|
|
/// <Summary>
|
|
/// Verifies the file layout of the source built sdk tarball to the Microsoft build.
|
|
/// The differences are captured in baselines/MsftToSbSdkDiff.txt.
|
|
/// Version numbers that appear in paths are compared but are stripped from the baseline.
|
|
/// This makes the baseline durable between releases. This does mean however, entries
|
|
/// in the baseline may appear identical if the diff is version specific.
|
|
/// </Summary>
|
|
[Fact]
|
|
public void CompareMsftToSb()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(Config.MsftSdkTarballPath))
|
|
{
|
|
OutputHelper.WriteLine($"skipping {nameof(CompareMsftToSb)} because {Config.MsftSdkTarballPathEnv} was not specified.");
|
|
return;
|
|
}
|
|
|
|
if (!File.Exists(Config.MsftSdkTarballPath))
|
|
{
|
|
throw new InvalidOperationException($"Tarball path '{Config.MsftSdkTarballPath}' specified in {Config.MsftSdkTarballPathEnv} does not exist.");
|
|
}
|
|
|
|
const string msftFileListingFileName = "msftSdkFiles.txt";
|
|
const string sbFileListingFileName = "sbSdkFiles.txt";
|
|
WriteTarballFileList(Config.MsftSdkTarballPath, msftFileListingFileName);
|
|
WriteTarballFileList(Config.DotNetTarballPath, sbFileListingFileName);
|
|
|
|
string diff = BaselineHelper.DiffFiles(msftFileListingFileName, sbFileListingFileName, OutputHelper);
|
|
diff = RemoveVersionedPaths(diff);
|
|
diff = RemoveDiffMarkers(diff);
|
|
diff = RemoveRids(diff);
|
|
BaselineHelper.Compare("MsftToSbSdk.diff", diff, OutputHelper);
|
|
}
|
|
|
|
private void WriteTarballFileList(string tarballPath, string outputFileName)
|
|
{
|
|
string fileListing = ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"tf {tarballPath}", OutputHelper);
|
|
IEnumerable<string> files = fileListing.Split(Environment.NewLine).OrderBy(path => path);
|
|
File.WriteAllLines(outputFileName, files);
|
|
}
|
|
|
|
private static string RemoveDiffMarkers(string source)
|
|
{
|
|
Regex indexRegex = new("^index .*", RegexOptions.Multiline);
|
|
string result = indexRegex.Replace(source, "index ------------");
|
|
|
|
Regex diffSegmentRegex = new("^@@ .* @@", RegexOptions.Multiline);
|
|
return diffSegmentRegex.Replace(result, "@@ ------------ @@");
|
|
}
|
|
|
|
private string RemoveRids(string diff) => diff.Replace(Config.TargetRid, "bannana.rid");
|
|
|
|
private static string RemoveVersionedPaths(string source)
|
|
{
|
|
// Remove semantic version path segments
|
|
string pathSeparator = Regex.Escape(Path.DirectorySeparatorChar.ToString());
|
|
// Regex source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
|
|
Regex semanticVersionRegex = new(
|
|
$"{pathSeparator}(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)"
|
|
+ $"(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))"
|
|
+ $"?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?{pathSeparator}");
|
|
string result = semanticVersionRegex.Replace(source, $"{Path.DirectorySeparatorChar}x.y.z{Path.DirectorySeparatorChar}");
|
|
|
|
// Remove net.x.y path segments
|
|
Regex netTfmRegex = new($"{pathSeparator}net[1-9]*.[0-9]{pathSeparator}");
|
|
return netTfmRegex.Replace(result, $"{Path.DirectorySeparatorChar}netx.y{Path.DirectorySeparatorChar}");
|
|
}
|
|
}
|