Skip to content

Commit

Permalink
Various junit dependency fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ds58 authored and calvertdw committed Sep 27, 2024
1 parent ad72d4e commit ef4fc0f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ dependencies {
api("com.dorongold.plugins:task-tree:4.0.0")
api("guru.nidi:graphviz-kotlin:0.18.1")
api("com.hierynomus:sshj:0.38.0")

testApi("org.junit.jupiter:junit-jupiter-api:5.10.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.3")
api("org.junit.platform:junit-platform-launcher:1.10.3")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.3")
}

tasks.withType<Test> {
Expand Down
27 changes: 15 additions & 12 deletions src/ci/IHMCCIPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import java.time.Duration

lateinit var LogTools: IHMCBuildLogTools

/**
* Included now in IHMCBuildPlugin
*/
class IHMCCIPlugin : Plugin<Project>
{
val JUNIT_VERSION = "5.9.2"
Expand Down Expand Up @@ -78,16 +81,16 @@ class IHMCCIPlugin : Plugin<Project>
addDependencies(testProject, apiConfigurationName, runtimeConfigurationName)
configureTestTask(testProject)
}
if (!containsIHMCTestMultiProject(project))
{
addDependencies(project, "testImplementation", "testRuntimeOnly")
configureTestTask(project)
}

var allHaveCompileJava = true
testProjects.value.forEach { testProject ->
allHaveCompileJava = allHaveCompileJava && testProject.tasks.findByPath("compileJava") != null
}
// if (!containsIHMCTestMultiProject(project))
// {
// addDependencies(project, "testImplementation", "testRuntimeOnly")
// configureTestTask(project)
// }
//
// var allHaveCompileJava = true
// testProjects.value.forEach { testProject ->
// allHaveCompileJava = allHaveCompileJava && testProject.tasks.findByPath("compileJava") != null
// }
}
}

Expand Down Expand Up @@ -115,7 +118,7 @@ class IHMCCIPlugin : Plugin<Project>

if (category == "allocation") // help out users trying to run allocation tests
{
LogTools.info("Adding allocation intrumenter dependency to $apiConfigurationName in ${project.name}")
LogTools.info("Adding allocation instrumenter dependency to $apiConfigurationName in ${project.name}")
project.dependencies.add(apiConfigurationName, allocation.instrumenter())
}
}
Expand Down Expand Up @@ -217,7 +220,7 @@ class IHMCCIPlugin : Plugin<Project>
testsToTagsMap.value.forEach { entry ->
if ((category == "fast" && entry.value.isEmpty()) || entry.value.contains(category))
{
LogTools.quiet(entry.key + " " + entry.value)
LogTools.info(entry.key + " " + entry.value)
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/ci/TagParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package us.ihmc.ci

import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginConvention
import org.junit.platform.engine.TestDescriptor
import org.junit.platform.engine.discovery.ClasspathRootSelector
import org.junit.platform.engine.discovery.DiscoverySelectors
import org.junit.platform.engine.support.descriptor.MethodSource
Expand All @@ -11,6 +10,7 @@ import org.junit.platform.launcher.TestIdentifier
import org.junit.platform.launcher.TestPlan
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
import org.junit.platform.launcher.core.LauncherFactory

import java.io.File
import java.net.URL
import java.net.URLClassLoader
Expand All @@ -29,7 +29,7 @@ object TagParser
val contextClasspathUrls = arrayListOf<URL>() // all of the tests and dependencies
val selectorPaths = hashSetOf<Path>() // just the test classes in this project
assembleTestClasspath(testProject, contextClasspathUrls, selectorPaths)
LogTools.debug("Classpath entries: " + contextClasspathUrls.toString())
LogTools.debug("Classpath entries: $contextClasspathUrls")

val originalClassLoader = Thread.currentThread().contextClassLoader
val customClassLoader = URLClassLoader.newInstance(contextClasspathUrls.toTypedArray(), originalClassLoader)
Expand Down Expand Up @@ -58,7 +58,7 @@ object TagParser
private fun recursiveBuildMap(set: Set<TestIdentifier>, testPlan: TestPlan, testsToTagsMap: HashMap<String, HashSet<String>>)
{
set.forEach { testIdentifier ->
if (testIdentifier.type == TestDescriptor.Type.TEST && testIdentifier.source.isPresent && testIdentifier.source.get() is MethodSource)
if (testIdentifier.isTest && testIdentifier.source.isPresent && testIdentifier.source.get() is MethodSource)
{
val methodSource = testIdentifier.source.get() as MethodSource
LogTools.debug("Test id: ${testIdentifier.displayName} tags: ${testIdentifier.tags} path: $methodSource")
Expand Down Expand Up @@ -88,6 +88,7 @@ object TagParser
*/
private fun assembleTestClasspath(testProject: Project, contextClasspathUrls: ArrayList<URL>, selectorPaths: HashSet<Path>)
{
// TODO:
val java = testProject.convention.getPlugin(JavaPluginConvention::class.java)
// val java = testProject.convention.getPlugin(JavaLibraryPlugin::class.java)
// testProject.plugins.
Expand All @@ -102,7 +103,7 @@ object TagParser

private fun addStuffToClasspath(file: File, contextClasspathUrls: ArrayList<URL>, selectorPaths: HashSet<Path>)
{
var entryString = file.toString()
val entryString = file.toString()
val uri = file.toURI()
val path = file.toPath()
if (entryString.endsWith(".jar"))
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/us/ihmc/build/IHMCBuildPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ import org.gradle.plugins.ide.eclipse.EclipsePlugin
import org.gradle.plugins.ide.idea.IdeaPlugin
import us.ihmc.cd.AppExtension
import us.ihmc.cd.RemoteExtension
import us.ihmc.ci.IHMCCIPlugin

class IHMCBuildPlugin : Plugin<Project>
{
val ciPlugin: IHMCCIPlugin = IHMCCIPlugin()

override fun apply(project: Project)
{
project.extensions.add("app", AppExtension(project))
Expand Down Expand Up @@ -122,5 +125,7 @@ class IHMCBuildPlugin : Plugin<Project>
// IHMCBuildTools.defineExtraSourceSetCompositeTask("publishExtraSourceSets", arrayListOf("publish"), project)

IHMCBuildTools.defineDynamicCompositeTask(project)

ciPlugin.apply(project);
}
}

0 comments on commit ef4fc0f

Please sign in to comment.