Skip to content

Commit 46834a0

Browse files
author
Konrad Jamrozik
authored
Use CodeownersFile.UseRegexMatcherDefault everywhere where applicable + remove obsolete tests (#5437)
This is a follow-up PR to: - #5241 That PR was supposed to enable the regex-based matcher everywhere, but didn't. This PR fixes that. This PR also: - removes the obsolete `ProgramSimplePathTests` test class; it is superseded by `ProgramGlobPathTests`, which is renamed in: - #5431 - removes obsolete tests from `get-codeowners.ps1` This PR is a prerequisite for following PRs: - #5103 - #5431
1 parent 5d9dc06 commit 46834a0

4 files changed

Lines changed: 16 additions & 74 deletions

File tree

eng/common/scripts/get-codeowners.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@ function TestGetCodeOwner([string]$targetDirectory, [string]$codeOwnerFileLocati
8181
}
8282

8383
if($Test) {
84-
$testFile = (Resolve-Path $PSScriptRoot/../../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/simple_path_CODEOWNERS)
85-
TestGetCodeOwner -targetDirectory "sdk" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
86-
TestGetCodeOwner -targetDirectory "sdk/noPath" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
87-
TestGetCodeOwner -targetDirectory "/sdk/azconfig" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person3", "person4")
88-
TestGetCodeOwner -targetDirectory "/sdk/azconfig/package" -codeOwnerFileLocation $testFile -includeNonUserAliases $true $testFile -expectReturn @("person3", "person4")
89-
TestGetCodeOwner -targetDirectory "/sd" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @()
90-
TestGetCodeOwner -targetDirectory "/sdk/testUser/" -codeOwnerFileLocation $testFile -expectReturn @("azure-sdk")
84+
# These tests have been removed; now instead we should run tests from RetrieveCodeOwnersProgramTests, and in a way as explained in:
85+
# https://github.com/Azure/azure-sdk-tools/issues/5434
86+
# https://github.com/Azure/azure-sdk-tools/pull/5103#discussion_r1068680818
87+
Write-Host "These tests have been removed. Please see https://github.com/Azure/azure-sdk-tools/issues/5434 for more."
88+
#
89+
# $testFile = (Resolve-Path $PSScriptRoot/../../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/simple_path_CODEOWNERS)
90+
# TestGetCodeOwner -targetDirectory "sdk" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
91+
# TestGetCodeOwner -targetDirectory "sdk/noPath" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
92+
# TestGetCodeOwner -targetDirectory "/sdk/azconfig" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person3", "person4")
93+
# TestGetCodeOwner -targetDirectory "/sdk/azconfig/package" -codeOwnerFileLocation $testFile -includeNonUserAliases $true $testFile -expectReturn @("person3", "person4")
94+
# TestGetCodeOwner -targetDirectory "/sd" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @()
95+
# TestGetCodeOwner -targetDirectory "/sdk/testUser/" -codeOwnerFileLocation $testFile -expectReturn @("azure-sdk")
9196
exit 0
9297
}
9398
else {

tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/ProgramSimplePathTests.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static int Main(
5353
bool excludeNonUserAliases = false,
5454
string? targetDir = null,
5555
string ignoredPathPrefixes = DefaultIgnoredPrefixes,
56-
bool useRegexMatcher = false)
56+
bool useRegexMatcher = CodeownersFile.UseRegexMatcherDefault)
5757
{
5858
try
5959
{
@@ -109,7 +109,7 @@ private static Dictionary<string, CodeownersEntry> GetCodeownersForGlobPath(
109109
string codeownersFilePathOrUrl,
110110
bool excludeNonUserAliases,
111111
string[]? ignoredPathPrefixes = null,
112-
bool useRegexMatcher = false)
112+
bool useRegexMatcher = CodeownersFile.UseRegexMatcherDefault)
113113
{
114114
ignoredPathPrefixes ??= Array.Empty<string>();
115115

@@ -131,7 +131,7 @@ private static CodeownersEntry GetCodeownersForSimplePath(
131131
string targetPath,
132132
string codeownersFilePathOrUrl,
133133
bool excludeNonUserAliases,
134-
bool useRegexMatcher = false)
134+
bool useRegexMatcher = CodeownersFile.UseRegexMatcherDefault)
135135
{
136136
CodeownersEntry codeownersEntry =
137137
CodeownersFile.GetMatchingCodeownersEntry(

tools/code-owners-parser/CodeOwnersParser/CodeownersFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Azure.Sdk.Tools.CodeOwnersParser
88
{
99
public static class CodeownersFile
1010
{
11-
private const bool UseRegexMatcherDefault = true;
11+
public const bool UseRegexMatcherDefault = true;
1212

1313
public static List<CodeownersEntry> GetCodeownersEntriesFromFileOrUrl(
1414
string codeownersFilePathOrUrl)

0 commit comments

Comments
 (0)