[release/7.0.1xx] SDK diff exclusions - backport (#15670)

This commit is contained in:
Nikola Milosavljevic 2023-03-01 09:05:57 -08:00 committed by GitHub
parent df0fc12896
commit c964d85026
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 1157 deletions

View file

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Enumeration;
using System.Linq;
using System.Text.RegularExpressions;
using Xunit.Abstractions;
@ -27,15 +28,15 @@ public class SdkContentTests : SmokeTests
{
const string msftFileListingFileName = "msftSdkFiles.txt";
const string sbFileListingFileName = "sbSdkFiles.txt";
WriteTarballFileList(Config.MsftSdkTarballPath, msftFileListingFileName, isPortable: true);
WriteTarballFileList(Config.SdkTarballPath, sbFileListingFileName, isPortable: false);
WriteTarballFileList(Config.MsftSdkTarballPath, msftFileListingFileName, isPortable: true, "msft");
WriteTarballFileList(Config.SdkTarballPath, sbFileListingFileName, isPortable: false, "sb");
string diff = BaselineHelper.DiffFiles(msftFileListingFileName, sbFileListingFileName, OutputHelper);
diff = RemoveDiffMarkers(diff);
BaselineHelper.CompareContents("MsftToSbSdk.diff", diff, OutputHelper, Config.WarnOnSdkContentDiffs);
}
private void WriteTarballFileList(string? tarballPath, string outputFileName, bool isPortable)
private void WriteTarballFileList(string? tarballPath, string outputFileName, bool isPortable, string sdkType)
{
if (!File.Exists(tarballPath))
{
@ -46,10 +47,32 @@ public class SdkContentTests : SmokeTests
fileListing = BaselineHelper.RemoveRids(fileListing, isPortable);
fileListing = BaselineHelper.RemoveVersions(fileListing);
IEnumerable<string> files = fileListing.Split(Environment.NewLine).OrderBy(path => path);
files = RemoveExclusions(
files,
GetExclusionFilters(
Path.Combine(BaselineHelper.GetAssetsDirectory(), "SdkDiffExclusions.txt"),
sdkType));
File.WriteAllLines(outputFileName, files);
}
private static IEnumerable<string> RemoveExclusions(IEnumerable<string> files, IEnumerable<string> exclusions) =>
files.Where(item => !exclusions.Any(p => FileSystemName.MatchesSimpleExpression(p, item)));
private static IEnumerable<string> GetExclusionFilters(string exclusionsFilePath, string sdkType)
{
int prefixSkip = sdkType.Length + 1;
return File.ReadAllLines(exclusionsFilePath)
.Where(line => line.StartsWith(sdkType + ",")) // process only specific sdk exclusions
.Select(line =>
{
// Ignore comments
var index = line.IndexOf('#');
return index >= 0 ? line[prefixSkip..index].TrimEnd() : line[prefixSkip..];
})
.ToList();
}
private static string RemoveDiffMarkers(string source)
{
Regex indexRegex = new("^index .*", RegexOptions.Multiline);

View file

@ -0,0 +1,34 @@
# This list is processed using FileSystemName.MatchesSimpleExpression
#
# Format
# {msft|sb},<path> [# comment]
# msft = Microsoft built SDK
# sb = source-built SDK
#
# Examples
# 'folder/*' matches 'folder/' and 'folder/abc'
# 'folder/?*' matches 'folder/abc' but not 'folder/'
#
# We do not want to filter-out folder entries, therefore, we should use: '?*' and not just '*'
msft,./sdk/x.y.z/TestHostNetFramework/?* # Intentional - MSFT build includes test-host that targets netcoreapp3.1
msft,./sdk/x.y.z/Sdks/Microsoft.NET.Sdk.Publish/tools/net472/?* # Intentional - source-build includes SDK Publishing package that target latest .NET TFM
msft,./sdk/x.y.z/Sdks/Microsoft.NET.Sdk.WindowsDesktop/?* # Intentional - explicitly excluded from source-build
sb,./sdk/x.y.z/TestHost/?* # Intentional - source-build includes test-host that targets latest .NET TFM
# vstest localization is disabled in Linux builds - https://github.com/microsoft/vstest/issues/4305
msft,./sdk/x.y.z/*?/Microsoft.CodeCoverage.IO.resources.dll
msft,./sdk/x.y.z/*?/Microsoft.TestPlatform.*?.resources.dll
msft,./sdk/x.y.z/*?/Microsoft.VisualStudio.TestPlatform.*?.resources.dll
msft,./sdk/x.y.z/*?/Test.Utility.resources.dll
msft,./sdk/x.y.z/*?/vstest.console.resources.dll
msft,./sdk/x.y.z/Extensions/*?/Microsoft.TestPlatform.*?.resources.dll
msft,./sdk/x.y.z/Extensions/*?/Microsoft.VisualStudio.TestPlatform.*?.resources.dll
# nuget localization is not available for Linux builds - https://github.com/NuGet/Home/issues/12440
msft,./sdk/x.y.z/*?/NuGet.*?.resources.dll
msft,./sdk/x.y.z/*?/Microsoft.Build.NuGetSdkResolver.resources.dll
# ILMerge is not supported in Linux builds - excluding the whole NuGet.Build.Tasks.Pack directory, to avoid a noisy diff
msft,./sdk/x.y.z/Sdks/NuGet.Build.Tasks.Pack/*?
sb,./sdk/x.y.z/Sdks/NuGet.Build.Tasks.Pack/*?