From 5df91372561466aa1467f08a23b245f7d1235efb Mon Sep 17 00:00:00 2001 From: Alan Everett Date: Sat, 1 Nov 2025 17:42:30 -0400 Subject: [PATCH] Gradle build task improvements (#2164) ## Description This fixes a few problems with the Gradle `build` task and subtasks. 1. Spotless was being run on `node_modules`, resulting in errors for out-of-source files. This is now disabled. 2. All tests were running from the `build` task, resulting in unexpected windows popping up. Now only headless tests are run. 3. Headless tests were updated to run from the same root directory as the other tests. ## Meta Merge checklist: - [X] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [X] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2025.3.2 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added --- build.gradle | 2 +- .../common/configuration/NetworkConfigTest.java | 5 +++-- shared/common.gradle | 9 ++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 0370705a8..fcbbe71c3 100644 --- a/build.gradle +++ b/build.gradle @@ -92,7 +92,7 @@ spotless { format 'misc', { target fileTree('.') { include '**/*.md', '**/.gitignore' - exclude '**/build/**', '**/build-*/**' + exclude '**/build/**', '**/build-*/**', '**/node_modules/**' } trimTrailingWhitespace() indentWithSpaces(2) diff --git a/photon-core/src/test/java/org/photonvision/common/configuration/NetworkConfigTest.java b/photon-core/src/test/java/org/photonvision/common/configuration/NetworkConfigTest.java index 0cc3c027c..cd4d5e1f6 100644 --- a/photon-core/src/test/java/org/photonvision/common/configuration/NetworkConfigTest.java +++ b/photon-core/src/test/java/org/photonvision/common/configuration/NetworkConfigTest.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; import org.junit.jupiter.api.Test; +import org.photonvision.common.util.TestUtils; public class NetworkConfigTest { @Test @@ -39,13 +40,13 @@ public class NetworkConfigTest { @Test public void testDeserializeTeamNumberOrNtServerAddress() { { - var folder = Path.of("test-resources/network-old-team-number"); + var folder = TestUtils.getResourcesFolderPath(true).resolve("network-old-team-number"); var configMgr = new ConfigManager(folder, new LegacyConfigProvider(folder)); configMgr.load(); assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress); } { - var folder = Path.of("test-resources/network-new-team-number"); + var folder = TestUtils.getResourcesFolderPath(true).resolve("network-new-team-number"); var configMgr = new ConfigManager(folder, new LegacyConfigProvider(folder)); configMgr.load(); assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress); diff --git a/shared/common.gradle b/shared/common.gradle index d383ac591..5ed2f857a 100644 --- a/shared/common.gradle +++ b/shared/common.gradle @@ -71,7 +71,7 @@ tasks.register('testHeadless', Test) { showStandardStreams = true } exclude '**/*BenchmarkTest*' - workingDir = "../" + workingDir = new File("${rootDir}") } jacoco { @@ -96,3 +96,10 @@ jacocoTestReport { })) } } + +// Only run headless tests from the build task +gradle.taskGraph.whenReady { graph -> + if (graph.hasTask(build)) { + test.enabled = false + } +}