Skip to content

Commit

Permalink
[build] Test each example in a new environment (wpilibsuite#5662)
Browse files Browse the repository at this point in the history
In C++ each example is a separate source set, but in Java they were one source set and tested as one with the test task. Example-specific test tasks exist for Java, but they weren't used.
This modifies the test task to exclude the example tests, instead depending on each example's test task. The advantage of this is that each example is tested in a separate environment, so leftover state from one example isn't carried over.
  • Loading branch information
Starlight220 authored Sep 18, 2023
1 parent e67df8c commit daf7702
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions wpilibjExamples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ ext {

apply from: "${rootDir}/shared/opencv.gradle"

test {
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
testLogging {
events "failed"
exceptionFormat "full"
}
finalizedBy jacocoTestReport
}

if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) {
test.enabled = false
}

dependencies {
implementation project(':wpilibj')
implementation project(':apriltag')
Expand Down Expand Up @@ -197,6 +183,10 @@ model {
includeTestsMatching("edu.wpi.first.wpilibj.examples.${entry.foldername}.*")
setFailOnNoMatchingTests(false)
}
test.filter {
excludeTestsMatching("edu.wpi.first.wpilibj.examples.${entry.foldername}.*")
setFailOnNoMatchingTests(false)
}
testTask.classpath = sourceSets.test.runtimeClasspath
testTask.dependsOn it.tasks.install

Expand All @@ -209,6 +199,11 @@ model {
testTask.environment 'LD_LIBRARY_PATH', filePath
testTask.environment 'DYLD_LIBRARY_PATH', filePath
testTask.workingDir filePath

if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) {
testTask.enabled = false
}
test.dependsOn(testTask)
}
}

Expand Down

0 comments on commit daf7702

Please sign in to comment.