Skip to content

Commit 5df9137

Browse files
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
1 parent 36b4373 commit 5df9137

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ spotless {
9292
format 'misc', {
9393
target fileTree('.') {
9494
include '**/*.md', '**/.gitignore'
95-
exclude '**/build/**', '**/build-*/**'
95+
exclude '**/build/**', '**/build-*/**', '**/node_modules/**'
9696
}
9797
trimTrailingWhitespace()
9898
indentWithSpaces(2)

photon-core/src/test/java/org/photonvision/common/configuration/NetworkConfigTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.IOException;
2626
import java.nio.file.Path;
2727
import org.junit.jupiter.api.Test;
28+
import org.photonvision.common.util.TestUtils;
2829

2930
public class NetworkConfigTest {
3031
@Test
@@ -39,13 +40,13 @@ public void testSerialization() throws IOException {
3940
@Test
4041
public void testDeserializeTeamNumberOrNtServerAddress() {
4142
{
42-
var folder = Path.of("test-resources/network-old-team-number");
43+
var folder = TestUtils.getResourcesFolderPath(true).resolve("network-old-team-number");
4344
var configMgr = new ConfigManager(folder, new LegacyConfigProvider(folder));
4445
configMgr.load();
4546
assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress);
4647
}
4748
{
48-
var folder = Path.of("test-resources/network-new-team-number");
49+
var folder = TestUtils.getResourcesFolderPath(true).resolve("network-new-team-number");
4950
var configMgr = new ConfigManager(folder, new LegacyConfigProvider(folder));
5051
configMgr.load();
5152
assertEquals("9999", configMgr.getConfig().getNetworkConfig().ntServerAddress);

shared/common.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ tasks.register('testHeadless', Test) {
7171
showStandardStreams = true
7272
}
7373
exclude '**/*BenchmarkTest*'
74-
workingDir = "../"
74+
workingDir = new File("${rootDir}")
7575
}
7676

7777
jacoco {
@@ -96,3 +96,10 @@ jacocoTestReport {
9696
}))
9797
}
9898
}
99+
100+
// Only run headless tests from the build task
101+
gradle.taskGraph.whenReady { graph ->
102+
if (graph.hasTask(build)) {
103+
test.enabled = false
104+
}
105+
}

0 commit comments

Comments
 (0)