From daf7702007073cefd4b1eb78bf5d8959c2eb416b Mon Sep 17 00:00:00 2001 From: Starlight220 <53231611+Starlight220@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:03:39 +0300 Subject: [PATCH] [build] Test each example in a new environment (#5662) 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. --- wpilibjExamples/build.gradle | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/wpilibjExamples/build.gradle b/wpilibjExamples/build.gradle index 570760f4cc7..d58923ca330 100644 --- a/wpilibjExamples/build.gradle +++ b/wpilibjExamples/build.gradle @@ -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') @@ -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 @@ -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) } }