From 10bb25a3f90510b0e77e792009719ccd8111ee36 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 17:42:24 +0200 Subject: [PATCH 01/28] Improve test build, run on multiple OS instances (Linux, Windows, Mac), and handle build failures properly so that auto merging is handled better. --- .github/workflows/test-prs.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 4e7afb9a3..8bf369d54 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -63,12 +63,13 @@ jobs: test: name: Test - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} needs: setup strategy: fail-fast: false matrix: test: ${{ fromJSON(needs.setup.outputs.tests-to-run) }} + os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -94,21 +95,22 @@ jobs: run: npx junit-report-merger junit.xml "**/TEST-*.xml" - name: Format test run name as artifact name + if: success() || failure() id: format-artifact-name # Use the GITHUB_OUTPUT mechanic to set the output variable run: | # We have two cases here, one with a gradle task path, there we replace the : with a - and strip the leading - # The other case is complexer, again we replace the : with a - and strip the leading - but now we also remove the ' --tests ' part # Remove the '"' from the string and replace the '.' with a '-' - NAME=$(echo "${{ matrix.test }}" | sed 's/:/-/g' | sed 's/^-//' | sed 's/ --tests /-/g' | sed 's/"//g' | sed 's/\./-/g') + NAME=$(echo "${{ matrix.test }}" | sed 's/:/-/g' | sed 's/^-//' | sed 's/ --tests /-/g' | sed 's/"//g' | sed 's/\./-/g') + OS_NAME=$(echo "${{ runner.os }}" | sed 's/-latest//g') # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command echo "::set-output name=artifact-name::$NAME" exit 0 fi - echo "artifact-name=$NAME" >> "$GITHUB_OUTPUT" - + echo "artifact-name=$NAME-$OS_NAME" >> "$GITHUB_OUTPUT" - uses: actions/upload-artifact@v4 if: success() || failure() @@ -146,3 +148,11 @@ jobs: with: name: test-results path: junit.xml + + - name: Failed build detection + if: failure() + uses: actions/github-script@v7 + with: + script: | + core.setFailed('Test build failure!') + From b26513a435d9021fcb513730ea98d5a29fb062be Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 17:43:28 +0200 Subject: [PATCH 02/28] Cleanup naming. --- .github/workflows/test-prs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 8bf369d54..b9be0daa4 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -121,6 +121,7 @@ jobs: retention-days: 1 process-test-data: + name: Process Test Data runs-on: ubuntu-latest needs: test if: success() || failure() From 10c8a8c1f3f5c38784b96c3aef63b00b2e0170e0 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 18:44:50 +0200 Subject: [PATCH 03/28] Improve testing setup and fix compile error --- .github/gradle/gradle.gradle | 119 +++++++++++++++++++++++++++---- .github/scripts/collect-tests.sh | 3 +- .github/workflows/test-prs.yml | 9 ++- gradle.properties | 2 + 4 files changed, 114 insertions(+), 19 deletions(-) diff --git a/.github/gradle/gradle.gradle b/.github/gradle/gradle.gradle index d665ffd71..bb2f3dd2a 100644 --- a/.github/gradle/gradle.gradle +++ b/.github/gradle/gradle.gradle @@ -1,18 +1,106 @@ +import groovy.json.JsonBuilder +import groovy.transform.CompileStatic + if (!project.hasProperty('githubCiTesting') && System.env['GITHUB_OUTPUT'] == null) { // If the property is not set and we are not running in the CI environment then we will do nothing return } -static def outputUnitTest(Project project, Task test) { - project.getLogger().lifecycle("<< TEST >>${test.path}") +static Map removeCommonPrefix(List list) { + if (list.size() == 0) { + return new HashMap() + } + + def result = new HashMap() + + if (list.size() == 1) { + System.out.println("Only one item in the list: ${list}") + def sections = list[0].split("\\.") + result.put(list[0], sections.last()) + return result + } + + Collections.sort(list, { String a, String b -> a.length() - b.length() }) + def max = list[0].length() + def prefix = "" + 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 + } + } + + prefix += currentChar + } + + throw new RuntimeException("Could not remove common prefix: ${list}") +} + +static String createDisplayNameSuffix(String path, String filter) { + //The path starts with a : and then the project name: + path = path.substring(path.indexOf(":") + 1) + + //Now split the path into parts + def parts = path.split(":") + def capitalizedParts = parts.collect { it.capitalize() } + + //Combine the parts with -> + path = capitalizedParts.join(" -> ") + + if (filter === null) { + return path + } + + //Next the filter has its common prefix stripped, is however still in domain name form + def filterParts = filter.split("\\.") + def capitalizedFilterParts = filterParts.collect { it.capitalize() } + filter = capitalizedFilterParts.join("/") + + return "${path} (${filter})" +} + +static List createTestRuns(Task it, List testClasses) { + def testRuns = new ArrayList() + if (testClasses.size() == 0) { + testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, null)}", path: it.path, filter: null)) + return testRuns + } + + def testClassesWithoutCommonPrefix = removeCommonPrefix(testClasses) + testClassesWithoutCommonPrefix.forEach { className, displayName -> + testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, displayName)}", path: it.path, filter: className)) + } + + return testRuns } -static def outputClassTest(Project project, Task test, String className) { - project.getLogger().lifecycle("<< TEST >>${test.path} --tests \"${className}\"") +@CompileStatic +class TestRun { + String displayName + String path + String filter + + String getDisplayName() { + return displayName + } + + String getPath() { + return path + } + + String getFilter() { + return filter + } } subprojects.forEach { Project subProject -> subProject.tasks.register('determineTests') { Task it -> + def tests = new ArrayList() + it.group = 'infrastructure' it.doLast { subProject.tasks.withType(Test).forEach { Task test -> @@ -20,22 +108,24 @@ subprojects.forEach { Project subProject -> if (testSourceSetCandidate != null) { SourceSet testSourceSet = testSourceSetCandidate as SourceSet + def testClasses = new ArrayList() + testSourceSet.java.srcDirs .collect { File file -> subProject.fileTree(file.parentFile) } .collect { FileTree fileTree -> - return fileTree.matching { - include '**/*Test.java' - include '**/*Tests.java' - include '**/*Test.groovy' - include '**/*Tests.groovy' + return fileTree.matching { PatternFilterable pattern -> + pattern.include '**/*Test.java' + pattern.include '**/*Tests.java' + pattern.include '**/*Test.groovy' + pattern.include '**/*Tests.groovy' } } .forEach { it.visit { FileVisitDetails details -> if (details.isDirectory()) - return; + return String className = details.relativePath.pathString .replace("groovy/", "") @@ -44,14 +134,19 @@ subprojects.forEach { Project subProject -> .replace(".java", "") .replace("/", ".") - outputClassTest(subProject, test, className) + testClasses.add(className) } } + tests.addAll(createTestRuns(test, testClasses)) } else { - outputUnitTest(subProject, test) + tests.addAll(createTestRuns(test, new ArrayList())) } } + + if (!tests.isEmpty()) { + project.getLogger().lifecycle("<< TEST >>${new JsonBuilder(tests)}") + } } } } diff --git a/.github/scripts/collect-tests.sh b/.github/scripts/collect-tests.sh index 88367d47c..f4469bd43 100755 --- a/.github/scripts/collect-tests.sh +++ b/.github/scripts/collect-tests.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -./gradlew determineTests | grep -e '<< TEST >>' | sed -e 's/<< TEST >>//g' > ./tasks -TESTS=$(cat tasks | jq --raw-input . | jq --compact-output --slurp .) +TESTS=$(./gradlew determineTests | grep -e '<< TEST >>' | sed -e 's/<< TEST >>//g' | jq -s 'add') # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index b9be0daa4..16c68664a 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -62,14 +62,14 @@ jobs: run: ./gradlew --info -s -x assemble test: - name: Test - runs-on: ${{ matrix.os }} + name: "${{ matrix.test }} (${{ matrix.os }})" + runs-on: "${{ matrix.os }}-latest" needs: setup strategy: fail-fast: false matrix: test: ${{ fromJSON(needs.setup.outputs.tests-to-run) }} - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu, windows, macos] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -103,14 +103,13 @@ jobs: # The other case is complexer, again we replace the : with a - and strip the leading - but now we also remove the ' --tests ' part # Remove the '"' from the string and replace the '.' with a '-' NAME=$(echo "${{ matrix.test }}" | sed 's/:/-/g' | sed 's/^-//' | sed 's/ --tests /-/g' | sed 's/"//g' | sed 's/\./-/g') - OS_NAME=$(echo "${{ runner.os }}" | sed 's/-latest//g') # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command echo "::set-output name=artifact-name::$NAME" exit 0 fi - echo "artifact-name=$NAME-$OS_NAME" >> "$GITHUB_OUTPUT" + echo "artifact-name=$NAME-${{ matrix.os }}" >> "$GITHUB_OUTPUT" - uses: actions/upload-artifact@v4 if: success() || failure() diff --git a/gradle.properties b/gradle.properties index 743dd54cf..cc8c87618 100644 --- a/gradle.properties +++ b/gradle.properties @@ -37,3 +37,5 @@ spock_groovy_version=3.0 mockito_version=4.11.0 jimfs_version=1.2 trainingwheels_version=1.0.46 + +githubCiTesting=true \ No newline at end of file From 3719ffc55555c264c5569bb24d880c21af40c7d9 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 18:47:58 +0200 Subject: [PATCH 04/28] No pretty print --- .github/scripts/collect-tests.sh | 2 +- gradle.properties | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/scripts/collect-tests.sh b/.github/scripts/collect-tests.sh index f4469bd43..1f5be0a32 100755 --- a/.github/scripts/collect-tests.sh +++ b/.github/scripts/collect-tests.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -TESTS=$(./gradlew determineTests | grep -e '<< TEST >>' | sed -e 's/<< TEST >>//g' | jq -s 'add') +TESTS=$(./gradlew determineTests | grep -e '<< TEST >>' | sed -e 's/<< TEST >>//g' | jq -s 'add' | jq -c .) # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command diff --git a/gradle.properties b/gradle.properties index cc8c87618..5f5504818 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,6 +36,4 @@ spock_version=2.1 spock_groovy_version=3.0 mockito_version=4.11.0 jimfs_version=1.2 -trainingwheels_version=1.0.46 - -githubCiTesting=true \ No newline at end of file +trainingwheels_version=1.0.46 \ No newline at end of file From ca5907b97a62d63ba6cdccb81c241e646bc7b106 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 18:53:58 +0200 Subject: [PATCH 05/28] Fix test object access --- .github/workflows/test-prs.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 16c68664a..0c656bd93 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -62,7 +62,7 @@ jobs: run: ./gradlew --info -s -x assemble test: - name: "${{ matrix.test }} (${{ matrix.os }})" + name: "${{ matrix.test.displayName }} (${{ matrix.os }})" runs-on: "${{ matrix.os }}-latest" needs: setup strategy: @@ -84,10 +84,15 @@ jobs: distribution: 'microsoft' - name: Setup Gradle - uses: gradle/gradle-build-action@v3 + uses: gradle/actions/setup-gradle@v3 + + - name: Test + if: ${{ matrix.test.filter != null }} + run: ./gradlew --info -s ${{ matrix.test.path }} --tests "${{ matrix.test.filter }}" - name: Test - run: ./gradlew --info -s ${{ matrix.test }} + if: ${{ matrix.test.filter == null }} + run: ./gradlew --info -s ${{ matrix.test.path }} # Always upload test results - name: Merge Test Reports From 6c00d108c1c6b5a07dbd1a9d8c19cfa966cf2c11 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 18:54:41 +0200 Subject: [PATCH 06/28] Fix the test output --- .github/workflows/test-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 0c656bd93..2b3d4ac31 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -107,7 +107,7 @@ jobs: # We have two cases here, one with a gradle task path, there we replace the : with a - and strip the leading - # The other case is complexer, again we replace the : with a - and strip the leading - but now we also remove the ' --tests ' part # Remove the '"' from the string and replace the '.' with a '-' - NAME=$(echo "${{ matrix.test }}" | sed 's/:/-/g' | sed 's/^-//' | sed 's/ --tests /-/g' | sed 's/"//g' | sed 's/\./-/g') + NAME=$(echo "${{ matrix.test.displayName }}" | sed 's/:/-/g' | sed 's/^-//' | sed 's/ --tests /-/g' | sed 's/"//g' | sed 's/\./-/g') # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command From 243e682687a4e13a1373d5c1a3b3ffc72b0a0fc5 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 19:04:33 +0200 Subject: [PATCH 07/28] Fix test case naming --- .github/workflows/test-prs.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 2b3d4ac31..c07ad5cf7 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -104,10 +104,9 @@ jobs: id: format-artifact-name # Use the GITHUB_OUTPUT mechanic to set the output variable run: | - # We have two cases here, one with a gradle task path, there we replace the : with a - and strip the leading - - # The other case is complexer, again we replace the : with a - and strip the leading - but now we also remove the ' --tests ' part - # Remove the '"' from the string and replace the '.' with a '-' - NAME=$(echo "${{ matrix.test.displayName }}" | sed 's/:/-/g' | sed 's/^-//' | sed 's/ --tests /-/g' | sed 's/"//g' | sed 's/\./-/g') + # We need to remove all invalid characters from the test name: + # Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n, Backslash \, Forward slash / + NAME=$(echo "${{ matrix.test.displayName }}" | tr '":<>|*?\\/' '-' | tr -d ' ') # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command From c21d6b5893ce1ff9e5582c2e66b29d310b70fa40 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 19:22:33 +0200 Subject: [PATCH 08/28] Add windows support --- .github/workflows/test-prs.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index c07ad5cf7..9e2807dd8 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -100,7 +100,24 @@ jobs: run: npx junit-report-merger junit.xml "**/TEST-*.xml" - name: Format test run name as artifact name - if: success() || failure() + if: (success() || failure()) && runner.os == 'Windows' + id: format-artifact-name + # Use the GITHUB_OUTPUT mechanic to set the output variable + run: | + # We need to remove all invalid characters from the test name: + # Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n, Backslash \, Forward slash / + $NAME = "${{ matrix.test.displayName }}" -replace '[":<>|*?\\/]', '-' -replace ' ', '' + + # Check if the GITHUB_OUTPUT is set + if ([string]::IsNullOrEmpty($env:GITHUB_OUTPUT)) { + # We do not have github output, then use the set output command + Write-Output "::set-output name=artifact-name::$NAME" + exit + } + Add-Content -Path $env:GITHUB_OUTPUT -Value "artifact-name=$NAME-${{ matrix.os }}" + + - name: Format test run name as artifact name + if: (success() || failure()) && runner.os != 'Windows' id: format-artifact-name # Use the GITHUB_OUTPUT mechanic to set the output variable run: | From 7f27e7e5a28a045718dc4e0a8dfbd74bfda1f1fc Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 19:23:30 +0200 Subject: [PATCH 09/28] Fix github actions --- .github/workflows/test-prs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 9e2807dd8..2b5289259 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -101,7 +101,7 @@ jobs: - name: Format test run name as artifact name if: (success() || failure()) && runner.os == 'Windows' - id: format-artifact-name + id: format-artifact-name-windows # Use the GITHUB_OUTPUT mechanic to set the output variable run: | # We need to remove all invalid characters from the test name: @@ -118,7 +118,7 @@ jobs: - name: Format test run name as artifact name if: (success() || failure()) && runner.os != 'Windows' - id: format-artifact-name + id: format-artifact-name-unix # Use the GITHUB_OUTPUT mechanic to set the output variable run: | # We need to remove all invalid characters from the test name: From 36a3bf1b8df33ee26294ddd427a3394c5adf7886 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 19:31:02 +0200 Subject: [PATCH 10/28] Fix ids of uploads --- .github/workflows/test-prs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 2b5289259..8cc6ee3b9 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -111,7 +111,7 @@ jobs: # Check if the GITHUB_OUTPUT is set if ([string]::IsNullOrEmpty($env:GITHUB_OUTPUT)) { # We do not have github output, then use the set output command - Write-Output "::set-output name=artifact-name::$NAME" + Write-Output "::set-output name=artifact-name::$NAME-${{ matrix.os }}" exit } Add-Content -Path $env:GITHUB_OUTPUT -Value "artifact-name=$NAME-${{ matrix.os }}" @@ -127,7 +127,7 @@ jobs: # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command - echo "::set-output name=artifact-name::$NAME" + echo "::set-output name=artifact-name::$NAME-${{ matrix.os }}" exit 0 fi echo "artifact-name=$NAME-${{ matrix.os }}" >> "$GITHUB_OUTPUT" From ddd3fbfb75bb2430f9a4675fca72e521673e90c8 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 19:37:58 +0200 Subject: [PATCH 11/28] echo the artifact name. --- .github/workflows/test-prs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 8cc6ee3b9..ab674ffb5 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -109,6 +109,7 @@ jobs: $NAME = "${{ matrix.test.displayName }}" -replace '[":<>|*?\\/]', '-' -replace ' ', '' # Check if the GITHUB_OUTPUT is set + Write-Output "Determined name to be $NAME-${{ matrix.os }}" if ([string]::IsNullOrEmpty($env:GITHUB_OUTPUT)) { # We do not have github output, then use the set output command Write-Output "::set-output name=artifact-name::$NAME-${{ matrix.os }}" @@ -125,6 +126,7 @@ jobs: # Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n, Backslash \, Forward slash / NAME=$(echo "${{ matrix.test.displayName }}" | tr '":<>|*?\\/' '-' | tr -d ' ') # Check if the GITHUB_OUTPUT is set + echo "Determined name to be $NAME-${{ matrix.os }}" if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command echo "::set-output name=artifact-name::$NAME-${{ matrix.os }}" From 7403fc66b8681e7baf3244c513e1c4fd50770e44 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 19:42:56 +0200 Subject: [PATCH 12/28] Actually upload with the right artifact name --- .github/workflows/test-prs.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index ab674ffb5..3afedf1c7 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -135,10 +135,18 @@ jobs: echo "artifact-name=$NAME-${{ matrix.os }}" >> "$GITHUB_OUTPUT" - uses: actions/upload-artifact@v4 - if: success() || failure() + if: (success() || failure()) && runner.os != 'Windows' + with: + if-no-files-found: ignore + name: test-results-${{ steps.format-artifact-name-unix.outputs.artifact-name }} + path: junit.xml + retention-days: 1 + + - uses: actions/upload-artifact@v4 + if: (success() || failure()) && runner.os == 'Windows' with: if-no-files-found: ignore - name: test-results-${{ steps.format-artifact-name.outputs.artifact-name }} + name: test-results-${{ steps.format-artifact-name-windows.outputs.artifact-name }} path: junit.xml retention-days: 1 From 5c65d73b82f05e6d013006fa57c8b92bbb27f253 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 21:14:34 +0200 Subject: [PATCH 13/28] Update training wheels. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5f5504818..33b8c31a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,4 +36,4 @@ spock_version=2.1 spock_groovy_version=3.0 mockito_version=4.11.0 jimfs_version=1.2 -trainingwheels_version=1.0.46 \ No newline at end of file +trainingwheels_version=1.0.47 \ No newline at end of file From 6fad909640595dffa1d8272793133dc1e5e58c6a Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Thu, 30 May 2024 21:30:49 +0200 Subject: [PATCH 14/28] Fix a bunch of tests. --- .../net/neoforged/gradle/common/CommonPlugin.java | 6 +++--- .../gradle/common/CommonProjectPlugin.java | 2 +- .../neoforged/gradle/common/util/ToolUtilities.java | 13 ++++--------- .../dependency/UserDevDependencyManager.java | 6 ++---- .../gradle/vanilla/AccessTransformerTests.groovy | 2 +- .../gradle/vanilla/VanillaProjectPlugin.java | 2 +- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java b/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java index a43ede574..ec84a5072 100644 --- a/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java +++ b/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java @@ -2,12 +2,12 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; +import org.jetbrains.annotations.NotNull; public class CommonPlugin implements Plugin { @Override - public void apply(Object o) { - if (o instanceof Project) { - final Project project = (Project) o; + public void apply(@NotNull Object o) { + if (o instanceof Project project) { project.getPluginManager().apply(CommonProjectPlugin.class); } else { throw new IllegalArgumentException("CommonPlugin can only be applied to a project"); diff --git a/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java b/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java index e33e84ec5..586b0052d 100644 --- a/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java +++ b/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java @@ -116,7 +116,7 @@ public void apply(Project project) { project.getRepositories().maven(e -> { e.setUrl(UrlConstants.MOJANG_MAVEN); - e.metadataSources(MavenArtifactRepository.MetadataSources::artifact); + e.metadataSources(MavenArtifactRepository.MetadataSources::mavenPom); }); project.getExtensions().getByType(SourceSetContainer.class).configureEach(sourceSet -> { diff --git a/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java b/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java index 7ba8754cc..db241d321 100644 --- a/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java +++ b/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java @@ -1,12 +1,10 @@ package net.neoforged.gradle.common.util; -import net.neoforged.gradle.dsl.common.extensions.repository.Repository; import net.neoforged.gradle.dsl.common.util.ConfigurationUtils; import net.neoforged.gradle.util.ModuleDependencyUtils; import org.gradle.api.Project; import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.ResolvedArtifact; -import org.gradle.api.artifacts.repositories.ArtifactRepository; import java.io.File; import java.util.function.Supplier; @@ -18,7 +16,7 @@ private ToolUtilities() { } public static File resolveTool(final Project project, final String tool) { - return resolveTool(project, () -> ConfigurationUtils.temporaryUnhandledConfiguration( + return resolveTool(() -> ConfigurationUtils.temporaryUnhandledConfiguration( project.getConfigurations(), "ToolLookupFor" + ModuleDependencyUtils.toConfigurationName(tool), project.getDependencies().create(tool) @@ -26,7 +24,7 @@ public static File resolveTool(final Project project, final String tool) { } public static ResolvedArtifact resolveToolArtifact(final Project project, final String tool) { - return resolveTool(project, () -> ConfigurationUtils.temporaryUnhandledConfiguration( + return resolveTool(() -> ConfigurationUtils.temporaryUnhandledConfiguration( project.getConfigurations(), "ToolLookupFor" + ModuleDependencyUtils.toConfigurationName(tool), project.getDependencies().create(tool) @@ -34,17 +32,14 @@ public static ResolvedArtifact resolveToolArtifact(final Project project, final } public static ResolvedArtifact resolveToolArtifact(final Project project, final Dependency tool) { - return resolveTool(project, () -> ConfigurationUtils.temporaryUnhandledConfiguration( + return resolveTool(() -> ConfigurationUtils.temporaryUnhandledConfiguration( project.getConfigurations(), "ToolLookupFor" + ModuleDependencyUtils.toConfigurationName(tool), tool ).getResolvedConfiguration().getResolvedArtifacts().iterator().next()); } - private static T resolveTool(final Project project, final Supplier searcher) { - //Grab the dynamic repository - final Repository repository = project.getExtensions().getByType(Repository.class); - + private static T resolveTool(final Supplier searcher) { //Return the resolved artifact return searcher.get(); } diff --git a/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java b/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java index 45c3bfb23..29b4f02a8 100644 --- a/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java +++ b/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java @@ -29,12 +29,10 @@ public void apply(final Project project) { return Optional.empty(); } - if (!(context.getDependency() instanceof ExternalModuleDependency)) { + if (!(context.getDependency() instanceof ExternalModuleDependency externalModuleDependency)) { return Optional.empty(); } - - final ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) context.getDependency(); - + final UserDevRuntimeDefinition runtimeDefinition = buildForgeUserDevRuntimeFrom(project, externalModuleDependency); final Configuration additionalDependenciesConfiguration = ConfigurationUtils.temporaryConfiguration( diff --git a/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy b/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy index ed17ae466..ab04bced9 100644 --- a/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy +++ b/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy @@ -45,7 +45,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { when: def initialRun = project.run { it.tasks('build') - it.debug() + it.stacktrace() } then: diff --git a/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java b/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java index 39558d892..6cb1b799c 100644 --- a/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java +++ b/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java @@ -13,7 +13,7 @@ public class VanillaProjectPlugin implements Plugin { public void apply(Project project) { project.getPlugins().apply(CommonPlugin.class); - VanillaRuntimeExtension runtimeExtension = project.getExtensions().create("vanillaRuntimes", VanillaRuntimeExtension.class, project); + project.getExtensions().create("vanillaRuntimes", VanillaRuntimeExtension.class, project); //Setup handling of the dependencies VanillaDependencyManager.getInstance().apply(project); From 2183ba6864545cd955322bd91d19fa0ea70e0ee8 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 10:28:17 +0200 Subject: [PATCH 15/28] Adapt tests with central config cache directories to run under test. --- .../gradle/neoform/FunctionalTests.groovy | 8 +++--- .../userdev/AccessTransformerTests.groovy | 10 +++---- .../gradle/userdev/CentralCacheTests.groovy | 2 +- .../userdev/ConfigurationCacheTests.groovy | 4 +-- .../gradle/userdev/ConfigurationTests.groovy | 4 +-- .../gradle/userdev/DepreciationTests.groovy | 4 +-- .../gradle/userdev/FunctionalTests.groovy | 18 ++++++------ .../gradle/userdev/MultiProjectTests.groovy | 18 ++++++------ .../neoforged/gradle/userdev/RunTests.groovy | 12 ++++---- .../convention/IDEAIDEConventionTests.groovy | 10 +++---- .../convention/RunConventionTests.groovy | 16 +++++------ .../SourceSetConventionTests.groovy | 28 +++++++++---------- 12 files changed, 67 insertions(+), 67 deletions(-) diff --git a/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy b/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy index 82a2a8b3a..d7bde6ce3 100644 --- a/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy +++ b/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy @@ -30,7 +30,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) } when: @@ -57,7 +57,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) } when: @@ -102,7 +102,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) } when: @@ -141,7 +141,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.enableLocalBuildCache() } diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy index 8bb131c55..1a10d8af9 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy @@ -41,7 +41,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -82,7 +82,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -125,7 +125,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -169,7 +169,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -213,7 +213,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy index 360c8df0b..f63e21dc9 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy @@ -60,7 +60,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.property(CentralCacheService.MAX_CACHE_SIZE_PROPERTY, "4") }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy index 7cdec4d30..ad1dc0b42 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy @@ -32,7 +32,7 @@ class ConfigurationCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.enableLocalBuildCache() it.enableConfigurationCache() it.enableBuildScan() @@ -73,7 +73,7 @@ class ConfigurationCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.enableLocalBuildCache() it.enableConfigurationCache() }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy index 582e97f86..471a4c468 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy @@ -44,7 +44,7 @@ class ConfigurationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -103,7 +103,7 @@ No dependencies } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy index f01d05a31..c3d5a0893 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy @@ -28,7 +28,7 @@ class DepreciationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -71,7 +71,7 @@ class DepreciationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy index 178f647dd..bc4a5dd5e 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy @@ -28,7 +28,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -66,7 +66,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -110,7 +110,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -149,7 +149,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -188,7 +188,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -226,7 +226,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -267,7 +267,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { """) it.withToolchains() it.enableLocalBuildCache() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -326,7 +326,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { """) it.withToolchains() it.enableLocalBuildCache() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -395,7 +395,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy index 6c8cb71d2..ec2f18f77 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy @@ -23,7 +23,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) def apiProject = create(rootProject, "api", { @@ -50,7 +50,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.plugin(this.pluginUnderTest) }) @@ -87,7 +87,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.plugin(this.pluginUnderTest) }) @@ -116,7 +116,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } } """) - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.withToolchains() }) @@ -144,7 +144,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.plugin(this.pluginUnderTest) }) @@ -181,7 +181,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.plugin(this.pluginUnderTest) }) @@ -207,7 +207,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) def apiProject = create(rootProject, "api", { @@ -231,7 +231,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.plugin("java-library") }) @@ -268,7 +268,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) it.plugin(this.pluginUnderTest) }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy index 21478d158..adc4a3296 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy @@ -48,7 +48,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -91,7 +91,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -133,7 +133,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -185,7 +185,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -241,7 +241,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -302,7 +302,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy index 100764cb7..b8b9d7fc4 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy @@ -35,7 +35,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -71,7 +71,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -107,7 +107,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -143,7 +143,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -178,7 +178,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy index 1c951e718..776421f91 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy @@ -40,7 +40,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -79,7 +79,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -118,7 +118,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -158,7 +158,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -195,7 +195,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -228,7 +228,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -265,7 +265,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -302,7 +302,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy index ca2f893b5..07a1158c0 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy @@ -32,7 +32,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -65,7 +65,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -98,7 +98,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -131,7 +131,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -164,7 +164,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -197,7 +197,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -238,7 +238,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -279,7 +279,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -320,7 +320,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -360,7 +360,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -398,7 +398,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -445,7 +445,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -492,7 +492,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: @@ -529,7 +529,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) }) when: From d2e8e1feffd9e7d476828be857373e054ac3ca00 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 14:47:12 +0200 Subject: [PATCH 16/28] Fix tests and bump TW to handle windows paths. --- gradle.properties | 2 +- .../neoforged/gradle/userdev/CentralCacheTests.groovy | 3 +-- .../neoforged/gradle/userdev/ConfigurationTests.groovy | 10 ++++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 33b8c31a2..e6dcbc3f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,4 +36,4 @@ spock_version=2.1 spock_groovy_version=3.0 mockito_version=4.11.0 jimfs_version=1.2 -trainingwheels_version=1.0.47 \ No newline at end of file +trainingwheels_version=1.0.48 \ No newline at end of file diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy index f63e21dc9..8e3c78cec 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy @@ -76,7 +76,6 @@ class CentralCacheTests extends BuilderBasedTestSpecification { when: def cleanRun = project.run { it.tasks('clean') - it.debug() } then: @@ -148,7 +147,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, cacheDir.getAbsolutePath()) + it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, cacheDir.getAbsolutePath().replace("\\", "\\\\")) it.property(CentralCacheService.LOG_CACHE_HITS_PROPERTY, "true") }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy index 471a4c468..d869311bf 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy @@ -54,12 +54,10 @@ class ConfigurationTests extends BuilderBasedTestSpecification { then: run.task(':dependencies').outcome == TaskOutcome.SUCCESS - run.output.contains( -''' -implementation - Implementation dependencies for the 'main' feature. (n) -No dependencies -''' - ) + def implementationStartLine = run.output.split(System.lineSeparator()).toList().indexOf('implementation - Implementation dependencies for the \'main\' feature. (n)') + implementationStartLine != -1 + def nextLine = run.output.split(System.lineSeparator()).toList().get(implementationStartLine + 1) + nextLine.contains("No dependencies") } def "a mod with userdev in the implementation configuration does not leak it via publishing"() { From 1c440fad89d9c42d95a28b58bb59a22a1ebd6546 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 15:33:23 +0200 Subject: [PATCH 17/28] Fix the remaining tests. --- .../groovy/net/neoforged/gradle/userdev/RunTests.groovy | 6 +++--- .../userdev/convention/SourceSetConventionTests.groovy | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy index adc4a3296..f317e9e8f 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy @@ -204,7 +204,7 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "userdev supports custom run dependencies from configuration"() { @@ -260,7 +260,7 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "userdev supports custom run dependencies from catalog"() { @@ -321,6 +321,6 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } } diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy index 07a1158c0..1aec2226e 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy @@ -244,11 +244,12 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { when: def run = project.run { it.tasks(':dependencies') + it.shouldFail() } then: - run.task(':dependencies').outcome == TaskOutcome.SUCCESS run.output.contains("Run sources: []") + run.output.contains("Run: client has no source sets configured. Please configure at least one source set.") } def "disabling sourceset conventions prevents registration of main sourceset to run"() { @@ -285,11 +286,12 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { when: def run = project.run { it.tasks(':dependencies') + it.shouldFail() } then: - run.task(':dependencies').outcome == TaskOutcome.SUCCESS run.output.contains("Run sources: []") + run.output.contains("Run: client has no source sets configured. Please configure at least one source set.") } def "disabling main source set registration conventions prevents registration of main sourceset to run"() { @@ -326,11 +328,12 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { when: def run = project.run { it.tasks(':dependencies') + it.shouldFail() } then: - run.task(':dependencies').outcome == TaskOutcome.SUCCESS run.output.contains("Run sources: []") + run.output.contains("Run: client has no source sets configured. Please configure at least one source set.") } def "having the conventions for main sourceset registration enabled registers it"() { From 17b5ea6d567e60a9c882ba7a225bc68ee9d99ce7 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 19:03:05 +0200 Subject: [PATCH 18/28] Fix the remaining tests. --- .github/workflows/test-prs.yml | 15 ++++++++++----- .../net/neoforged/gradle/userdev/RunTests.groovy | 2 +- .../convention/SourceSetConventionTests.groovy | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 3afedf1c7..11fd95a5f 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -154,7 +154,7 @@ jobs: name: Process Test Data runs-on: ubuntu-latest needs: test - if: success() || failure() + if: always() steps: - uses: actions/checkout@v3 @@ -166,23 +166,28 @@ jobs: - name: Publish Test Report uses: mikepenz/action-junit-report@v4 - if: success() || failure() # always run even if the previous step fails + if: always() # always run even if the previous step fails with: report_paths: '**/*.xml' - name: Merge Test Reports - if: success() || failure() + if: always() run: npx junit-report-merger junit.xml "**/*.xml" - uses: actions/upload-artifact@v4 - if: success() || failure() + if: always() with: name: test-results path: junit.xml - name: Failed build detection - if: failure() uses: actions/github-script@v7 + if: >- + ${{ + contains(needs.*.result, 'failure') + || contains(needs.*.result, 'cancelled') + || contains(needs.*.result, 'skipped') + }} with: script: | core.setFailed('Test build failure!') diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy index f317e9e8f..8a9dcffb4 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy @@ -152,7 +152,7 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.graalvm.polyglot/polyglot") + classpathFile.text.contains("org.graalvm.polyglot${File.separator}polyglot") !classpathFile.text.contains(".pom") } diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy index 1aec2226e..7cf7fa760 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy @@ -421,7 +421,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { classpathFile.exists() - !classpathFile.text.contains("org.jgrapht/jgrapht-core") + !classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "enabling sourceset local run runtime registration conventions registers localRunRuntime"() { @@ -468,7 +468,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "using the local runtime convention configuration does not put the dependency on the runtime config"() { From 5fcc6a94999b4dd6338d67b4d5c512862c2375ef Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 20:37:47 +0200 Subject: [PATCH 19/28] Create extension for the tests. --- build.gradle | 1 + .../gradle/neoform/FunctionalTests.groovy | 8 +++--- settings.gradle | 1 + test-utils/build.gradle | 17 +++++++++++ .../test/extensions/FileExtensions.groovy | 14 ++++++++++ .../RuntimeBuilderExtensions.groovy | 23 +++++++++++++++ ...rg.codehaus.groovy.runtime.ExtensionModule | 3 ++ .../userdev/AccessTransformerTests.groovy | 10 +++---- .../gradle/userdev/CentralCacheTests.groovy | 10 +++++-- .../userdev/ConfigurationCacheTests.groovy | 4 +-- .../gradle/userdev/ConfigurationTests.groovy | 4 +-- .../gradle/userdev/DepreciationTests.groovy | 4 +-- .../gradle/userdev/FunctionalTests.groovy | 18 ++++++------ .../gradle/userdev/MultiProjectTests.groovy | 18 ++++++------ .../neoforged/gradle/userdev/RunTests.groovy | 12 ++++---- .../convention/IDEAIDEConventionTests.groovy | 10 +++---- .../convention/RunConventionTests.groovy | 16 +++++------ .../SourceSetConventionTests.groovy | 28 +++++++++---------- 18 files changed, 132 insertions(+), 69 deletions(-) create mode 100644 test-utils/build.gradle create mode 100644 test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy create mode 100644 test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy create mode 100644 test-utils/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule diff --git a/build.gradle b/build.gradle index 6662bb0b3..650c2710f 100644 --- a/build.gradle +++ b/build.gradle @@ -163,6 +163,7 @@ subprojects.forEach { subProject -> spec.exclude group: 'org.codehaus.groovy' } evalSubProject.dependencies.functionalTestImplementation "net.neoforged.trainingwheels:gradle-functional:${project.trainingwheels_version}" + evalSubProject.dependencies.functionalTestImplementation project(':test-utils') //Configure the plugin metadata, so we can publish it. evalSubProject.gradlePlugin.plugins { NamedDomainObjectContainer plugins -> diff --git a/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy b/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy index d7bde6ce3..317584372 100644 --- a/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy +++ b/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy @@ -30,7 +30,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) } when: @@ -57,7 +57,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) } when: @@ -102,7 +102,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) } when: @@ -141,7 +141,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.enableLocalBuildCache() } diff --git a/settings.gradle b/settings.gradle index ccfffe2be..78d468739 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,6 +11,7 @@ plugins { rootProject.name = 'NeoGradle' include 'utils' +include 'test-utils' include 'common' include 'vanilla' include 'neoform' diff --git a/test-utils/build.gradle b/test-utils/build.gradle new file mode 100644 index 000000000..4b234197a --- /dev/null +++ b/test-utils/build.gradle @@ -0,0 +1,17 @@ +plugins { + id 'groovy' +} + +dependencies.api dependencies.gradleTestKit() +dependencies.api "org.junit.jupiter:junit-jupiter-api:${project.junit_version}" +dependencies.api "org.junit.jupiter:junit-jupiter-params:${project.junit_version}" +dependencies.api "org.junit.jupiter:junit-jupiter-engine:${project.junit_version}" +dependencies.api "org.junit.platform:junit-platform-engine:${project.junit_platform_version}" +dependencies.api "org.mockito:mockito-junit-jupiter:${project.mockito_version}" +dependencies.api "org.mockito:mockito-core:${project.mockito_version}" +dependencies.api "org.mockito:mockito-inline:${project.mockito_version}" +dependencies.api "net.neoforged.trainingwheels:base:${project.trainingwheels_version}" +dependencies.api "net.neoforged.trainingwheels:gradle-base:${project.trainingwheels_version}" +dependencies.api "net.neoforged.trainingwheels:gradle-functional:${project.trainingwheels_version}" + +dependencies.implementation project(':common') \ No newline at end of file diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy new file mode 100644 index 000000000..02f24e859 --- /dev/null +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy @@ -0,0 +1,14 @@ +package net.neoforged.gradle.utils.test.extensions + +/** + * Extensions for the [File] class. + */ +class FileExtensions { + + /** + * @return the absolute path of the file with backslashes escaped. + */ + static String getPropertiesPath(final File self) { + return self.absolutePath.replace("\\", "\\\\") + } +} diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy new file mode 100644 index 000000000..a829ad076 --- /dev/null +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy @@ -0,0 +1,23 @@ +package net.neoforged.gradle.utils.test.extensions + +import net.neoforged.gradle.common.caching.CentralCacheService +import net.neoforged.trainingwheels.gradle.functional.builder.Runtime + +/** + * Extensions for the [Runtime.Builder] class. + */ +class RuntimeBuilderExtensions { + + /** + * Sets the global cache directory to the given [testProjectDir]. + * + * @param testProjectDir the directory to use as the global cache directory + * @return the global cache directory + */ + 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) + + return cacheDir + } +} diff --git a/test-utils/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/test-utils/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule new file mode 100644 index 000000000..ab48055f1 --- /dev/null +++ b/test-utils/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule @@ -0,0 +1,3 @@ +moduleName = neogradle-test-utils-module +moduleVersion = 1.0 +extensionClasses = net.neoforged.gradle.utils.test.extensions.FileExtensions,net.neoforged.gradle.utils.test.extensions.RuntimeBuilderExtensions \ No newline at end of file diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy index 1a10d8af9..13115fb6e 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy @@ -41,7 +41,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -82,7 +82,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -125,7 +125,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -169,7 +169,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -213,7 +213,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy index 8e3c78cec..74adda905 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy @@ -60,7 +60,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.property(CentralCacheService.MAX_CACHE_SIZE_PROPERTY, "4") }) @@ -133,7 +133,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { def "cache_supports_cleanup_and_take_over_of_failed_lock"() { given: - def cacheDir = new File(tempDir, ".caches-global") + File cacheDir; def project = create("cache_supports_cleanup_and_take_over_of_failed_lock", { it.build(""" java { @@ -147,10 +147,14 @@ class CentralCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, cacheDir.getAbsolutePath().replace("\\", "\\\\")) + cacheDir = it.withGlobalCacheDirectory(tempDir) it.property(CentralCacheService.LOG_CACHE_HITS_PROPERTY, "true") }) + if (cacheDir == null) { + throw new IllegalStateException("Cache directory was not set") + } + when: project.run { it.tasks('build') diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy index ad1dc0b42..3b9bdb96f 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy @@ -32,7 +32,7 @@ class ConfigurationCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.enableLocalBuildCache() it.enableConfigurationCache() it.enableBuildScan() @@ -73,7 +73,7 @@ class ConfigurationCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.enableLocalBuildCache() it.enableConfigurationCache() }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy index d869311bf..3faeb29d1 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy @@ -44,7 +44,7 @@ class ConfigurationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -101,7 +101,7 @@ class ConfigurationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy index c3d5a0893..061d623ce 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy @@ -28,7 +28,7 @@ class DepreciationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -71,7 +71,7 @@ class DepreciationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy index bc4a5dd5e..17b5716e0 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy @@ -28,7 +28,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -66,7 +66,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -110,7 +110,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -149,7 +149,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -188,7 +188,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -226,7 +226,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -267,7 +267,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { """) it.withToolchains() it.enableLocalBuildCache() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -326,7 +326,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { """) it.withToolchains() it.enableLocalBuildCache() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -395,7 +395,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy index ec2f18f77..ffec9f665 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy @@ -23,7 +23,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) def apiProject = create(rootProject, "api", { @@ -50,7 +50,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -87,7 +87,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -116,7 +116,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } } """) - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.withToolchains() }) @@ -144,7 +144,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -181,7 +181,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -207,7 +207,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) def apiProject = create(rootProject, "api", { @@ -231,7 +231,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.plugin("java-library") }) @@ -268,7 +268,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy index 8a9dcffb4..2b3339039 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy @@ -48,7 +48,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -91,7 +91,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -133,7 +133,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -185,7 +185,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -241,7 +241,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -302,7 +302,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy index b8b9d7fc4..06c69ca1c 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy @@ -35,7 +35,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -71,7 +71,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -107,7 +107,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -143,7 +143,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -178,7 +178,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy index 776421f91..8f83f4771 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy @@ -40,7 +40,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -79,7 +79,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -118,7 +118,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -158,7 +158,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -195,7 +195,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -228,7 +228,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -265,7 +265,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -302,7 +302,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy index 7cf7fa760..6d29958ad 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy @@ -32,7 +32,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -65,7 +65,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -98,7 +98,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -131,7 +131,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -164,7 +164,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -197,7 +197,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -238,7 +238,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -280,7 +280,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -322,7 +322,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -363,7 +363,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -401,7 +401,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -448,7 +448,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -495,7 +495,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -532,7 +532,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath().replace("\\", "\\\\")) + it.withGlobalCacheDirectory(tempDir) }) when: From 0ad6325cdf86419a64d8cac295c16be3955e7d26 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 20:49:15 +0200 Subject: [PATCH 20/28] Limit the build to 15 agents, and auto cancel --- .github/workflows/test-prs.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 11fd95a5f..d41cb6846 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -9,6 +9,10 @@ on: - ready_for_review - reopened +concurrency: + group: ci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: setup: name: Setup @@ -66,6 +70,7 @@ jobs: runs-on: "${{ matrix.os }}-latest" needs: setup strategy: + max-parallel: 15 fail-fast: false matrix: test: ${{ fromJSON(needs.setup.outputs.tests-to-run) }} From 03a8ab0c48b319f4e56a086c0eaa1ef7fcfa067f Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 21:13:39 +0200 Subject: [PATCH 21/28] Address maties requests --- .github/gradle/gradle.gradle | 12 ------------ .../utils/test/extensions/FileExtensions.groovy | 3 +++ .../test/extensions/RuntimeBuilderExtensions.groovy | 6 ++++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/gradle/gradle.gradle b/.github/gradle/gradle.gradle index bb2f3dd2a..59426d8b9 100644 --- a/.github/gradle/gradle.gradle +++ b/.github/gradle/gradle.gradle @@ -83,18 +83,6 @@ class TestRun { String displayName String path String filter - - String getDisplayName() { - return displayName - } - - String getPath() { - return path - } - - String getFilter() { - return filter - } } subprojects.forEach { Project subProject -> diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy index 02f24e859..b314a20d6 100644 --- a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy @@ -1,8 +1,11 @@ package net.neoforged.gradle.utils.test.extensions +import groovy.transform.CompileStatic + /** * Extensions for the [File] class. */ +@CompileStatic class FileExtensions { /** diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy index a829ad076..83125f318 100644 --- a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy @@ -1,15 +1,17 @@ package net.neoforged.gradle.utils.test.extensions +import groovy.transform.CompileStatic import net.neoforged.gradle.common.caching.CentralCacheService import net.neoforged.trainingwheels.gradle.functional.builder.Runtime /** - * Extensions for the [Runtime.Builder] class. + * Extensions for the {@link Runtime.Builder} class. */ +@CompileStatic class RuntimeBuilderExtensions { /** - * Sets the global cache directory to the given [testProjectDir]. + * Sets the global cache directory to the given {@param testProjectDir}. * * @param testProjectDir the directory to use as the global cache directory * @return the global cache directory From a305b4b3cb4e697d643f7a4dcd49ba07ae9bf75c Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 21:36:40 +0200 Subject: [PATCH 22/28] Address changes requested by sci, and use extension method instead of property --- .github/gradle/gradle.gradle | 23 +++++++++++-------- .../RuntimeBuilderExtensions.groovy | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/gradle/gradle.gradle b/.github/gradle/gradle.gradle index 59426d8b9..4fa0dfd8a 100644 --- a/.github/gradle/gradle.gradle +++ b/.github/gradle/gradle.gradle @@ -8,13 +8,12 @@ if (!project.hasProperty('githubCiTesting') && System.env['GITHUB_OUTPUT'] == nu static Map removeCommonPrefix(List list) { if (list.size() == 0) { - return new HashMap() + return [:] } def result = new HashMap() - 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 @@ -23,21 +22,27 @@ static Map removeCommonPrefix(List 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) { @@ -64,7 +69,7 @@ static String createDisplayNameSuffix(String path, String filter) { } static List createTestRuns(Task it, List testClasses) { - def testRuns = new ArrayList() + def testRuns = [] if (testClasses.size() == 0) { testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, null)}", path: it.path, filter: null)) return testRuns diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy index 83125f318..693a25e7b 100644 --- a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy @@ -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 } From 536ab8eea7f68b6c85e9fac1050364fed2d620d5 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 21:42:53 +0200 Subject: [PATCH 23/28] Fix compile error --- .github/gradle/gradle.gradle | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/gradle/gradle.gradle b/.github/gradle/gradle.gradle index 4fa0dfd8a..7a8366480 100644 --- a/.github/gradle/gradle.gradle +++ b/.github/gradle/gradle.gradle @@ -23,26 +23,21 @@ static Map removeCommonPrefix(List list) { 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) { - break comparisonLoop + for (final def entry in list) { + result.put(entry, entry.substring(prefix.length())) + } + return result } } prefix += currentChar } - 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 + throw new IllegalArgumentException("Could not remove common prefix: ${list}") } static String createDisplayNameSuffix(String path, String filter) { @@ -69,7 +64,7 @@ static String createDisplayNameSuffix(String path, String filter) { } static List createTestRuns(Task it, List testClasses) { - def testRuns = [] + def testRuns = new ArrayList() if (testClasses.size() == 0) { testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, null)}", path: it.path, filter: null)) return testRuns From d449b12910b1ffad67c382eda3f29e2da2f74a0a Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 21:43:35 +0200 Subject: [PATCH 24/28] Address more changes from SCI --- .github/gradle/gradle.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/gradle/gradle.gradle b/.github/gradle/gradle.gradle index 7a8366480..35378ce9e 100644 --- a/.github/gradle/gradle.gradle +++ b/.github/gradle/gradle.gradle @@ -64,7 +64,7 @@ static String createDisplayNameSuffix(String path, String filter) { } static List createTestRuns(Task it, List testClasses) { - def testRuns = new ArrayList() + def testRuns = [] if (testClasses.size() == 0) { testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, null)}", path: it.path, filter: null)) return testRuns @@ -87,7 +87,7 @@ class TestRun { subprojects.forEach { Project subProject -> subProject.tasks.register('determineTests') { Task it -> - def tests = new ArrayList() + def tests = [] it.group = 'infrastructure' it.doLast { From 8bb1366e19dc5a6dff84bfc41db3c80a0352fa62 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 21:52:43 +0200 Subject: [PATCH 25/28] Need to remove to compilestatic from the extensions. It does not work. --- .../neoforged/gradle/utils/test/extensions/FileExtensions.groovy | 1 - .../gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy | 1 - 2 files changed, 2 deletions(-) diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy index b314a20d6..07f9d0038 100644 --- a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy @@ -5,7 +5,6 @@ import groovy.transform.CompileStatic /** * Extensions for the [File] class. */ -@CompileStatic class FileExtensions { /** diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy index 693a25e7b..69119dcc2 100644 --- a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy @@ -7,7 +7,6 @@ import net.neoforged.trainingwheels.gradle.functional.builder.Runtime /** * Extensions for the {@link Runtime.Builder} class. */ -@CompileStatic class RuntimeBuilderExtensions { /** From d27ad0b356811f5adebd4e27508b29eaa1c4b90e Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 21:56:42 +0200 Subject: [PATCH 26/28] More groovy goodness --- .github/gradle/gradle.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/gradle/gradle.gradle b/.github/gradle/gradle.gradle index 35378ce9e..9e584e7cd 100644 --- a/.github/gradle/gradle.gradle +++ b/.github/gradle/gradle.gradle @@ -96,7 +96,7 @@ subprojects.forEach { Project subProject -> if (testSourceSetCandidate != null) { SourceSet testSourceSet = testSourceSetCandidate as SourceSet - def testClasses = new ArrayList() + def testClasses = [] testSourceSet.java.srcDirs .collect { File file -> From 42cd15be9642610b8320ff23769698b7af5b0b2b Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Fri, 31 May 2024 22:20:34 +0200 Subject: [PATCH 27/28] Fix unit tests. --- .../naming/NeoFormOfficialNamingChannelConfigurator.java | 2 +- .../userdev/convention/SourceSetConventionTests.groovy | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java b/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java index 27660e262..0f9688c9f 100644 --- a/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java +++ b/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java @@ -215,7 +215,7 @@ public abstract static class MappingsFileValueSource implements ValueSource f.getAbsoluteFile().getPath().endsWith(getParameters().getMappingsFilePath().get())).getSingleFile(); + return getParameters().getNeoFormArchive().filter(f -> f.getAbsoluteFile().getPath().replace(File.separator, "/").endsWith(getParameters().getMappingsFilePath().get())).getSingleFile(); } } } diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy index 6d29958ad..2c9701ff9 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy @@ -244,12 +244,10 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { when: def run = project.run { it.tasks(':dependencies') - it.shouldFail() } then: run.output.contains("Run sources: []") - run.output.contains("Run: client has no source sets configured. Please configure at least one source set.") } def "disabling sourceset conventions prevents registration of main sourceset to run"() { @@ -286,12 +284,10 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { when: def run = project.run { it.tasks(':dependencies') - it.shouldFail() } then: run.output.contains("Run sources: []") - run.output.contains("Run: client has no source sets configured. Please configure at least one source set.") } def "disabling main source set registration conventions prevents registration of main sourceset to run"() { @@ -328,12 +324,10 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { when: def run = project.run { it.tasks(':dependencies') - it.shouldFail() } then: run.output.contains("Run sources: []") - run.output.contains("Run: client has no source sets configured. Please configure at least one source set.") } def "having the conventions for main sourceset registration enabled registers it"() { From 58c777aaec44290425f846570f43e2c7610efbf2 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Sat, 1 Jun 2024 12:01:03 +0200 Subject: [PATCH 28/28] Fix central cache tests. --- .../neoforged/gradle/userdev/CentralCacheTests.groovy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy index 74adda905..325740d57 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy @@ -47,6 +47,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { def "clean_cache_listens_to_project_property_for_size"() { given: + File cacheDir; def project = create("build_supports_configuration_cache_build", { it.build(""" java { @@ -60,10 +61,14 @@ class CentralCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.withGlobalCacheDirectory(tempDir) + cacheDir = it.withGlobalCacheDirectory(tempDir) it.property(CentralCacheService.MAX_CACHE_SIZE_PROPERTY, "4") }) + if (cacheDir == null) { + throw new IllegalStateException("Cache directory was not set") + } + when: def run = project.run { it.tasks('build') @@ -71,7 +76,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { then: run.task(':build').outcome == TaskOutcome.SUCCESS - new File(tempDir, ".caches-global").listFiles().size() > 4 + cacheDir.listFiles().size() > 4 when: def cleanRun = project.run { @@ -81,7 +86,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { then: cleanRun.task(':clean').outcome == TaskOutcome.SUCCESS cleanRun.task(':cleanCache').outcome == TaskOutcome.SUCCESS - new File(tempDir, ".caches-global").listFiles().size() == 4 + cacheDir.listFiles().size() == 4 } def "cache_supports_running_gradle_in_parallel"() {