Skip to content

Commit

Permalink
Remove RIDS in CompareMsftToSbAssemblyVersions test (#42022)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellahathaway authored Jul 9, 2024
1 parent c7dbe99 commit 09935d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ internal class BaselineHelper
private const string SemanticVersionPlaceholderMatchingPattern = "*.*.*"; // wildcard pattern used to match on the version represented by the placeholder
private const string NonSemanticVersionPlaceholder = "x.y";
private const string NonSemanticVersionPlaceholderMatchingPattern = "*.*"; // wildcard pattern used to match on the version represented by the placeholder
private const string TargetRidPlaceholder = "banana-rid";
private const string TargetRidPlaceholderMatchingPattern = "*-*"; // wildcard pattern used to match on the rid represented by the placeholder
private const string PortableRidPlaceholder = "portable-rid";
private const string PortableRidPlaceholderMatchingPattern = "*-*"; // wildcard pattern used to match on the rid represented by the placeholder

public static void CompareEntries(string baselineFileName, IOrderedEnumerable<string> actualEntries)
{
Expand Down Expand Up @@ -91,7 +95,7 @@ public static string GetBaselineFilePath(string baselineFileName, string baselin
Path.Combine(GetAssetsDirectory(), baselineSubDir, baselineFileName);

public static string RemoveRids(string diff, bool isPortable = false) =>
isPortable ? diff.Replace(Config.PortableRid, "portable-rid") : diff.Replace(Config.TargetRid, "banana-rid");
isPortable ? diff.Replace(Config.PortableRid, PortableRidPlaceholder) : diff.Replace(Config.TargetRid, TargetRidPlaceholder);

public static string RemoveVersions(string source)
{
Expand Down Expand Up @@ -119,14 +123,16 @@ public static string RemoveVersions(string source)
}

/// <summary>
/// This returns a <see cref="Matcher"/> that can be used to match on a path whose versions have been removed via
/// <see cref="RemoveVersions(string)"/>.
/// This returns a <see cref="Matcher"/> that can be used to match on a path whose versions and RID have been removed via
/// <see cref="RemoveVersions(string)"/> and <see cref="RemoveRids(string, bool)"/>
/// </summary>
public static Matcher GetFileMatcherFromPath(string path)
{
path = path
.Replace(SemanticVersionPlaceholder, SemanticVersionPlaceholderMatchingPattern)
.Replace(NonSemanticVersionPlaceholder, NonSemanticVersionPlaceholderMatchingPattern);
.Replace(NonSemanticVersionPlaceholder, NonSemanticVersionPlaceholderMatchingPattern)
.Replace(TargetRidPlaceholder, TargetRidPlaceholderMatchingPattern)
.Replace(PortableRidPlaceholder, PortableRidPlaceholderMatchingPattern);
Matcher matcher = new();
matcher.AddInclude(path);
return matcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ private string FindMatchingFilePath(string rootDir, Matcher matcher, string repr
{
AssemblyName assemblyName = AssemblyName.GetAssemblyName(file);
string relativePath = Path.GetRelativePath(sbSdkPath, file);
string normalizedPath = BaselineHelper.RemoveVersions(relativePath);
string normalizedPath = BaselineHelper.RemoveRids(relativePath, isPortable: false);
normalizedPath = BaselineHelper.RemoveVersions(normalizedPath);

if(!exclusionsHelper.IsFileExcluded(normalizedPath, SourceBuildSdkType))
{
Expand Down

0 comments on commit 09935d7

Please sign in to comment.