From d673c44ae56fcaf8368bcf3488f417e3b947158e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 9 Feb 2020 00:53:44 +0100 Subject: [PATCH] =?utf8?q?=E2=9C=85=20Don=E2=80=99t=20run=20some=20tests?= =?utf8?q?=20in=20parallel?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- build.gradle | 17 ++++++++++++++++- .../net/pterodactylus/sone/main/SoneModuleTest.kt | 2 ++ .../net/pterodactylus/sone/main/SonePluginTest.kt | 2 ++ .../kotlin/net/pterodactylus/sone/test/NotParallel.kt | 8 ++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/test/kotlin/net/pterodactylus/sone/test/NotParallel.kt diff --git a/build.gradle b/build.gradle index 78c3110..e5eaff7 100644 --- a/build.gradle +++ b/build.gradle @@ -57,8 +57,23 @@ dependencies { apply from: 'version.gradle' -test { +task parallelTest(type: Test) { maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + useJUnit { + excludeCategories 'net.pterodactylus.sone.test.NotParallel' + } +} + +task notParallelTest(type: Test) { + maxParallelForks = 1 + useJUnit { + includeCategories 'net.pterodactylus.sone.test.NotParallel' + } +} + +test { + exclude '**' + dependsOn parallelTest, notParallelTest } task fatJar(type: Jar) { diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 1a71f4b..c628334 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -17,6 +17,7 @@ import net.pterodactylus.util.config.* import net.pterodactylus.util.version.Version import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* +import org.junit.experimental.categories.* import org.mockito.Mockito.* import java.io.* import java.util.concurrent.* @@ -25,6 +26,7 @@ import kotlin.test.* const val versionString = "v80" +@Category(NotParallel::class) class SoneModuleTest { private val currentDir: File = File(".") diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt index e658fe2..0bb03af 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SonePluginTest.kt @@ -15,6 +15,7 @@ import net.pterodactylus.sone.web.* import net.pterodactylus.sone.web.notification.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* +import org.junit.experimental.categories.* import org.mockito.Mockito.* import java.io.* import java.util.concurrent.atomic.* @@ -24,6 +25,7 @@ import kotlin.test.* * Unit test for [SonePlugin]. */ @Dirty +@Category(NotParallel::class) class SonePluginTest { private var sonePlugin = SonePlugin { injector } diff --git a/src/test/kotlin/net/pterodactylus/sone/test/NotParallel.kt b/src/test/kotlin/net/pterodactylus/sone/test/NotParallel.kt new file mode 100644 index 0000000..6e00fbf --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/test/NotParallel.kt @@ -0,0 +1,8 @@ +package net.pterodactylus.sone.test + +/** + * Marker class for a JUnit [org.junit.experimental.categories.Category], to + * mark tests that should not be run parallel to other tests. + */ +class NotParallel + -- 2.7.4