Skip to content

Commit

Permalink
Address changes requested by sci, and use extension method instead of…
Browse files Browse the repository at this point in the history
… property
  • Loading branch information
marchermans committed May 31, 2024
1 parent 03a8ab0 commit a305b4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions .github/gradle/gradle.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ if (!project.hasProperty('githubCiTesting') && System.env['GITHUB_OUTPUT'] == nu

static Map<String, String> removeCommonPrefix(List<String> list) {
if (list.size() == 0) {
return new HashMap<String, String>()
return [:]
}

def result = new HashMap<String, String>()

if (list.size() == 1) {
System.out.println("Only one item in the list: ${list}")
if (list.unique(false).size() == 1) {
def sections = list[0].split("\\.")
result.put(list[0], sections.last())
return result
Expand All @@ -23,21 +22,27 @@ static Map<String, String> removeCommonPrefix(List<String> list) {
Collections.sort(list, { String a, String b -> a.length() - b.length() })
def max = list[0].length()
def prefix = ""

comparisonLoop:
for(int index = 0; index < max; index++) {
def currentChar = list[0][index]
for (String item : list) {
if (item[index] != currentChar) {
for (final def entry in list) {
result.put(entry, entry.substring(prefix.length()))
}
return result
break comparisonLoop
}
}

prefix += currentChar
}

throw new RuntimeException("Could not remove common prefix: ${list}")
if (prefix.length() == max) {
throw new IllegalArgumentException("The common prefix is the entire string")
}

for (final def entry in list) {
result.put(entry, entry.substring(prefix.length()))
}
return result
}

static String createDisplayNameSuffix(String path, String filter) {
Expand All @@ -64,7 +69,7 @@ static String createDisplayNameSuffix(String path, String filter) {
}

static List<TestRun> createTestRuns(Task it, List<String> testClasses) {
def testRuns = new ArrayList<TestRun>()
def testRuns = []
if (testClasses.size() == 0) {
testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, null)}", path: it.path, filter: null))
return testRuns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RuntimeBuilderExtensions {
*/
static File withGlobalCacheDirectory(final Runtime.Builder self, final File testProjectDir) {
final File cacheDir = new File(testProjectDir, ".ng-cache")
self.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, cacheDir.propertiesPath)
self.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, cacheDir.getPropertiesPath())

return cacheDir
}
Expand Down

0 comments on commit a305b4b

Please sign in to comment.